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

pcggui Class Reference

#include <pcggui.h>

Collaboration diagram for pcggui:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Skin_Status { NoError, InvalidSkeleton, VertexWithoutWeight }

Public Member Functions

void BeginEditParams (Interface *ip, IUtil *iu)
void EndEditParams (Interface *ip, IUtil *iu)
void Init (HWND hWnd)
void Destroy (HWND hWnd)
void DeleteThis ()
 pcggui ()
 ~pcggui ()
void CovertScene ()
void ConvertBone (INode *pParent, model::ReferenceModel *rm)
uint ConvertSkin (INode *node, model::ReferenceModel *rm)
Modifier * getModifier (INode *pNode, Class_ID modCID)
void SetReferenceModelMode (BOOL rm)
void ExportAll ()
void SaveAll ()
void LoadAll ()
void SaveAnalyzer ()
void LoadAnalyzer ()
void Analyze ()
void Render ()

Public Attributes

HWND hPanel
IUtil * iu
Interface * ip
BOOL refModel

Private Attributes

vector< model::ExampleModel * > exampleModels
vector< model::ReferenceModel * > referenceModels
model::Analyzer pca

Member Enumeration Documentation

enum pcggui::Skin_Status
 

Enumeration values:
NoError 
InvalidSkeleton 
VertexWithoutWeight 

Definition at line 54 of file pcggui.h.

00054                          {
00055                 NoError,
00056                 InvalidSkeleton,
00057                 VertexWithoutWeight,
00058         };


Constructor & Destructor Documentation

pcggui::pcggui  ) 
 

Definition at line 130 of file pcggui.cpp.

References hPanel, ip, and iu.

00131 {
00132         iu = NULL;
00133         ip = NULL;      
00134         hPanel = NULL;
00135 }

pcggui::~pcggui  ) 
 

Definition at line 137 of file pcggui.cpp.

00138 {
00139 
00140 }


Member Function Documentation

void pcggui::Analyze  ) 
 

Definition at line 354 of file pcggui.cpp.

References model::Analyzer::adjust(), model::Analyzer::computeEnergy(), model::Analyzer::covariance(), exampleModels, model::Analyzer::findComponents(), model::Analyzer::mean(), model::Analyzer::mergeData(), pca, referenceModels, model::Analyzer::selectComponents(), and model::Analyzer::transformation().

Referenced by pcgguiDlgProc().

00354                      {
00355         DebugPrint("*************Starting to Analyze*************\n");
00356         pca.mergeData(*referenceModels[0],exampleModels);
00357         DebugPrint("Calculating mean\n");
00358         pca.mean();
00359         DebugPrint("Adjusting data\n");
00360         pca.adjust();
00361         DebugPrint("Finding Covariance\n");
00362         pca.covariance();
00363         DebugPrint("Begin EigenVector calculations\n");
00364         DebugPrint("Timer Started\n");
00365         clock_t begin = clock();
00366         pca.findComponents(model::Analyzer::HOUSEHOLDER);
00367         clock_t end = clock();
00368         DebugPrint("Timer Stopped\n");
00369         DebugPrint("Time elapsed in seconds: %d\n", difftime(end, begin));
00370         DebugPrint("End EigenVector calculations\n");
00371         pca.computeEnergy();
00372         pca.selectComponents();
00373         pca.transformation();
00374 }

Here is the call graph for this function:

void pcggui::BeginEditParams Interface *  ip,
IUtil *  iu
 

Definition at line 142 of file pcggui.cpp.

References file, GetString(), hInstance, hPanel, IDD_PANEL, IDS_PARAMS, and pcgguiDlgProc().

00143 {
00144         fopen_s(&file,"c:\\testdebug.txt","w");
00145         fprintf(file,"");
00146         fclose(file);
00147         fopen_s(&file,"c:\\testdebug.txt","a");
00148         fprintf(file,"\nFile Opened\n");
00149         this->iu = iu;
00150         this->ip = ip;
00151         hPanel = ip->AddRollupPage(
00152                 hInstance,
00153                 MAKEINTRESOURCE(IDD_PANEL),
00154                 pcgguiDlgProc,
00155                 GetString(IDS_PARAMS),
00156                 0);
00157 }

