Von04 Posted February 10, 2010 Share Posted February 10, 2010 Me and my friend Rick have embarked on a long and tedious process to make a GMF Model Editor. We are actually progressing quite nicely, but have run into a few snags. Does anyone know how to find out which bone a particular vertice is attached to? Thanks in advance. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 10, 2010 Share Posted February 10, 2010 http://leadwerks.com/wiki/index.php?title=Game_Model_Format#GMF_SDK Also http://leadwerks.com/developer/SDK/ there is an SDK download. I don't know how relevant it still is. Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Von04 Posted February 11, 2010 Author Share Posted February 11, 2010 We are currently using the GMF/SDK. We have progressed to the point where we can Load/Create a model, modify it, and then save it. It all works fine until we try to save an animation, because we are apparently not attaching the vertices to the correct bones. If anyone else has experimented with this any help would be appreciated. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Josh Posted February 11, 2010 Share Posted February 11, 2010 What language are you writing this in? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Von04 Posted February 11, 2010 Author Share Posted February 11, 2010 We are using c++. Everything seems to save fine except for the animations. Here is our save function. #include "stdafx.h" #include "gmfsdk.h" using namespace System; using namespace System::IO; using namespace System::Runtime::InteropServices; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace Tao::Platform::Windows; using namespace std; static int SaveMeshGMF(TMesh mesh,String^ path,TGMFEntity gmfparent=0) { TGMFMesh gmesh; TGMFSurface gsurf; String^ type=gcnew String(GetEntityKey(mesh,"class")); switch(Convert::ToInt32(GetEntityKey(mesh,"class"))) { case ENTITY_MESH: if(type!="Mesh") break; gmesh=GMFMeshCreate(gmfparent); GMFNodeSetProperty(gmesh,"name", GetEntityKey(mesh,"name","<None>")); for (int s=1; s<Convert::ToInt32(CountSurfaces(mesh)+1);s++) { TSurface surf=GetSurface(mesh,s); gsurf=GMFMeshAddSurface(gmesh); int vcount=Convert::ToInt32(CountVertices(surf)); for(int v=0;v<vcount;v++) { TVec3 Vertex=GetVertexPosition(surf,v); TVec3 VertexN=GetVertexNormal(surf,v); TVec4 Color=GetVertexColor(surf,v); TVec2 VertexUV=GetVertexTexCoords(surf,v); GMFSurfaceAddVertex(gsurf,Vertex.X,Vertex.Y,Vertex.Z,VertexN.X,VertexN.Y,VertexN.Z,VertexUV.X,VertexUV.Y,0.0,0.0,Color.X*255,Color.Y*255,Color.Z*255,Color.W*255); if(AnimationLength(mesh)>0)GMFSurfaceAttachVertex(gsurf,v,gmesh,1); } int tcount=Convert::ToInt32(CountTriangles(surf)); for (int t=0;t<tcount;t++) { GMFSurfaceAddTriangle(gsurf,TriangleVertex(surf,t,0),TriangleVertex(surf,t,1),TriangleVertex(surf,t,2)); } GMFSurfaceCalculateBinormalsAndTangents(gsurf); TMaterial gmeshmaterial=GetSurfaceMaterial(surf); if(gmeshmaterial) { str gmeshname=MaterialName(gmeshmaterial); if (gmeshname!="") { GMFNodeSetProperty (gsurf,"material",gmeshname); } } } TVec16 entmat=GetEntityMatrix(mesh); TMat4 bank; bank.A0=entmat.A0; bank.A1=entmat.A1; bank.A2=entmat.A2; bank.A3=entmat.A3; bank.B0=entmat.B0; bank.B1=entmat.B1; bank.B2=entmat.B2; bank.B3=entmat.B3; bank.C0=entmat.C0; bank.C1=entmat.C1; bank.C2=entmat.C2; bank.C3=entmat.C3; bank.D0=entmat.D0; bank.D1=entmat.D1; bank.D2=entmat.D2; bank.D3=entmat.D3; GMFEntitySetMatrix(gmesh,bank); } if(type!="Mesh") { gmesh=GMFBoneCreate(gmfparent); TVec3 po=EntityPosition(mesh); TVec3 ro=EntityRotation(mesh); TVec3 so=EntityScale(mesh); GMFNodeSetProperty(gmesh,"name", GetEntityKey(mesh,"name","<None>")); GMFEntitySetPositionRotationScale(gmesh,po.X,po.Y,po.Z,ro.X,ro.Y,ro.Z,so.X,so.Y,so.Z); for(int a=0; a < AnimationLength(mesh); a++) { Animate(mesh,a); TVec3 po=EntityPosition(mesh); TVec3 ro=EntityRotation(mesh); TVec4 qu=EntityQuat(mesh); GMFEntityAddQuaternionKey(gmesh,qu.X,qu.Y,qu.Z,qu.W,a); GMFEntityAddPositionKey(gmesh, po.X, po.Y, po.Z, a); GMFEntityAddRotationKey(gmesh, ro.X, ro.Y, ro.Z, a); } } for (int c=1;c<CountChildren(mesh)+1;c++) { SaveMeshGMF(GetChild(mesh,c),path,gmesh); } return GMFMeshSaveFile(gmesh,(char*)(void*)Marshal::StringToHGlobalAnsi(path)); }; Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 11, 2010 Share Posted February 11, 2010 the reply editor is screwy, I have to manually use the "code" and "/code" tags Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Josh Posted February 11, 2010 Share Posted February 11, 2010 Maybe I can add a command for this. It will probably require some funny stuff, like the top-level mesh, the surface, vertex index, and bone index (0-3). Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Niosop Posted February 11, 2010 Share Posted February 11, 2010 If you add it to the SDK could you add it to the LE API as well, pretty please? Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Von04 Posted February 12, 2010 Author Share Posted February 12, 2010 That would be awesome, thanks Josh! Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.