A camera has the following properties:
- fovAngle: The field of view angle.
- nearPlane: The near clipping plane.
- farPlane: The far clipping plane.
- projection: The projection type, 0 for orthogonal, 1 for perspective.
- stereoMode: The stereo mode, 0 for no stereo, 1 for toe-in, 2 for off-axis.
- eyeSeparation: The eye separation.
- eyeX, eyeY, eyeZ: The position of the eye.
- focusX, focusY, focusZ: The position of the focus.
- upX, upY, upZ: The up vector.
First we get the currently selected human (yes, we do anticipate having more than one human in the scene).
Next we get the vertices which belong to the head by facegroup names.
We calculate the center of these vertices as this will become our focus point at which we will look at.
Now we are ready to set the eye and focus positions. We set the focus to the center position, and the eye a bit to the back.
Finally we reset the human's position and rotation so that our calculations are as simple as the ones above.
If we would allow the human to be translated and rotated, we would need to take this transformation into account, as above we calculated the center of the untransformed mesh.
human = self.scene3d.selectedHuman
Next we get the vertices which belong to the head by facegroup names.
headNames = [group.name for group in human.meshData.facesGroups if ("head" in group.name or "jaw" in group.name)]
self.headVertices, self.headFaces = human.meshData.getVerticesAndFacesForGroups(headNames)
We calculate the center of these vertices as this will become our focus point at which we will look at.
center = centroid([v.co for v in self.headVertices])
Now we are ready to set the eye and focus positions. We set the focus to the center position, and the eye a bit to the back.
self.modelCamera.eyeX = center[0]
self.modelCamera.eyeY = center[1]
self.modelCamera.eyeZ = 10
self.modelCamera.focusX = center[0]
self.modelCamera.focusY = center[1]
self.modelCamera.focusZ = 0
Finally we reset the human's position and rotation so that our calculations are as simple as the ones above.
human.setPosition([0.0, 0.0, 0.0])
human.setRotation([0.0, 0.0, 0.0])
If we would allow the human to be translated and rotated, we would need to take this transformation into account, as above we calculated the center of the untransformed mesh.
This comment has been removed by a blog administrator.
ReplyDeleteJust downloaded and tested MH from trunk. It is AWESOME!!!! Absolutely awesome!
ReplyDeleteKeep up the good work guys and gals!