Here is the call graph for this function:

void pcggui::ConvertBone INode *  pParent,
model::ReferenceModel rm
 

Definition at line 282 of file pcggui.cpp.

References model::Skeleton::addBone(), and model::ReferenceModel::getSkeleton().

Referenced by CovertScene().

00282                                                                 {
00283         DebugPrint("Sub Named Object: \"%s\"\n",pParent->GetName());
00284 
00285         rm->getSkeleton()->addBone(NULL,NULL,10,pParent->GetName());
00286 
00287         for(int q=0;q<pParent->NumberOfChildren();q++) {
00288                 ConvertBone(pParent->GetChildNode(q),rm);
00289         }
00290 }

Here is the call graph for this function:

uint pcggui::ConvertSkin INode *  node,
model::ReferenceModel rm
 

Definition at line 475 of file pcggui.cpp.

References model::Bone::addMapping(), ISkinContextData::GetAssignedBone(), ISkin::GetBone(), model::Skeleton::getBone(), ISkinContextData::GetBoneWeight(), ISkin::GetContextInterface(), getModifier(), ISkinContextData::GetNumAssignedBones(), ISkinContextData::GetNumPoints(), model::ReferenceModel::getSkeleton(), SKIN_CLASS_ID, SKIN_INTERFACE, and uint.

Referenced by CovertScene().

