MStatus sgBDataCmd_key::writeData( bool exportByMatrix ) { MStatus status; double dTime = MAnimControl::currentTime().value(); if( exportByMatrix ) { for( unsigned int i=0; i<m_pathArrExport.length(); i++ ) { m_objectKeyDatasExport[i].lengthTime++; m_objectKeyDatasExport[i].dArrTime.append( dTime ); MFnDependencyNode fnNode( m_objectKeyDatasExport[i].oTargetNode ); if( m_objectKeyDatasExport[i].numAttr == 0 ) { continue; } if( m_objectKeyDatasExport[i].numAttr == 1 ) { MPlug plug = fnNode.findPlug( m_objectKeyDatasExport[i].namesAttribute[0] ); m_objectKeyDatasExport[i].dArrValuesArray.append( plug.asDouble() ); } else { if( m_objectKeyDatasExport[i].numAttr == 10 ) { MPlug plug = fnNode.findPlug( m_objectKeyDatasExport[i].namesAttribute[0] ); m_objectKeyDatasExport[i].dArrValuesArray.append( plug.asDouble() ); } MDagPath dagPath; dagPath.getAPathTo( m_objectKeyDatasExport[i].oTargetNode, dagPath ); MTransformationMatrix trMtx = dagPath.inclusiveMatrix() * dagPath.exclusiveMatrixInverse(); MVector trans = trMtx.translation( MSpace::kTransform ); double rotValues[3] ={0,0,0}; MTransformationMatrix::RotationOrder order = MTransformationMatrix::kZXY; trMtx.getRotation( rotValues, order, MSpace::kTransform ); double scales[3]; trMtx.getScale( scales, MSpace::kTransform ); m_objectKeyDatasExport[i].dArrValuesArray.append( trans.x ); m_objectKeyDatasExport[i].dArrValuesArray.append( trans.y ); m_objectKeyDatasExport[i].dArrValuesArray.append( trans.z ); m_objectKeyDatasExport[i].dArrValuesArray.append( rotValues[0] ); m_objectKeyDatasExport[i].dArrValuesArray.append( rotValues[1] ); m_objectKeyDatasExport[i].dArrValuesArray.append( rotValues[2] ); m_objectKeyDatasExport[i].dArrValuesArray.append( scales[0] ); m_objectKeyDatasExport[i].dArrValuesArray.append( scales[1] ); m_objectKeyDatasExport[i].dArrValuesArray.append( scales[2] ); } } } else { for( unsigned int i=0; i<m_pathArrExport.length(); i++ ) { m_objectKeyDatasExport[i].lengthTime++; m_objectKeyDatasExport[i].dArrTime.append( dTime ); MFnDependencyNode fnNode( m_objectKeyDatasExport[i].oTargetNode ); for( unsigned int j=0; j< m_objectKeyDatasExport[i].numAttr; j++ ) { MPlug plug = fnNode.findPlug( m_objectKeyDatasExport[i].namesAttribute[j] ); m_objectKeyDatasExport[i].dArrValuesArray.append( plug.asDouble() ); } } } return MS::kSuccess; }
void OutputTextures(MSelectionList selected){ MString temp; MString affich; int MatExists=0; for(int i=0;i<selected.length();i++){ MDagPath path; MObject obj; selected.getDagPath(i,path); obj=path.child(0); MFnMesh fn(path); obj=fn.parent(0); path.getAPathTo(fn.parent(0)); MFnMesh fna(path); unsigned int instancenumbers; MObjectArray shaders; MIntArray indices; fna.getConnectedShaders(instancenumbers,shaders,indices); switch(shaders.length()) { // if no shader applied to the mesh instance case 0: { //***************Affich("pas de matériaux"); } break; // if all faces use the same material // if more than one material is used, write out the face indices the materials // are applied to. default: { //************************Affich("trouvé plusieurs matériaux"); //write_int(shaders.length()); // now write each material and the face indices that use them for(int j=0;j < shaders.length();++j) { for(int matest=0;matest<Matid.length();matest++){ //**************************Affich(Matid[matest].asChar()); //*****************************Affich(GetShaderName( shaders[j] ).asChar()); if(Matid[matest]== GetShaderName( shaders[j] )){ MatExists = 1; }//fin if matid }// fin for matest if(MatExists != 1){ //*****************************Affich("matériau absent de la liste, enregistrement"); Matid.append(GetShaderName( shaders[j] ).asChar()); nb_Tex_by_Brush.append(0); writeTexture(shaders[j],"color"); //Affich(temp); }else { //************************************* Affich("matériau existe dans la liste"); }// fin if matexists MatExists = 0; }//fin for j shaders }// fin case default break; }//fin switches }//fin for selected Matid.clear(); }// fin output textures
MStatus MayaRenderView::redoIt() { MStatus retStatus; //get the camera MDagPath camera; if(_camera != std::string("")){ MObject node = getNode(MString(_camera.c_str()),&retStatus); camera.getAPathTo(node); } else { M3dView view = M3dView::active3dView(&retStatus); CHECKERR(retStatus,"M3dView::active3dView"); retStatus = view.getCamera(camera); CHECKERR(retStatus,"M3dView::active3dView"); } MString integrator; MFnDependencyNode globals(raytraceGlobalsNode::get()); getCustomAttribute(integrator, "integrator", globals); cout << "Integrator: " << integrator.asChar() << endl; MString intersector; getCustomAttribute(intersector, "intersector", globals); cout << "Intersector: " << intersector.asChar() << endl; MString sampler; getCustomAttribute(sampler, "sampler", globals); cout << "Sampler: " << sampler.asChar() << endl; //set the renderview retStatus = MRenderView::setCurrentCamera (camera ); CHECKERR(retStatus,"MRenderView::setCurrentCamera (camera )"); cout << "Camera: " << camera.fullPathName().asChar() << endl; int xSize = _resolution.x(),ySize = _resolution.y(); // raytrace things MayaSceneReader* mayaReader(new MayaSceneReader()); boost::shared_ptr<Raytrace::ISceneReader> sceneReader(mayaReader); mayaReader->SetResolution(_resolution); mayaReader->SetCamera(camera); Raytrace::Output output = Raytrace::CreateCustomOutput(sceneReader,"mayaOutput"); RV_PIXEL* pixels = new RV_PIXEL[xSize*ySize]; MRenderView::startRender ( xSize, ySize, true, true ); output->SetIntegrator(integrator.asChar()); output->SetIntersector(intersector.asChar()); output->SetSampler(sampler.asChar()); output->SetOutputSurface(pixels, sizeof(RV_PIXEL)*xSize*ySize, xSize, ySize, Raytrace::IOutput::FORMAT_RGBA_F32); output->Refresh(); std::cout << "Begin Rendering" << std::endl; Raytrace::String status; while(true) { if(output->GetLastFrameInfo(status) == Raytrace::Result::RenderingComplete) break; std::cout << "Update Output : " << status << std::endl; output->UpdateOutput(); MRenderView::updatePixels(0,xSize-1,0,ySize-1, pixels,true); MRenderView::refresh(0,xSize-1,0,ySize-1); Sleep(1000); } std::cout << "Complete Rendering: " << status << std::endl; output->UpdateOutput(); MRenderView::updatePixels(0,xSize-1,0,ySize-1, pixels,true); MRenderView::endRender(); return MS::kSuccess; }