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";
	
}
示例#2
0
void userDAGGenericCB(MDagMessage::DagMessage msg, MDagPath &child,
					  MDagPath &parent, void *)
{	
	MString dagStr("DAG Changed - ");
	switch (msg) {
		case MDagMessage::kParentAdded:
			dagStr += "Parent Added: ";
			break;
		case MDagMessage::kParentRemoved:
			dagStr += "Parent Removed: ";
			break;
		case MDagMessage::kChildAdded:
			dagStr += "Child Added: ";
			break;
		case MDagMessage::kChildRemoved:
			dagStr += "Child Removed: ";
			break;
		case MDagMessage::kChildReordered:
			dagStr += "Child Reordered: ";
			break;
		default:
			dagStr += "Unknown Type: ";
			break;
	}

	dagStr += "child = ";
	dagStr += child.fullPathName();
	dagStr += ", parent = ";
	dagStr += parent.fullPathName();

	// Check to see if the parent is the world object.
	//
	MStatus pStat;
	parent.transform(&pStat);
	if (MS::kInvalidParameter == pStat) {
		dagStr += "(WORLD)";
	}

	// Install callbacks if node is not in the model.
	// Callback is for node added to model.
	bool incomplete = false;
	if ( dagNotInModel( child ) ) {
		installNodeAddedCallback( child );
		incomplete = true;
	}
	if ( dagNotInModel( parent ) ) {
		installNodeAddedCallback( parent);
		incomplete = true;
	}

	// Warn user that dag path info may be
	// incomplete
	if (incomplete)
		dagStr += "\t// May be incomplete!";	

	MGlobal::displayInfo(dagStr);
}
示例#3
0
MStatus setupRGBShaders::doIt( const MArgList & args )
{
    unsigned int FIndex = args.flagIndex( "fp", "folderPath" );
    unsigned int fIndex = args.flagIndex( "fn", "fileName" );

    if( FIndex == MArgList::kInvalidArgIndex || fIndex == MArgList::kInvalidArgIndex ) {
        MGlobal::displayError( "Error specifying flag or flag values. \n-fp, -folderPath <folder_path> \t -fn, -fileName <file_name>" );
        return MS::kFailure;
    }

    folderPath = args.asString( FIndex );
    fileName = args.asString( fIndex );

    MItDag meshIt( MItDag::kDepthFirst, MFn::kMesh );

    for( ; !meshIt.isDone(); meshIt.next() ) {
        MDagPath dagPath;

        meshIt.getPath( dagPath );
        meshObjs.append( dagPath.transform() );
    }

    MItDag camIt( MItDag::kDepthFirst, MFn::kCamera );

    for( ; !camIt.isDone(); camIt.next() ) {
        MDagPath dagPath;

        camIt.getPath( dagPath );
        MFnDependencyNode camFn( dagPath.node() );

        bool isRenderable;
        camFn.findPlug( "renderable" ).getValue( isRenderable );

        if( isRenderable )
            camObjs.append( dagPath.transform() );
    }

    MGlobal::executeCommand( "setAttr miDefaultFramebuffer.datatype 5" );

    return redoIt();
}
示例#4
0
size_t
UsdMayaGLBatchRenderer::_ShapeHash(
    const UsdPrim& usdPrim, 
    const SdfPathVector& excludePrimPaths,
    const MDagPath& objPath )
{
    size_t hash( MObjectHandle(objPath.transform()).hashCode() );
    boost::hash_combine( hash, usdPrim );
    boost::hash_combine( hash, excludePrimPaths );

    return hash;
}
		MStatus CreateCurves::Curve::create(CreateCurves & instance) {
			MStatus status;

			MFnNurbsCurve curve;

			MObject curveObject = curve.create(points, knots, instance.m_degree, isLoop ? MFnNurbsCurve::kClosed : MFnNurbsCurve::kOpen, false, false, MObject::kNullObj, &status);

			if (!status) {
				status.perror("MFnNurbsCurve::create");
				return status;
			}

			MDagPath path;
			if (!(status = curve.getPath(path))) {
				status.perror("MFnNurbsCurve::getPath");
				return status;
			}

			instance.m_curves.append(path.transform());

			return MStatus::kSuccess;
		}