00475                                                              {
00476         // Return success
00477         uint ok=NoError;
00478 
00479         // Get the skin modifier
00480         Modifier* skin=getModifier (node, SKIN_CLASS_ID);
00481 
00482         // Found it ?
00483         if (skin)
00484         {
00485                 // **********    COMSKIN EXPORT    **********
00486 
00487                 // Get a com_skin2 interface
00488                 ISkin *comSkinInterface=(ISkin*)skin->GetInterface (SKIN_INTERFACE);
00489 
00490                 // Should been controled with isSkin before.
00491                 assert (comSkinInterface);
00492 
00493                 // Found com_skin2 ?
00494                 if (comSkinInterface)
00495                 {
00496                         // Get local data
00497                         ISkinContextData *localData=comSkinInterface->GetContextInterface(node);
00498 
00499                         // Should been controled with isSkin before.
00500                         assert (localData);
00501 
00502                         // Found ?
00503                         if (localData)
00504                         {
00505                                 // Check same vertices count
00506                                 uint vertCount=localData->GetNumPoints();
00507 
00508 
00509                                 // For each vertex
00510                                 for (uint vert=0; vert<vertCount; vert++)
00511                                 {
00512                                         // Get bones count for this vertex
00513                                         uint boneCount=localData->GetNumAssignedBones (vert);
00514 
00515                                         // No bones, can't export
00516                                         if (boneCount==0)
00517                                         {
00518                                                 // Error
00519                                                 ok=VertexWithoutWeight;
00520                                                 break;
00521                                         }
00522 
00523                                         // A map of float / string
00524                                         //std::multimap<float, uint> weightMap;
00525                                         std::map<float, uint> weightMap;
00526 
00527                                         // For each bones
00528                                         for (uint bone=0; bone<boneCount; bone++)
00529                                         {
00530                                                 // Get the bone weight
00531                                                 float weight=localData->GetBoneWeight (vert, bone);
00532 
00533                                                 // Get bone number
00534                                                 uint boneId=localData->GetAssignedBone (vert, bone);
00535 
00536                                                 // Insert in the map
00537                                                 weightMap.insert (std::map<float, uint>::value_type (weight, boneId));
00538                                         }
00539 
00540                                         // Sum the NL3D_MESH_SKINNING_MAX_MATRIX highest bones
00541                                         float sum=0.f;
00542                                         std::map<float, uint>::iterator ite=weightMap.begin();
00543                                         while (ite!=weightMap.end())
00544                                         {
00545                                                 // Add to the sum
00546                                                 sum+=ite->first;
00547 
00548                                                 // Next value
00549                                                 ite++;
00550                                         }
00551 
00552                                         // For each bones in the list, build the skin information
00553                                         uint id=0;
00554                                         ite=weightMap.end();
00555                                         while (ite!=weightMap.begin())
00556                                         {
00557                                                 // Previous value
00558                                                 ite--;
00559 
00560                                                 // Get the bones ID
00561                                                 Bone* bone = rm->getSkeleton()->getBone(comSkinInterface->GetBone(ite->second)->GetName());
00562 
00563                                                 // Set the weight
00564                                                 //DebugPrint("Bone: %s - Vertex: %d - %f\n",bone->getName().c_str(),vert,ite->first/sum);
00565                                                 bone->addMapping(new model::Mapping(vert,ite->first/sum));
00566 
00567                                                 // Next Id
00568                                                 id++;
00569                                         }
00570                                         // Breaked ?
00571                                         if (ite!=weightMap.begin())
00572                                         {
00573                                                 // break again to exit
00574                                                 break;
00575                                         }
00576                                 }
00577                         }
00578                 }
00579 
00580                 // Release the interface
00581                 skin->ReleaseInterface (SKIN_INTERFACE, comSkinInterface);
00582         }
00583         /*else
00584         {
00585                 // **********    PHYSIQUE EXPORT    **********
00586 
00587                 // Physique mode
00588                 Modifier* skin=getModifier (node, PHYSIQUE_CLASS_ID);
00589 
00590                 // Must exist
00591                 assert (skin);
00592                 
00593                 // Get a com_skin2 interface
00594                 IPhysiqueExport *physiqueInterface=(IPhysiqueExport *)skin->GetInterface (I_PHYINTERFACE);
00595 
00596                 // Should been controled with isSkin before.
00597                 assert (physiqueInterface);
00598 
00599                 // Found com_skin2 ?
00600                 if (physiqueInterface)
00601                 {
00602                         // Get local data
00603                         IPhyContextExport *localData=physiqueInterface->GetContextInterface(&node);
00604 
00605                         // Should been controled with isSkin before.
00606                         assert (localData);
00607 
00608                         // Found ?
00609                         if (localData)
00610                         {
00611                                 // Use rigid export
00612                                 localData->ConvertToRigid (TRUE);
00613 
00614                                 // Allow blending
00615                                 localData->AllowBlending (TRUE);
00616 
00617                                 // Check same vertices count
00618                                 uint vertCount=localData->GetNumberVertices();
00619 
00620                                 // Ctrl we have the same number of vertices in the mesh and in the modifier.
00621                                 if (rm->getVertexs().size()!=vertCount)
00622                                 {
00623                                         ok=InvalidSkeleton;
00624                                 }
00625                                 else
00626                                 {
00627                                         // If not the same count, return false (perhaps, the modifier is not in the good place in the stack..)
00628                                         if (rm->getVertexs().size()==vertCount)
00629                                         {
00630                                                 // Rebuild the array
00631                                                 buildMesh.SkinWeights.resize (vertCount);
00632 
00633                                                 // For each vertex
00634                                                 for (uint vert=0; vert<vertCount; vert++)
00635                                                 {
00636                                                         // Get a vertex interface
00637                                                         IPhyVertexExport *vertexInterface=localData->GetVertexInterface (vert);
00638 
00639                                                         // Check if it is a rigid vertex or a blended vertex
00640                                                         IPhyRigidVertex                 *rigidInterface=NULL;
00641                                                         IPhyBlendedRigidVertex  *blendedInterface=NULL;
00642                                                         int type=vertexInterface->GetVertexType ();
00643                                                         if (type==RIGID_TYPE)
00644                                                         {
00645                                                                 // this is a rigid vertex
00646                                                                 rigidInterface=(IPhyRigidVertex*)vertexInterface;
00647                                                         }
00648                                                         else
00649                                                         {
00650                                                                 // It must be a blendable vertex
00651                                                                 assert (type==RIGID_BLENDED_TYPE);
00652                                                                 blendedInterface=(IPhyBlendedRigidVertex*)vertexInterface;
00653                                                         }
00654 
00655                                                         // Get bones count for this vertex
00656                                                         uint boneCount;
00657                                                         if (blendedInterface)
00658                                                         {
00659                                                                 // If blenvertex, only one bone
00660                                                                 boneCount=blendedInterface->GetNumberNodes();
00661                                                         }
00662                                                         else
00663                                                         {
00664                                                                 // If rigid vertex, only one bone
00665                                                                 boneCount=1;
00666                                                         }
00667 
00668                                                         // No bones, can't export
00669                                                         if (boneCount==0)
00670                                                         {
00671                                                                 // Error
00672                                                                 ok=VertexWithoutWeight;
00673                                                                 break;
00674                                                         }
00675 
00676                                                         // A map of float / string
00677                                                         //std::multimap<float, INode*> weightMap;
00678                                                         std::map<float, INode*> weightMap;
00679 
00680                                                         // For each bones
00681                                                         for (uint bone=0; bone<boneCount; bone++)
00682                                                         {
00683                                                                 if (blendedInterface)
00684                                                                 {
00685                                                                         // Get the bone weight
00686                                                                         float weight=blendedInterface->GetWeight(bone);
00687 
00688                                                                         // Get node
00689                                                                         INode *node=blendedInterface->GetNode(bone);
00690                                                                         assert (node);
00691 
00692                                                                         // Insert in the map
00693                                                                         weightMap.insert (std::map<float, INode*>::value_type (weight, node));
00694                                                                 }
00695                                                                 else
00696                                                                 {
00697                                                                         // Get node
00698                                                                         INode *node=rigidInterface->GetNode();
00699                                                                         assert (node);
00700 
00701                                                                         // Insert in the map
00702                                                                         weightMap.insert (std::map<float, INode*>::value_type (1, node));
00703                                                                 }
00704                                                         }
00705 
00706                                                         // Sum the NL3D_MESH_SKINNING_MAX_MATRIX highest bones
00707                                                         float sum=0.f;
00708                                                         std::map<float, INode*>::iterator ite=weightMap.begin();
00709                                                         while (ite!=weightMap.end())
00710                                                         {
00711                                                                 // Add to the sum
00712                                                                 sum+=ite->first;
00713                                                                 
00714                                                                 // Next value
00715                                                                 ite++;
00716                                                         }
00717 
00718                                                         // For each bones in the list, build the skin information
00719                                                         uint id=0;
00720                                                         ite=weightMap.end();
00721                                                         while (ite!=weightMap.begin())
00722                                                         {
00723                                                                 // Previous value
00724                                                                 ite--;
00725 
00726                                                                 // Get the bones ID
00727                                                                 sint32 matrixId=-1;
00728                                                                 TInodePtrInt::const_iterator itId=skeletonShape.find (ite->second);
00729                                                                 if (itId!=skeletonShape.end())
00730                                                                         matrixId=itId->second;
00731 
00732                                                                 // Find the bone ?
00733                                                                 if (matrixId==-1)
00734                                                                 {
00735                                                                         // no, error, wrong skeleton
00736                                                                         ok=InvalidSkeleton;
00737                                                                         break;
00738                                                                 }
00739 
00740                                                                 // Set the weight
00741                                                                 buildMesh.SkinWeights[vert].MatrixId[id]=matrixId;
00742                                                                 buildMesh.SkinWeights[vert].Weights[id]=ite->first/sum;
00743                                                                 
00744                                                                 // Next Id
00745                                                                 id++;
00746                                                         }
00747                                                         
00748                                                         // Breaked ?
00749                                                         if (ite!=weightMap.begin())
00750                                                         {
00751                                                                 // break again to exit
00752                                                                 break;
00753                                                         }
00754 
00755                                                         // Release vertex interfaces
00756                                                         localData->ReleaseVertexInterface (vertexInterface);
00757                                                 }
00758                                         }
00759                                 }
00760 
00761                                 // Release locaData interface
00762                                 physiqueInterface->ReleaseContextInterface (localData);
00763                         }
00764 
00765                 }
00766 
00767                 // Release the interface
00768                 skin->ReleaseInterface (I_PHYINTERFACE, physiqueInterface);
00769         }*/
00770 
00771         return ok;
00772 }

