void RadiosityRenderer::printTransformData(const MDagPath& dagPath)
{
    printf("got");
	
	
	//This method simply determines the transformation information on the DAG node and prints it out.
    MStatus status;
    MObject transformNode = dagPath.transform(&status);
    // This node has no transform - i.e., it’s the world node
    if (!status && status.statusCode () == MStatus::kInvalidParameter)
        return;
    MFnDagNode transform (transformNode, &status);
    if (!status) {
        status.perror("MFnDagNode constructor");
        return;
    }
    MTransformationMatrix matrix (transform.transformationMatrix());
	//cout << " translation: " << matrix.translation(MSpace::kWorld)
	//<< endl;
    double threeDoubles[3];
    MTransformationMatrix::RotationOrder rOrder;
    matrix.getRotation (threeDoubles, rOrder, MSpace::kWorld);
	
	cout << " rotation: ["
	<< threeDoubles[0] << ", "
	<< threeDoubles[1] << ", "
	<< threeDoubles[2] << "]\n";
    matrix.getScale (threeDoubles, MSpace::kWorld);
	
	cout << " scale: ["
	<< threeDoubles[0] << ", "
	<< threeDoubles[1] << ", "
	<< threeDoubles[2] << "]\n";
	
}
Example #2
0
	MStatus Mesh::TranslationMatrix(ostream& fout) const {
		MStatus status;
	
		MObject	transformNode = dagPath.transform(&status);
		if (!status && status.statusCode () == MStatus::kInvalidParameter) return MStatus::kFailure;
		
		MFnDagNode transform(transformNode, &status);
		if (!status) return MStatus::kFailure;
		
		MTransformationMatrix matrix (transform.transformationMatrix());
		
		MVector translation = matrix.translation(MSpace::kWorld);
		fout << "Translate " <<  translation.x << " " << translation.y << " " << translation.z << endl;
		
		MEulerRotation rotation = matrix.eulerRotation().reorder(MEulerRotation::kXYZ);
		fout << "Rotation " << rotation.x << " 1 0 0" << endl;
		fout << "Rotation " << rotation.y << " 0 1 0" << endl;
		fout << "Rotation " << rotation.z << " 0 0 1" << endl;
		
		double scale[3];
		matrix.getScale(scale, MSpace::kWorld);
		fout << "Scale " << scale[0] << " " << scale[1] << " " << scale[2] << endl;
		
		return MStatus::kSuccess;
	}
Example #3
0
void exportTerrain::printTransformData(const MFnLight& theLight)
{
    MStatus		status;
    unsigned		numParents = theLight.parentCount(&status);
    MObject		transformNode;
    //will only use the first parent
    
    if(numParents != 0){
	transformNode = theLight.parent(0,&status);
	// This node has no transform - i.e., it's the world node
    }
    else
	return;
    
    if (!status && status.statusCode () == MStatus::kInvalidParameter)
	return;
    MFnTransform   transform(transformNode, &status);
    if (!status) {
	status.perror("MFnTransform constructor");
	return;
    }
    fout << "Name: " << transform.name(&status) << endl;
    fout << "Transform: " << transform.translation( MSpace::kTransform,&status) << endl;

    MQuaternion rot;
    status = transform.getRotation(rot);
    double rotD[4];
    rot.get(rotD);
    MColor tempRot(rotD[0],rotD[1],rotD[2],rotD[3]);
 //   fout << "Rotation: " << tempRot << endl;


    printLightData(theLight);
}
    // ------------------------------------------------------------
    bool SceneGraph::create ( bool selectionOnly )
    {
        // The flag, if just the selected elements should be exported.
        mExportSelectedOnly = selectionOnly;

        // Add all the animation expressions
        MItDependencyNodes depIter ( MFn::kExpression );
        for ( ; !depIter.isDone(); depIter.next() )
        {
            MObject item = depIter.item();
            if ( item.hasFn ( MFn::kExpression ) )
            {
                mAnimationExpressions.append ( item );
            }
        }

        // Push all nodes from root down to all meshes which have to be exported in a list.
        findForcedNodes ();

        // Fills the list with all root targets to export.
        bool success = retrieveExportNodes ();
        
        // Create a selection list containing only the root nodes (implies export all!)
        uint length = mTargets.length();
        for ( uint i=0; i<mTargets.length(); ++i )
        {
            MDagPath dagPath;
            MStatus status = mTargets.getDagPath ( i, dagPath );
            if ( status != MStatus::kSuccess ) return false;

            // This node has no transform - i.e., it's the world node
            MObject transformNode = dagPath.transform ( &status );
            if ( !status && status.statusCode () == MStatus::kInvalidParameter ) continue;

            // Check if it is a valid transform node
            MFnDagNode transform ( transformNode, &status );
            if ( !status )
            {
                status.perror ( "MFnDagNode constructor" );
                return false;
            }

            // Create a new scene element
            SceneElement* sceneElement = createSceneElement ( dagPath );

            // Push the root nodes into the tree.
            // If the root node is instanced, push it at the beginning (no instance on root!).
            if ( dagPath.isInstanced () )
                mExportNodesTree.insert ( mExportNodesTree.begin (), sceneElement );
            else
                mExportNodesTree.push_back ( sceneElement );
            
            // Create the child elements
            //if ( sceneElement->getIsExportNode() )
            {
                createChildSceneElements ( sceneElement );
            }
        }

        return true;
    }