示例#1
0
void loadLogo (String fileName)
{
  //Read the file
  File file( fileName );
  if( !file.open( "rb" ))
  {
    printf( "Failed opening file '%s'!\n", fileName.toCSTR().buffer() );
    getchar();
    exit( 1 );
  }
  
  data = file.read( file.getSize() );
  file.close();
  
  //Load character data
  SerializeManager sm;
  mshLogo = (TriMesh*) sm.load( (void*)data.buffer() );
  mshLogo->sendToGpu();

  printf ("Logo: %d verts, %d faces\n",
          mshLogo->getVertexCount(),
          mshLogo->getFaceCount());
}
示例#2
0
void loadPackage (String fileName)
{ 
  //Read the file
  File file( fileName );
  if( !file.open( "rb" ))
  {
    printf( "Failed opening file '%s'!\n", fileName.toCSTR().buffer() );
    getchar();
    exit( 1 );
  }
  
  data = file.read( file.getSize() );
  file.close();
  
  //Load character data
  SerializeManager sm;
  character = (Character*) sm.load( (void*)data.buffer() );
  
  printf ("Imported %d verts, %d faces, %d animations\n",
          character->mesh->getVertexCount(),
          character->mesh->getFaceCount(),
          character->anims.size());
  
  printf ("Animation name: '%s'\n",
          character->anims.first()->name.buffer());

  numFrames = character->anims.first()->tracksR.first()->keys.size();
  maxTime = character->anims.first()->tracksR.first()->totalTime;

  //Split into 24-bone sub meshes
  SkinSuperToSubMesh splitter( character->mesh );
  splitter.splitByBoneLimit( 24 );

  UintSize numMeshes = splitter.getSubMeshCount();
  for (UintSize m=0; m<numMeshes; ++m)
  {
    SkinTriMesh *mesh = (SkinTriMesh*) splitter.getSubMesh(m);
    character->meshes.pushBack( mesh );
    mesh->sendToGpu();
  }

  /*
  //Add vertices to the mesh
  polyMesh = new SPolyMesh;
  ArrayList <SPolyMesh::Vertex*> verts( inMesh->verts.size() );
  for (UintSize v=0; v<inMesh->verts.size(); ++v)
  {
    SPolyMesh::Vertex *vert = (SPolyMesh::Vertex*) polyMesh->addVertex();
    vert->point = inMesh->verts[v].point;
    for (int b=0; b<4; ++b) {
      vert->boneIndex[b] = inMesh->verts[v].boneIndex[b];
      vert->boneWeight[b] = inMesh->verts[v].boneWeight[b]; }
    verts.pushBack (vert);
  }
  
  //Add indexed faces to the mesh
  int nextIndex = 0;
  for (UintSize f=0; f<inMesh->faces.size(); ++f)
  {
    int numCorners = inMesh->faces[f].numCorners;
    HMesh::Vertex **corners = new HMesh::Vertex*[ numCorners ];
    
    for (int c=0; c<numCorners; ++c) {
      Uint32 vertIndex = inMesh->indices[ nextIndex++ ];
      if (vertIndex > inMesh->verts.size()) {
        printf( "Invalid vertex: %d\n", vertIndex );
        vertIndex = 0; }
      corners[c] = verts[ vertIndex ];
    }
    
    SPolyMesh::Face *face = (SPolyMesh::Face*) polyMesh->addFace( corners, numCorners );
    if (face != NULL) face->smoothGroups = inMesh->faces[f].smoothGroups;
    
    delete[] corners;
  }
  */ 
}