Here is the call graph for this function:

void pcggui::CovertScene  ) 
 

Definition at line 178 of file pcggui.cpp.

References model::Model::addFace(), model::Model::addVertex(), ConvertBone(), ConvertSkin(), exampleModels, model::Model::getVertex(), ip, referenceModels, model::Vertex::setCoordinates(), model::Vertex::setNormal(), model::Face::setVertices(), and thepcggui.

Referenced by pcgguiDlgProc().

00178                          {
00179         model::ExampleModel* em = new model::ExampleModel();
00180         model::ReferenceModel* rm = new model::ReferenceModel();
00181         TimeValue currtime = thepcggui.ip->GetTime();
00182         INode* node;
00183         BOOL needDel;
00184         NullView nullView;
00185         unsigned long offset = 0;
00186         unsigned long tmpOffset = 0;
00187 
00188         if(thepcggui.ip->GetRootNode()->NumberOfChildren() > 0) {
00189                 for(int n=0;n<thepcggui.ip->GetRootNode()->NumberOfChildren();n++) {
00190 
00191                         node = thepcggui.ip->GetRootNode()->GetChildNode(n);
00192                         ObjectState os = node->EvalWorldState(currtime);
00193 
00195                         // find and export modifier data if
00196                         // exists for this node
00197 
00198                         Object* pObj = node->GetObjectRef();
00199                         // make sure we have a derived obj, which implies
00200                         // modifiers are avail, and not a base obj
00201                         while (pObj && pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID) {
00202                                 IDerivedObject* pDerObj = (IDerivedObject*) pObj;
00203                                 // Iterate over all entries of the modifier stack.
00204                                 for (int Idx = 0; Idx < pDerObj->NumModifiers(); Idx++) {
00205                                         Modifier* mod = pDerObj->GetModifier(Idx);
00206                                         DebugPrint("Mod Name: %s\n",mod->GetName());
00207                                         DebugPrint("Mod class ID: 0x%x - %d\n",mod->ClassID(),mod->ClassID());
00208                                         /*if(mod->ClassID() == 9845843) {
00209                                                 DebugPrint("SKIN\n");
00210                                         }*/
00211                                         
00212                                         //if (mod->ClassID() == Class_ID(BENDOSM_CLASS_ID,0)) {
00213                                 }
00214                                 // get next object in stack -- could be base obj,
00215                                 // or another derived obj
00216                                 pObj = pDerObj->GetObjRef();
00217                         }
00218 
00219 
00220                         if(os.obj->SuperClassID()==GEOMOBJECT_CLASS_ID) {
00221                                 if(node->GetBoneNodeOnOff()) {
00222                                         if(refModel) {
00223                                                 ConvertBone(node,rm);
00224                                         }
00225                                 } else {
00226                                         Mesh *mesh = ((GeomObject*)os.obj)->GetRenderMesh(thepcggui.ip->GetTime(),node,nullView,needDel);
00227                                         if (!mesh) return;
00228 
00229                                         mesh->buildNormals();
00230                                         Matrix3 tm = node->GetObjTMAfterWSM(thepcggui.ip->GetTime());
00231                                         for (int i=0; i<mesh->getNumVerts(); i++) {
00232                                                 Point3 v = (tm * mesh->verts[i]);
00233                                                 model::Vertex* vertex = new model::Vertex();
00234                                                 vertex->setCoordinates(v.x, v.y, v.z);
00235                                                 vertex->setNormal(mesh->getNormal(i).x,mesh->getNormal(i).y,mesh->getNormal(i).z);
00236                                                 if(refModel) {
00237                                                         rm->addVertex(vertex);
00238                                                 } else {
00239                                                         em->addVertex(vertex);
00240                                                 }
00241                                                 tmpOffset = i;
00242                                         }
00243                                         for (int i=0; i<mesh->getNumFaces(); i++) {
00244                                                 model::Face* face = new model::Face();
00245                                                 if(refModel) {
00246                                                         face->setVertices(
00247                                                                 rm->getVertex(offset + (int)mesh->faces[i].v[0]),
00248                                                                 rm->getVertex(offset + (int)mesh->faces[i].v[1]),
00249                                                                 rm->getVertex(offset + (int)mesh->faces[i].v[2]));
00250                                                         rm->addFace(face);
00251                                                 } else {
00252                                                         face->setVertices(
00253                                                                 em->getVertex(offset + (int)mesh->faces[i].v[0]),
00254                                                                 em->getVertex(offset + (int)mesh->faces[i].v[1]),
00255                                                                 em->getVertex(offset + (int)mesh->faces[i].v[2]));
00256                                                         em->addFace(face);
00257                                                 }
00258                                         }
00259                                         offset = tmpOffset;
00260                                 }
00261                         }
00262                 }
00263                 for(int n=0;n<thepcggui.ip->GetRootNode()->NumberOfChildren();n++) {
00264                         node = thepcggui.ip->GetRootNode()->GetChildNode(n);
00265                         ObjectState os = node->EvalWorldState(currtime);
00266                         if(os.obj->SuperClassID()==GEOMOBJECT_CLASS_ID) {
00267                                 if(!node->GetBoneNodeOnOff()) {
00268                                         if(refModel) {
00269                                                 DebugPrint("Error Code: %d\n",ConvertSkin(node,rm));
00270                                         }
00271                                 }
00272                         }
00273                 }
00274                 if(refModel) {
00275                         referenceModels.push_back(rm);
00276                 } else {
00277                         exampleModels.push_back(em);
00278                 }
00279         }
00280 }

