Main Page | Namespace List | Class List | Directories | File List | Namespace Members | Class Members | File Members

imaya_helper.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 #ifndef _IMAYA_HELPER_H_
00017 #define _IMAYA_HELPER_H_
00018 
00019 // includes, maya
00020 #include <maya/MPoint.h>
00021 #include <maya/MDagPath.h>
00022 #include <maya/MGlobal.h>
00023 #include <maya/MItSelectionList.h>
00024 
00025 // types, exported (class, enum, struct, union, typedef)
00026 
00028 namespace Util {
00029 
00030 
00033 //@brief For now we assume only one point light source position will be returned.
00035 inline void
00036 getPointLightPosition( MPoint &Translation ) {
00037   
00038   // Status and intermediate status
00039   MStatus status( MS::kFailure );
00040 
00041   // Create a selection list of all the objects in the scene.
00042   MSelectionList selectionList;
00043   MString allLights("*");
00044 
00045   // save the current selection mask
00046   MStatus stat;
00047   MSelectionMask select_mask_prev( MGlobal::objectSelectionMask( &stat));
00048   CONDITION( MS::kSuccess == stat);
00049 
00050 
00051   MSelectionMask select_mask( MSelectionMask::kSelectLights );
00052   MGlobal::setObjectSelectionMask( select_mask);
00053   MGlobal::getSelectionListByName( allLights, selectionList );
00054 
00055   // DAG path of point light source and it's transform,
00056   // and transform object.
00057   MDagPath pLTransformDagPath;
00058 
00059   // Iterate over the selection list but filter 
00060   // everything except for Point Light Sources.
00061   MItSelectionList iterator( selectionList );
00062   iterator.setFilter( MFn::kPointLight );
00063 
00064   for( iterator.reset(); !iterator.isDone(); iterator.next() ) {
00065 
00066     iterator.getDagPath( pLTransformDagPath );
00067 
00068     // Pop off the shape node from the path,
00069     // leaving the transform node.
00070     pLTransformDagPath.pop();
00071 
00072     MFnTransform theTransform( pLTransformDagPath );
00073     Translation = MPoint( MVector(theTransform.getTranslation( MSpace::kTransform , &status )) );
00074 
00075     // Note: at this point, we only keep the first
00076     // point light source iterated through.
00077     break;
00078   }
00079 
00080   // reset selection mask
00081   MGlobal::setObjectSelectionMask( select_mask_prev);
00082 
00083 }
00084 
00085 }
00086 
00087 // variables, exported (extern)
00088 
00089 // functions, inlined (inline)
00090   
00091 // functions, exported (extern)
00092   
00093 #endif // #ifndef _PROTO_H_
00094 

Generated on Sat Dec 31 18:07:49 2005 for ICaster by  doxygen 1.4.4