smaragden
09-27-2002, 09:26 AM
I have a problem with the transformation of an normal from worldspace
to cameraspace in the Maya4.0 API.
I'm successfylly transform the point with no problem, just: (point in
worldspace) * (cameras inversetransformationmatrix).
I thougt that (normal in worldspace).transformAsNormal(cameras
inversetransformationmatrix) would do the same but but the right way
for normals.
But i cant't get it to work. Here's the snippet of code relevant to
the problem.
//CODE////////////////////////////////////////////////////////
MDagpath objDPath = nurbsobjects dagpath
MDagPath camDPath = cameras dagpath
MVector SNormal;
MPoint SPoint;
MFnCamera Camera;
MFnNurbsSurface Sphere;
currentNurbsObject.setObject( objDPath );
SNormal = currentNurbsObject.normal(u,v,MSpace::kWorld ,&status);
currentNurbsObject.getPointAtParam(u,v,SPoint,MSpace::kWorld);
worldToCam = CamDpath.inclusiveMatrixInverse();
SPoint = SPoint * worldToCam;
SNormal = SNormal.transformAsNormal(worldToCam);
SNormal.normalize() ;
//CODE////////////////////////////////////////////////////////
SPoint is in Camera Space after this, but SNormal is not.
What am i missing about transformation of normals?
Regards
Fredrik Brännbacka
to cameraspace in the Maya4.0 API.
I'm successfylly transform the point with no problem, just: (point in
worldspace) * (cameras inversetransformationmatrix).
I thougt that (normal in worldspace).transformAsNormal(cameras
inversetransformationmatrix) would do the same but but the right way
for normals.
But i cant't get it to work. Here's the snippet of code relevant to
the problem.
//CODE////////////////////////////////////////////////////////
MDagpath objDPath = nurbsobjects dagpath
MDagPath camDPath = cameras dagpath
MVector SNormal;
MPoint SPoint;
MFnCamera Camera;
MFnNurbsSurface Sphere;
currentNurbsObject.setObject( objDPath );
SNormal = currentNurbsObject.normal(u,v,MSpace::kWorld ,&status);
currentNurbsObject.getPointAtParam(u,v,SPoint,MSpace::kWorld);
worldToCam = CamDpath.inclusiveMatrixInverse();
SPoint = SPoint * worldToCam;
SNormal = SNormal.transformAsNormal(worldToCam);
SNormal.normalize() ;
//CODE////////////////////////////////////////////////////////
SPoint is in Camera Space after this, but SNormal is not.
What am i missing about transformation of normals?
Regards
Fredrik Brännbacka