Here is the call graph for this function:

void pcggui::DeleteThis  )  [inline]
 

Definition at line 67 of file pcggui.h.

00067 { }             

void pcggui::Destroy HWND  hWnd  ) 
 

Definition at line 173 of file pcggui.cpp.

References file.

Referenced by pcgguiDlgProc().

00174 {
00175         fprintf(file,"Destroy\n");
00176 }

void pcggui::EndEditParams Interface *  ip,
IUtil *  iu
 

Definition at line 159 of file pcggui.cpp.

References file, and hPanel.

00160 {
00161         this->iu = NULL;
00162         this->ip = NULL;
00163         ip->DeleteRollupPage(hPanel);
00164         hPanel = NULL;
00165         fclose(file);
00166 }

void pcggui::ExportAll  ) 
 

Definition at line 292 of file pcggui.cpp.

References exampleModels, functions::Exporter::exportModel(), and referenceModels.

Referenced by pcgguiDlgProc().

00292                        {
00293         functions::Exporter ex = functions::Exporter();
00294         char tmp[100];
00295 
00296         for(int i=0; i<exampleModels.size(); i++) {
00297                 sprintf_s(tmp,"c:\\exampleModel%d.x3d",i);
00298                 ex.exportModel(exampleModels[i],tmp);
00299         }
00300 
00301         for(int i=0; i<referenceModels.size(); i++) {
00302                 sprintf_s(tmp,"c:\\referenceModel%d.x3d",i);
00303                 ex.exportModel(referenceModels[i],tmp);
00304         }
00305 
00306 }