示例#6
0
// Node added to model callback.
static void userNodeAddedCB(MObject& node,void *clientData)
{
	MStatus status;

	if (! node.isNull()) {
		bool doDisplay = true;

		MDagPath path;
		status = MDagPath::getAPathTo(node,path);
		if ( status.error() ) {
			doDisplay = false;
			MGlobal::displayInfo("Error: failed to get dag path to node.");
		}

		if ( doDisplay ) {
			MString s = path.fullPathName();
			MString info("DAG Model -  Node added: ");
			info+= s;

			path.transform(&status);
			if (MS::kInvalidParameter == status) {
				info += "(WORLD)";
			}

			MGlobal::displayInfo(info);	
		}
	}

	// remove the callback
	MCallbackId id = MMessage::currentCallbackId();
	MMessage::removeCallback(id);

	// listen for removal message
	/* MCallbackId id = */ MModelMessage::addNodeRemovedFromModelCallback( node, userNodeRemovedCB, 0, &status );
	if ( status.error() ) {
		MGlobal::displayError("Failed to install node removed from model callback.\n");
		return;
	}
}
示例#7
0
// Set keyframes to move selected object in a spiral
MStatus spiralAnimCurve::doIt( const MArgList& )
{   
	// Get the Active Selection List
	//
	MStatus status;
	MSelectionList	sList;
	MGlobal::getActiveSelectionList( sList );

	// Create an iterator for the selection list
	//
	MItSelectionList iter( sList, MFn::kDagNode, &status );
	if ( MS::kSuccess != status ) {
		cerr << "Failure in plugin setup";
		return MS::kFailure;
	}
	
	MDagPath mObject;	
	MObject mComponent;

	for ( ; !iter.isDone(); iter.next() ) {
		status = iter.getDagPath( mObject, mComponent );

		// Check if there was an error
		//
		if ( MS::kSuccess != status ) continue;

		// We don't handle components
		//
		if ( !mComponent.isNull() ) continue;
		
		// Create the function set
		//
		MFnDagNode fnSet( mObject, &status );

		if ( MS::kSuccess != status ) {
			cerr << "Failure to create function set\n";
			continue;
		}

		// Get the plug for the X-translation channel
		//
		MString attrName( "translateX" );
		const MObject attrX = fnSet.attribute( attrName, &status );
		if ( MS::kSuccess != status ) {
			cerr << "Failure to find attribute\n";
		}
		MFnAnimCurve acFnSetX;
		acFnSetX.create( mObject.transform(), attrX, NULL, &status ); 

		if ( MS::kSuccess != status ) {
			cerr << "Failure creating MFnAnimCurve function set (translateX)\n";
			continue;
		}

		// Repeat for Y-translation
		//
		attrName.set( "translateZ" );
		const MObject attrZ = fnSet.attribute( attrName, &status );
		if ( MS::kSuccess != status ) {
			cerr << "Failure to find attribute\n";
		}
		MFnAnimCurve acFnSetZ;
		acFnSetZ.create( mObject.transform(), attrZ, NULL, &status ); 

		if ( MS::kSuccess != status ) {
			cerr << "Failure creating MFnAnimCurve function set (translateZ)\n";
			continue;
		}
		
		// Build spiral animation
		// 
		for( int i = 1; i <= NUM_FRAMES; i++ ) {
			// Build the keyframe at frame i
			//
			double x = sin( (double)i * RADIAL_VELOCITY ) * 
				            ( (double)i * OUTWARD_VELOCITY ); 
			double z = cos( (double)i * RADIAL_VELOCITY ) * 
				            ( (double)i * OUTWARD_VELOCITY );

			// cerr << "Setting keys - frame: " << i << "  x: " << x << "  z: " << z << endl;

			MTime tm( (double)i, MTime::kFilm );
			if ( ( MS::kSuccess != acFnSetX.addKeyframe( tm, x ) ) ||
				 ( MS::kSuccess != acFnSetZ.addKeyframe( tm, z ) ) ) {
				cerr << "Error setting the keyframe\n"; 
			}
		}

	}

	return status;
}
    // ------------------------------------------------------------
    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;
    }
