PDA

View Full Version : Maya 6.0 - Set Matrix of current Viewport-Camera


lama12345
12-04-2011, 09:52 AM
Hey there,

does anybody know how to set a matrix for the current viewport? I've just found out how to read it.


MDagPath camera;
MStatus status = M3dView::active3dView().getCamera(camera);
if (status == MS::kSuccess)
{
MFnCamera camera2(camera);
printf("focus=%.2f ", camera2.focalLength());
//camera2.setFocalLength(66.66);
double x,y,z,w;
//transform.getRotationQuaternion(x, y, z, w);

MMatrix worldPos = camera.inclusiveMatrix();
x = worldPos(3, 0);
y = worldPos(3, 1);
z = worldPos(3, 2);
w = worldPos(3, 3);
printf("x=%.0f y=%.0f z=%.0f w=%.0f ", x, y, z, x);
}


Now i want to add some Values to x,y,z and recreate the MMatrix back, but i have no clue how it should work.

Regards,
lama12345

zoharl
12-05-2011, 08:58 AM
First I would recommend you to update your maya version to 7.0, I remember from 5 years ago that it's much better than 6.0 ;).

Second I think you should distinguish between the projection matrix and the inclusive matrix. The projection matrix is made from parameters such as focal length, and you'll need specifically to change these parameters to change this matrix (I don't think that maya can do the other way around). The inclusive matrix is the transform matrix (translation, rotation...) like in any other object, and you can change it using MFnTransform.

CGTalk Moderation
12-05-2011, 08:58 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.