Here is the call graph for this function:

Modifier * pcggui::getModifier INode *  pNode,
Class_ID  modCID
 

Definition at line 437 of file pcggui.cpp.

Referenced by ConvertSkin().

00438 {
00439         Object* pObj = pNode->GetObjectRef();
00440 
00441         if (!pObj)
00442                 return NULL;
00443 
00444         ObjectState os = pNode->EvalWorldState(0);
00445         if (os.obj && (os.obj->SuperClassID() != GEOMOBJECT_CLASS_ID) && (os.obj->SuperClassID() != LIGHT_CLASS_ID) )
00446         {
00447                 return NULL;
00448         }
00449 
00450         // For all derived objects (can be > 1)
00451         while (pObj && (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID))
00452         {
00453                 IDerivedObject* pDObj = (IDerivedObject*)pObj;
00454                 int m;
00455                 int nNumMods = pDObj->NumModifiers();
00456                 // Step through all modififers and verify the class id
00457                 for (m=0; m<nNumMods; ++m) 
00458                 {
00459                         Modifier* pMod = pDObj->GetModifier(m);
00460                         if (pMod) 
00461                         {
00462                                 if (pMod->ClassID() == modCID) 
00463                                 {
00464                                         // Match! Return it
00465                                         return pMod;
00466                                 }
00467                         }
00468                 }
00469                 pObj = pDObj->GetObjRef();
00470         }
00471 
00472         return NULL;
00473 }