MStatus getLight::readLight(yafaray::yafrayInterface_t &yI)
{
	MStatus stat;

	bool hasYafLight=0;

	MString listPoint("ls -type yafPointLight");
	MStringArray pointResult;
	MGlobal::executeCommand(listPoint, pointResult);
	
	if(pointResult.length()>0)
	{
		    hasYafLight=1;
			for(unsigned int i=0;i<pointResult.length();i++)
			{
				//test output
				cout<<pointResult[i].asChar()<<endl;

				MSelectionList list;
				MGlobal::getSelectionListByName(pointResult[i],list);
				for(unsigned int index=0;index<list.length();index++)
				{
					MDagPath pointPath;
					list.getDagPath(index,pointPath);

					MObject pointTransNode=pointPath.transform();
					MFnTransform pointTrans(pointTransNode);
					MGlobal::displayInfo(pointTrans.name());
					MVector transP=pointTrans.getTranslation(MSpace::kTransform);

					//test output
					//this is the position of the point light
					cout<<"============test light==========="<<endl;
					cout<<transP.x<<transP.y<<transP.z<<endl;

					MObject pointDepNode;
					list.getDependNode(index,pointDepNode);
					MFnDependencyNode pointDepFn(pointDepNode);

					yI.paramsClearAll();
					yI.paramsSetString("type","pointlight");

					yI.paramsSetPoint("from",transP.x,transP.y,transP.z);

					MObject pointColor;
					pointDepFn.findPlug("LightColor").getValue(pointColor);
					MFnNumericData pointData(pointColor);
					float pcR,pcG,pcB;
					pointData.getData(pcR,pcG,pcB);
					yI.paramsSetColor("color",pcR,pcG,pcB);

					float pointPower;
					pointDepFn.findPlug("Power").getValue(pointPower);
					yI.paramsSetFloat("power",pointPower);

					cout<<"================point light=============="<<endl;
					cout<<pointDepFn.name().asChar()<<endl;
					yI.createLight(pointDepFn.name().asChar());

				}

			}
	}

	//sphere light
	MString listSphere("ls -type yafSphereLight");
	MStringArray sphereResult;
	MGlobal::executeCommand(listSphere, sphereResult);

	if(sphereResult.length()>0)
	{
		hasYafLight=1;
		for(unsigned int i=0;i<sphereResult.length();i++)
		{
			//test output
			cout<<sphereResult[i].asChar()<<endl;

			MSelectionList list;
			MGlobal::getSelectionListByName(sphereResult[i],list);
			for(unsigned int index=0;index<list.length();index++)
			{
				MDagPath spherePath;
				list.getDagPath(index,spherePath);

				MObject sphereTransNode=spherePath.transform();
				MFnTransform sphereTrans(sphereTransNode);
				MVector transP=sphereTrans.getTranslation(MSpace::kTransform);

				MFnDagNode sphereFn(spherePath);
				MObject sphereColor;
				sphereFn.findPlug("LightColor").getValue(sphereColor);
				MFnNumericData sphereData(sphereColor);
				float sphereR,sphereG,sphereB;
				sphereData.getData(sphereR,sphereG,sphereB);

				float power;
				sphereFn.findPlug("Power").getValue(power);

				int samples;
				sphereFn.findPlug("Samples").getValue(samples);

				float radius;
				sphereFn.findPlug("Radius").getValue(radius);
				

				//check if draw geometry needed
				bool makeGeo;
				sphereFn.findPlug("MakeGeometry").getValue(makeGeo);
				if (makeGeo)
				{
					int u=24;
					int v=48;

					yI.paramsClearAll();
					yI.paramsSetString("type","light_mat");
					yI.paramsSetFloat("power",power);
					yI.paramsSetColor("color",sphereR,sphereG,sphereB);
					yafaray::material_t *lightMat=yI.createMaterial(sphereFn.name().asChar());

					int sphereID=makeSphere(yI,u,v,transP.x,transP.y,transP.z,radius,lightMat);
					yI.paramsSetInt("object",sphereID);
				}

				yI.paramsClearAll();
				yI.paramsSetString("type","spherelight");
				yI.paramsSetPoint("from",transP.x, transP.y,transP.z);
				yI.paramsSetColor("color",sphereR,sphereG,sphereB);
				yI.paramsSetFloat("power",power);
				yI.paramsSetInt("samples",samples);
				yI.paramsSetFloat("radius",radius);


				cout<<"================sphere light=============="<<endl;
				cout<<sphereFn.name().asChar()<<endl;
				yI.createLight(sphereFn.name().asChar());

			}

		}
	}
	MString listSun("ls -type yafSunLight");
	MStringArray sunResult;
	MGlobal::executeCommand(listSun,sunResult);
	if (sunResult.length()>0)
	{
		hasYafLight=1;
		for (unsigned int i=0;i<sunResult.length();i++)
		{
			//test output
			cout<<sunResult[i].asChar()<<endl;

			MSelectionList list;
			MGlobal::getSelectionListByName(sunResult[i],list);
			for(unsigned int index=0;index<list.length();index++)
			{
				MDagPath sunPath;
				list.getDagPath(index,sunPath);

				MObject sunTransNode=sunPath.transform();
				MFnTransform sunTrans(sunTransNode);
				MTransformationMatrix sunMatrix=sunTrans.transformation();
				MMatrix sMatrix=sunMatrix.asMatrix();
				MVector transP=sunTrans.getTranslation(MSpace::kTransform);

				MPoint direction1(0.0,0.0,0.0);
				MPoint direction2(0.0,0.0,1.0);
				MPoint direction=direction1-direction2;
				direction*=sMatrix;

				yI.paramsClearAll();
				yI.paramsSetString("type","sunlight");
				MFnDagNode sunFn(sunPath);

				yI.paramsSetPoint("from",transP.x, transP.y,transP.z);
				yI.paramsSetPoint("direction",direction.x,direction.y,direction.z);

				MObject sunColor;
				sunFn.findPlug("LightColor").getValue(sunColor);
				MFnNumericData sunData(sunColor);
				float sunR,sunG,sunB;
				sunData.getData(sunR,sunG,sunB);
				yI.paramsSetColor("color",sunR,sunG,sunB);

				float power;
				sunFn.findPlug("Power").getValue(power);
				yI.paramsSetFloat("power",power);

				int samples;
				sunFn.findPlug("Samples").getValue(samples);
				yI.paramsSetInt("samples",samples);

				float angle;
				sunFn.findPlug("Angle").getValue(angle);
				yI.paramsSetFloat("angle",angle);

				cout<<"================sun light=============="<<endl;
				cout<<sunFn.name().asChar()<<endl;
				yI.createLight(sunFn.name().asChar());

			}
		}
	}

	//spot light
	MString listSpot("ls -type yafSpotLight");
	MStringArray spotResult;
	MGlobal::executeCommand(listSpot, spotResult);

	if(spotResult.length()>0)
	{
		hasYafLight=1;
		for(unsigned int i=0;i<spotResult.length();i++)
		{
			//test output
			cout<<spotResult[i].asChar()<<endl;

			MSelectionList list;
			MGlobal::getSelectionListByName(spotResult[i],list);
			for(unsigned int index=0;index<list.length();index++)
			{
				MDagPath spotPath;
				list.getDagPath(index,spotPath);

				MObject spotTransNode=spotPath.transform();
				MFnTransform spotTrans(spotTransNode);
				MTransformationMatrix spotMatrix=spotTrans.transformation();
				MMatrix sMatrix=spotMatrix.asMatrix();
				MVector transP=spotTrans.getTranslation(MSpace::kTransform);

				MPoint direction1(0.0,0.0,0.0);
				MPoint direction2(0.0,-1.0,0.0);
				MPoint direction=direction2-direction1;
				direction*=sMatrix;

				yI.paramsClearAll();
				yI.paramsSetString("type","spotlight");
				MFnDagNode spotFn(spotPath);

				yI.paramsSetPoint("from",transP.x, transP.y,transP.z);
				yI.paramsSetPoint("to",direction.x,direction.y,direction.z);

				MObject spotColor;
				spotFn.findPlug("LightColor").getValue(spotColor);
				MFnNumericData spotData(spotColor);
				float spotR,spotG,spotB;
				spotData.getData(spotR,spotG,spotB);
				yI.paramsSetColor("color",spotR,spotG,spotB);

				float power;
				spotFn.findPlug("Power").getValue(power);
				yI.paramsSetFloat("power",power);

				float coneAngle;
				spotFn.findPlug("ConeAngle").getValue(coneAngle);
				yI.paramsSetFloat("cone_angle",coneAngle);

				float blend;
				spotFn.findPlug("PenumbraDistance").getValue(blend);
				yI.paramsSetFloat("blend",blend);

				bool softShadows;
				spotFn.findPlug("SoftShadows").getValue(softShadows);
				yI.paramsSetBool("soft_shadows",softShadows);

				float fuzzyness;
				spotFn.findPlug("ShadowFuzzyness").getValue(fuzzyness);
				yI.paramsSetFloat("shadowFuzzyness",fuzzyness);

				bool photonOnly;
				spotFn.findPlug("PhotonOnly").getValue(photonOnly);
				yI.paramsSetBool("photon_only",photonOnly);

				int samples;
				spotFn.findPlug("Samples").getValue(samples);
				yI.paramsSetInt("samples",samples);

				cout<<"================spot light=============="<<endl;
				cout<<spotFn.name().asChar()<<endl;
				yI.createLight(spotFn.name().asChar());

			}

		}
	}
	//directional lights
	MString listDirectional("ls -type yafDirectionalLight");
	MStringArray dirResult;
	MGlobal::executeCommand(listDirectional,dirResult);
	if(dirResult.length()>0)
	{
		    hasYafLight=1;

			for (unsigned int i=0; i<dirResult.length(); i++)
			{
				MSelectionList list;
				MGlobal::getSelectionListByName(dirResult[i],list);
				for(unsigned int index=0;index<list.length();index++)
				{
					MDagPath dirShapePath;
					list.getDagPath(index,dirShapePath);
					MFnTransform dirTransform(dirShapePath.transform());
					MTransformationMatrix dirTransMatrix=dirTransform.transformation();
					MMatrix dirMatrix=dirTransMatrix.asMatrix();

					MPoint direction1(0,0,0);
					MPoint direction2(0,0,-1);
					MPoint direction=direction1-direction2;
					direction*=dirMatrix;

					yI.paramsClearAll();
					yI.paramsSetString("type","directional");

					yI.paramsSetPoint("direction",direction.x, direction.y, direction.z);

					MFnDagNode dirShapeFn(dirShapePath);
					MObject dirColor;
					dirShapeFn.findPlug("LightColor").getValue(dirColor);
					MFnNumericData dirData(dirColor);
					float dirR,dirG,dirB;
					dirData.getData(dirR,dirG,dirB);
					yI.paramsSetColor("color",dirR,dirG,dirB);

					float power;
					dirShapeFn.findPlug("Power").getValue(power);
					yI.paramsSetFloat("power",power);

					bool infinite;
					dirShapeFn.findPlug("Infinite").getValue(infinite);
					yI.paramsSetBool("infinite",infinite);

					float radius;
					dirShapeFn.findPlug("Radius").getValue(radius);
					yI.paramsSetFloat("radius",radius);

					MVector dirP=dirTransform.getTranslation(MSpace::kTransform);
					yI.paramsSetPoint("from",dirP.x,dirP.y,dirP.z);

					cout<<"================directional light=============="<<endl;
					cout<<dirShapeFn.name().asChar()<<endl;
					yI.createLight(dirShapeFn.name().asChar());
					
				}
			}
	}

	//area lights
	MString listArea("ls -type yafAreaLight");
	MStringArray areaResult;
	MGlobal::executeCommand(listArea, areaResult);
	if(areaResult.length()>0)
	{
		    hasYafLight=1;

			for(unsigned int i=0;i<areaResult.length();i++)
			{
				MSelectionList list;
				MGlobal::getSelectionListByName(areaResult[i],list);
				for(unsigned int index=0;index<list.length();index++)
				{
					MDagPath areaShapePath;
					list.getDagPath(index,areaShapePath);
					//areaTransform is the transform node of this light, all the location information is here
					MFnTransform areaTransform(areaShapePath.transform());
					MTransformationMatrix areaTransMatrix=areaTransform.transformation();
					MMatrix areaMatrix=areaTransMatrix.asMatrix();
					//this is the shape node of the light, all the attribute is here

					MPoint corner(-1.0,-1.0,0);
					MPoint point1(-1.0,1.0,0);
					MPoint point2(1.0,1.0,0);
					MPoint point3(1.0,-1.0,0);
					corner*=areaMatrix;
					point1*=areaMatrix;
					point2*=areaMatrix;
					point3*=areaMatrix;

					MVector areaP=areaTransform.getTranslation(MSpace::kTransform);

					MFnDagNode areaShapeFn(areaShapePath);
					int samples;
					areaShapeFn.findPlug("Samples").getValue(samples);

					MObject areaColor;
					areaShapeFn.findPlug("LightColor").getValue(areaColor);
					MFnNumericData areaData(areaColor);
					float areaR,areaG,areaB;
					areaData.getData(areaR,areaG,areaB);

					float power;
					areaShapeFn.findPlug("Power").getValue(power);

					bool makeGeo;
					areaShapeFn.findPlug("MakeGeometry").getValue(makeGeo);
					if (makeGeo==1)
					{
						//create light
						yI.paramsClearAll();
						yI.paramsSetString("type","light_mat");
						yI.paramsSetFloat("power",power);
						yI.paramsSetColor("color",areaR,areaG,areaB);
						yafaray::material_t * lightMat=yI.createMaterial(areaShapeFn.name().asChar());
						//create geometry
						yI.paramsClearAll();
						int areaID=yI.getNextFreeID();
						yI.startGeometry();
						yI.startTriMesh(areaID,4,2,false,false);
						yI.addVertex(corner.x,corner.y,corner.z);
						yI.addVertex(point1.x,point1.y,point1.z);
						yI.addVertex(point2.x,point2.y,point2.z);
						yI.addVertex(point3.x,point3.y,point3.z);
						yI.addTriangle(0,1,2,lightMat);
						yI.addTriangle(0,2,3,lightMat);
						yI.endTriMesh();
						yI.endGeometry();
						yI.paramsSetInt("object",areaID);

					}

					yI.paramsClearAll();
					yI.paramsSetString("type","arealight");

					cout<<"===============area light=============="<<endl;
					yI.paramsSetInt("samples",samples);

					yI.paramsSetPoint("corner",corner.x, corner.y, corner.z);
					yI.paramsSetPoint("point1",point1.x, point1.y, point1.z);
					yI.paramsSetPoint("point2",point3.x, point3.y, point3.z);

					yI.paramsSetPoint("from",areaP.x, areaP.y, areaP.z);

					yI.paramsSetColor("color",areaR,areaG,areaB);
					yI.paramsSetFloat("power",power);

					cout<<areaShapeFn.name().asChar()<<endl;
					yI.createLight(areaShapeFn.name().asChar());

				}
			}
	}
	//if there is no light in the scene, create a default one
	//but this one will not be available if users create new ones
	if (hasYafLight==false)
	{
		yI.paramsClearAll();
		yI.paramsSetString("type","directional");
		//use camera direction and position so that default light always can be seen no matter where user watch from 
		//M3dView currentView=M3dView::active3dView();
		//MDagPath cameraPath;
		//MFnCamera currentCam(cameraPath);
		//MVector lightPosition=currentCam.eyePoint(MSpace::kWorld);
		//MVector lightDirection=currentCam.viewDirection(MSpace::kWorld);

		//currentView.getCamera(cameraPath);
		yI.paramsSetPoint("direction",0.0,0.0,1.0);
		yI.paramsSetPoint("from",0.0,0.0,0.0);
		yI.paramsSetColor("color",0.8f,0.8f,0.8f);
		yI.paramsSetFloat("power",1.0f);
		yI.paramsSetBool("infinite",true);
		yI.paramsSetFloat("radius",1.0f);
		yI.createLight("yafDefaultLight1");

		yI.paramsClearAll();
		yI.paramsSetString("type","directional");
		yI.paramsSetPoint("direction",1.0,0.0,-1.0);
		yI.paramsSetPoint("from",0.0,0.0,0.0);
		yI.paramsSetColor("color",0.8f,0.8f,0.8f);
		yI.paramsSetFloat("power",1.0f);
		yI.paramsSetBool("infinite",true);
		yI.paramsSetFloat("radius",1.0f);
		yI.createLight("yafDefaultLight2");

		MGlobal::displayWarning("(yafaray) you haven't created your own light yet!");
	}

	return stat;
}