void Camera::rotateYX(REAL ay, REAL ax) //[]---------------------------------------------------[] //| Rotate YX. | //| | //| Composition of an azimuth of ay with an elavation | //| of ax (in degrees). | //[]---------------------------------------------------[] { if (Math::isZero(ay)) { elevation(ax); return; } Transf3 r; r.rotation(focalPoint, viewUp, Math::toRadians<REAL>(ay)); if (!Math::isZero(ax)) { Vec3 axis = directionOfProjection.cross(viewUp); Transf3 q; q.rotation(focalPoint, axis, Math::toRadians<REAL>(ax)); q.transformVectorRef(viewUp); r.compose(q); } r.transformRef(position); updateDOP(); }
void Camera::yaw(REAL angle) //[]---------------------------------------------------[] //| Yaw. | //| | //| Rotate the focal point about the view up vector | //| centered at the camera's position. | //[]---------------------------------------------------[] { if (!Math::isZero(angle)) { Transf3 r; r.rotation(position, viewUp, Math::toRadians<REAL>(angle)); r.transformRef(focalPoint); updateDOP(); } }
void Camera::roll(REAL angle) //[]---------------------------------------------------[] //| Roll. | //| | //| Rotate the view up vector around the view plane | //| normal | //[]---------------------------------------------------[] { if (!Math::isZero(angle)) { Transf3 r; r.rotation(directionOfProjection, -Math::toRadians<REAL>(angle)); r.transformVectorRef(viewUp); viewModified = true; } }
void Camera::azimuth(REAL angle) //[]---------------------------------------------------[] //| Azimuth. | //| | //| Rotate the camera's position about the view up | //| vector centered at the focal point. | //[]---------------------------------------------------[] { if (!Math::isZero(angle)) { Transf3 r; r.rotation(focalPoint, viewUp, Math::toRadians<REAL>(angle)); r.transformRef(position); updateDOP(); } }
void Camera::pitch(REAL angle) //[]---------------------------------------------------[] //| Pitch. | //| | //| Rotate the focal point about the cross product of | //| the view up vector and the view plane normal | //| centered at the camera's position. | //[]---------------------------------------------------[] { if (!Math::isZero(angle)) { Vec3 axis = directionOfProjection.cross(viewUp); Transf3 r; r.rotation(position, axis, Math::toRadians<REAL>(angle)); r.transformRef(focalPoint); updateDOP(); viewUp = axis.cross(directionOfProjection); } }
void Camera::elevation(REAL angle) //[]---------------------------------------------------[] //| Elevation. | //| | //| Rotate the camera's position about the cross | //| product of the view plane normal and the view up | //| vector centered at the focal point. | //[]---------------------------------------------------[] { if (!Math::isZero(angle)) { Vec3 axis = directionOfProjection.cross(viewUp); Transf3 r; r.rotation(focalPoint, axis, Math::toRadians<REAL>(angle)); r.transformRef(position); updateDOP(); viewUp = axis.cross(directionOfProjection); } }
/* TriangleMeshShape* MeshSweeper::makeCone(const Vec3& center, REAL radius, const Vec3& normal, REAL height, int segments) //[]----------------------------------------------------[] //| Make cylinder | //[]----------------------------------------------------[] { Polyline circle = makeCircle(center, radius, normal, segments); return makeCone(circle, normal * -height); } */ TriangleMeshShape* MeshSweeper::makeSphere(const Vec3& center, REAL radius, int mers) //[]----------------------------------------------------[] //| Make sphere | //[]----------------------------------------------------[] { if (mers < 6) mers = 6; int sections = mers; int nv = sections * mers + 2; // number of vertices (and normals) int nt = 2 * mers * sections; // number of triangles TriangleMesh::Arrays data; data.vertices = new Vec3[data.numberOfVertices = nv]; data.normals = new Vec3[data.numberOfNormals = nv]; data.triangles = new TriangleMesh::Triangle[data.numberOfTriangles = nt]; { Polyline arc = makeArc(center, radius, Vec3(0, 0, 1), 180, sections + 1); Polyline::VertexIterator vit = arc.getVertexIterator(); Transf3 rot; Vec3* vertex = data.vertices; Vec3* normal = data.normals; REAL invRadius = Math::inverse<REAL>(radius); *normal = ((*vertex = (vit++).position) - center) * invRadius; rot.rotation(center, *normal, Math::toRadians<REAL>(360) / mers); vertex++; normal++; for (int s = 0; s < sections; s++) { Vec3 p = *vertex = (vit++).position; *normal = (p - center) * invRadius; vertex++; normal++; for (int m = 1; m < mers; m++) { *vertex = rot.transformRef(p); *normal = (p - center) * invRadius; vertex++; normal++; } } *normal = ((*vertex = (vit++).position) - center) * invRadius; } TriangleMesh::Triangle* triangle = data.triangles; for (int i = 1; i <= mers; i++) { int j = i % mers + 1; triangle->setVertices(0, i, j); triangle->setNormals(0, i, j); triangle++; } for (int s = 1; s < sections; s++) for (int m = 0, b = (s - 1) * mers + 1; m < mers;) { int i = b + m; int k = b + ++m % mers; int j = i + mers; int l = k + mers; triangle->setVertices(i, j, k); triangle->setNormals(i, j, k); triangle[1].setVertices(k, j, l); triangle[1].setNormals(k, j, l); triangle += 2; } for (int m = 0, b = (sections - 1) * mers + 1, j = nv - 1; m < mers;) { int i = b + m; int k = b + ++m % mers; triangle->setVertices(i, j, k); triangle->setNormals(i, j, k); triangle++; } return new TriangleMeshShape(data); }