void pcggui::Init HWND  hWnd  ) 
 

Definition at line 168 of file pcggui.cpp.

References file.

Referenced by pcgguiDlgProc().

00169 {
00170         fprintf(file,"Init\n");
00171 }

void pcggui::LoadAll  ) 
 

Definition at line 322 of file pcggui.cpp.

References exampleModels, model::ReferenceModel::load(), model::Model::load(), and referenceModels.

Referenced by pcgguiDlgProc().

00322                      {
00323         char tmp[100];
00324         int number = 10;
00325 
00326         exampleModels.clear();
00327         referenceModels.clear();
00328 
00329         for(int i=0; i<number; i++) {
00330                 sprintf_s(tmp,"c:\\savedExampleModel%d.pcg",i);
00331                 model::ExampleModel* em = new model::ExampleModel();
00332                 if(em->load(tmp)) {
00333                         exampleModels.push_back(em);
00334                 }
00335         }
00336 
00337         for(int i=0; i<number; i++) {
00338                 sprintf_s(tmp,"c:\\savedReferenceModel%d.pcg",i);
00339                 model::ReferenceModel* rm = new model::ReferenceModel();
00340                 if(rm->load(tmp)) {
00341                         referenceModels.push_back(rm);
00342                 }
00343         }
00344 }

Here is the call graph for this function:

void pcggui::LoadAnalyzer  ) 
 

Definition at line 350 of file pcggui.cpp.

References model::Analyzer::load(), and pca.

Referenced by pcgguiDlgProc().

00350                           {
00351         pca.load("c:\\PCG-ANALYZER");
00352 }

Here is the call graph for this function:

void pcggui::Render  ) 
 

Definition at line 376 of file pcggui.cpp.

References exampleModels, model::Vertex::getCoordinates(), model::Model::getFace(), model::Model::getFaces(), model::Vertex::getIndex(), model::Vertex::getNormal(), model::Face::getVertex(), model::Model::getVertex(), model::Model::getVertexs(), ip, and model::Vertex::setNormal().

Referenced by pcgguiDlgProc().

