void SSceneSummary::SObjectInfo::Prepare() { bReady = true; if (object_name.size()){ CEditableObject* O = Lib.CreateEditObject(object_name.c_str()); xr_string pref = object_name.c_str(); if (O){ SPairInfo tmp; tmp.first = pref+"\\References"; tmp.second = _itoa(ref_count); info.push_back (tmp); tmp.first = pref+"\\Geometry\\Faces"; tmp.second = _itoa(O->GetFaceCount()); info.push_back (tmp); tmp.first = pref+"\\Geometry\\Vertices"; tmp.second = _itoa(O->GetVertexCount()); info.push_back (tmp); SurfaceVec& surfaces = O->Surfaces(); for (SurfaceIt it=surfaces.begin(); it!=surfaces.end(); it++){ xr_string pr= pref+xr_string("\\Materials\\")+(*it)->_Name(); tmp.first = pr+"\\Texture"; tmp.second = (*it)->_Texture(); info.push_back (tmp); tmp.first = pr+"\\Faces"; tmp.second = _itoa(O->GetSurfFaceCount((*it)->_Name()));info.push_back (tmp); } Lib.RemoveEditObject(O); } }else{ Msg("!Empty object name found."); } }
MStatus CXRayObjectExport::writer ( const MFileObject& file, const MString& options, FileAccessMode mode ) { MStatus status= MS::kFailure; //move default extesion here.. MString mname = file.fullName()+".object"; LPCSTR fname = mname.asChar(); Log("Export object: ",fname); CEditableObject* OBJECT = new CEditableObject(fname); OBJECT->SetVersionToCurrent(TRUE,TRUE); if((mode==MPxFileTranslator::kExportAccessMode)||(mode==MPxFileTranslator::kSaveAccessMode)){ status = ExportAll(OBJECT)?MS::kSuccess:MS::kFailure; }else if(mode==MPxFileTranslator::kExportActiveAccessMode){ status = ExportSelected(OBJECT)?MS::kSuccess:MS::kFailure; } if (MS::kSuccess==status){ OBJECT->Optimize (); OBJECT->SaveObject (fname); Log("Object succesfully exported."); Msg("%d vertices, %d faces", OBJECT->GetVertexCount(), OBJECT->GetFaceCount()); }else{ Log("! Export failed."); } xr_delete(OBJECT); return status; }
bool CSceneObject::GetSummaryInfo(SSceneSummary* inf) { inherited::GetSummaryInfo (inf); CEditableObject* E = GetReference(); R_ASSERT(E); if (IsStatic()||IsMUStatic()){ for(SurfaceIt s_it=E->m_Surfaces.begin(); s_it!=E->m_Surfaces.end(); s_it++){ float area = 0.f; float pixel_area = 0.f; for(EditMeshIt m = E->Meshes().begin();m!=E->Meshes().end();m++){ area += (*m)->CalculateSurfaceArea(*s_it,true); pixel_area += (*m)->CalculateSurfacePixelArea(*s_it,true); } inf->AppendTexture(ChangeFileExt(AnsiString(*(*s_it)->m_Texture),"").LowerCase().c_str(),SSceneSummary::sttBase,area,pixel_area,E->m_LibName.c_str()); } if (m_Flags.is(CEditableObject::eoUsingLOD)){ inf->AppendTexture(E->GetLODTextureName().c_str(),SSceneSummary::sttLOD,0,0,"$LOD$"); inf->lod_objects.insert (E->m_LibName.c_str()); inf->object_lod_ref_cnt++; } if (m_Flags.is(CEditableObject::eoMultipleUsage)){ inf->mu_objects.insert(E->m_LibName.c_str()); inf->object_mu_ref_cnt++; } inf->face_cnt += E->GetFaceCount (); inf->vert_cnt += E->GetVertexCount(); } if (m_Flags.is(CEditableObject::eoHOM)){ inf->hom_face_cnt += E->GetFaceCount (); inf->hom_vert_cnt += E->GetVertexCount(); } if (m_Flags.is(CEditableObject::eoSoundOccluder)){ inf->snd_occ_face_cnt += E->GetFaceCount(); inf->snd_occ_vert_cnt += E->GetVertexCount(); } inf->AppendObject (E->GetName()); return true; }