Jump to content
  • entries
    941
  • comments
    5,894
  • views
    866,029

GMF2 SDK Update


Josh

1,043 views

 Share

The GMF2 SDK has been updated with tangents and bounds calculation, object colors, and save-to-file functionality.

The GMF2 SDK is a lightweight engine-agnostic open-source toolkit for loading and saving of game models. The GMF2 format can work as a standalone file format or simply as a data format for import and export plugins. This gives us a protocol we can pull model data into and export model data from, and a format that loads large data much faster than alternative file formats.

Here is an example showing how to construct a GMF2 model and save it to a file:

//Create a GMF file
GMFFile* file = new GMFFile;

//Create a model
GMFNode* node = new GMFNode(file, GMF_TYPE_MODEL);

//Set the orientation
node->SetMatrix(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);

//Set the object color
node->SetColor(0,0,1,1);

//Add one LOD level
GMFLOD* lod = node->AddLOD();

//Create a triangle mesh and add it to the LOD. (Meshes can be shared.)
GMFMesh* mesh = new GMFMesh(file, 3);
lod->AddMesh(mesh);

//Add vertices
mesh->AddVertex(-0.5,0.5,0, 0,0,1, 0,0);
mesh->AddVertex(0.5,0.5,0, 0,0,1, 1,0);
mesh->AddVertex(0.5,-0.5,0, 0,0,1, 1,1);
mesh->AddVertex(-0.5,-0.5,0, 0,0,1, 0,1);

//Add triangles
mesh->AddPolygon(0,1,2);
mesh->AddPolygon(0,2,3);

//Build vertex tangents (optional)
mesh->UpdateTangents();

//Save data to file
file->Save("out.gmf");

//Cleanup - This will get rid of all created objects
delete file;

You can get the GMF2 SDK on GitHub.

  • Like 1
 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...