00376                     {
00377         Mesh mesh;
00378         model::ExampleModel* em = exampleModels[0];
00379         mesh.setNumVerts(em->getVertexs().size());
00380         mesh.setNumFaces(em->getFaces().size());
00381         for(int i=0;i<em->getVertexs().size();i++) {
00382                 Vertex* v = em->getVertex(i);
00383                 mesh.setVert(i,Point3(v->getCoordinates()->x,v->getCoordinates()->y,v->getCoordinates()->z));
00384                 mesh.setNormal(i,Point3(v->getNormal()->x,v->getNormal()->y,v->getNormal()->z));
00385         }
00386         for(int i=0;i<em->getFaces().size();i++) {
00387                 model::Face* f = em->getFace(i);
00388                 mesh.faces[i].setVerts(f->getVertex(0)->getIndex(),f->getVertex(1)->getIndex(),f->getVertex(2)->getIndex());
00389         }
00390 
00391         //TriObject *obj = CreateNewTriObject();
00392         //RegisterEditTriObjDesc( GetEditTriObjDesc() );
00393 
00394         // Create a new object through the CreateInstance() API
00395         GeomObject *obj = (GeomObject*)ip->CreateInstance(GEOMOBJECT_CLASS_ID, Class_ID(BOXOBJ_CLASS_ID ,0));
00396         assert(obj);
00397         
00398         
00399         //((TriObject*)obj)->mesh = mesh;
00400         //RegisterEditTriObjDesc( GetTriObjDescriptor() );
00401 
00402 
00403 
00404         // Create a derived object that references the cylinder
00405         IDerivedObject *dobj = CreateDerivedObject(obj);
00406 
00407         // Create a node in the scene that references the derived object
00408         INode *node = ip->CreateObjectNode(dobj);
00409 
00410         // Name the node and make the name unique.
00411         TSTR name(_T("MyNode"));
00412         ip->MakeNameUnique(name);
00413         node->SetName(name);
00414 
00415         // Eval the node's object (exclude WSMs)
00416         Object *oldObj = node->GetObjectRef();
00417         ObjectState os = oldObj->Eval(ip->GetTime());
00418 
00419         // Set the result to be the node's new object (make a clone)
00420         Object *newobj = (Object*)os.obj->Clone();
00421         newobj->SetSubSelState(0); // Reset the selection level to object level
00422         oldObj->SetAFlag(A_LOCK_TARGET);
00423         node->SetObjectRef(newobj);
00424         node->NotifyDependents(FOREVER,0,REFMSG_SUBANIM_STRUCTURE_CHANGED);
00425         oldObj->ClearAFlag(A_LOCK_TARGET);
00426         oldObj->MaybeAutoDelete();
00427 
00428 
00429         // Redraw the viewports
00430         ip->RedrawViews(ip->GetTime());
00431 
00432 }

Here is the call graph for this function:

void pcggui::SaveAll  ) 
 

Definition at line 308 of file pcggui.cpp.

References exampleModels, and referenceModels.

Referenced by pcgguiDlgProc().

00308                      {
00309         char tmp[100];
00310 
00311         for(int i=0; i<exampleModels.size(); i++) {
00312                 sprintf_s(tmp,"c:\\savedExampleModel%d.pcg",i);
00313                 exampleModels[i]->save(tmp);
00314         }
00315 
00316         for(int i=0; i<referenceModels.size(); i++) {
00317                 sprintf_s(tmp,"c:\\savedReferenceModel%d.pcg",i);
00318                 referenceModels[i]->save(tmp);
00319         }
00320 }

void pcggui::SaveAnalyzer  ) 
 

Definition at line 346 of file pcggui.cpp.

References pca, and model::Analyzer::save().

Referenced by pcgguiDlgProc().

00346                           {
00347         pca.save("c:\\PCG-ANALYZER");
00348 }

Here is the call graph for this function:

void pcggui::SetReferenceModelMode BOOL  rm  )  [inline]
 

Definition at line 77 of file pcggui.h.

References refModel.

Referenced by pcgguiDlgProc().

00077 { refModel = rm; };


Member Data Documentation

vector<model::ExampleModel*> pcggui::exampleModels [private]
 

Definition at line 43 of file pcggui.h.

Referenced by Analyze(), CovertScene(), ExportAll(), LoadAll(), Render(), and SaveAll().

HWND pcggui::hPanel
 

Definition at line 49 of file pcggui.h.

Referenced by BeginEditParams(), EndEditParams(), and pcggui().

Interface* pcggui::ip
 

Definition at line 51 of file pcggui.h.

Referenced by CovertScene(), pcggui(), pcgguiDlgProc(), and Render().

IUtil* pcggui::iu
 

Definition at line 50 of file pcggui.h.

Referenced by pcggui().

model::Analyzer pcggui::pca [private]
 

Definition at line 45 of file pcggui.h.

Referenced by Analyze(), LoadAnalyzer(), and SaveAnalyzer().

vector<model::ReferenceModel*> pcggui::referenceModels [private]
 

Definition at line 44 of file pcggui.h.

Referenced by Analyze(), CovertScene(), ExportAll(), LoadAll(), and SaveAll().

BOOL pcggui::refModel
 

Definition at line 52 of file pcggui.h.

Referenced by SetReferenceModelMode().


The documentation for this class was generated from the following files:
Generated on Tue Apr 17 09:39:51 2007 for PCG Library by  doxygen 1.3.9.1