I've been working a bit on importing the cat mother( http://catmother.sourceforge.net/ ) *.gm model files, primarily for three weapons, the baretta, the m16, and the shotgun. I have the baretta in 3ds format, but no uvs... No idea where the 3ds version came from. so I was gonna write a small converter that exports asc files, for later conversion to *.x/*.b3d/*.3ds . So far, I have vertex physical and textural positions. For whatever reason, getting the tris has been the hardest part. I can't seem to get it in.
Here is the source for my importer. I had one version that gathered lots of data etc., but then realized this was more efficient because all you need is the verts,the uvs, and the tris.
You can also download all the source off the catmother website. the model file stuff is in the 'sgu' folder.
Note to anyone who tries to work on this: the readBEint etc. functions are actually to read big-endian integers/floats/shorts. I also made a recursive file string searcher I think is pretty cool( fast etc. ) :)
Once converted, I will of course release the models to the general community as they are very nice/high quality.
Here is the source for my importer. I had one version that gathered lots of data etc., but then realized this was more efficient because all you need is the verts,the uvs, and the tris.
Const view=0 ;0-view vertices in 2d 1-View in 3d(not working) Graphics3D 640,480 ;WireFrame True AppTitle "*.gm loader" Global tempb=CreateBank(4) Global ch[100] g=loadgeometry("m16.gm") ScaleEntity g,10,10,10 Global siz cam=CreateCamera() CameraClsColor cam,255,255,255 PositionEntity cam,0,0,-5 l=CreateLight() While Not KeyHit(1) TurnEntity g,1,1,1 RenderWorld Flip Wend Function loadgeometry(fil$) siz=FileSize(fil$) f=ReadFile(fil$) pdatastart=findstring(f,"points")+6+4 SeekFile f,pdatastart-4 pdataend=readbeint(f)+pdatastart fdatastart=findstring(f,"faces")+5+4 SeekFile f,fdatastart-4 fdataend=readbeint(f)+fdatastart tdatastart=findstring(f,"texcoordlayer")+13+4 DebugLog tdatastart SeekFile f,tdatastart-4 tdataend=readbeint(f)+tdatastart Cls Color 255,255,255 mesh=CreateMesh() surf=CreateSurface(mesh) SeekFile f,pdatastart While FilePos(f)<pdataend If view Then v=AddVertex(surf,readBEfloat(f),readBEfloat(f),readBEfloat(f)) Else x#=readBEfloat(f) y#=readBEfloat(f) z#=readBEfloat(f) Plot x*400+100,y*400+200 Plot x*400+500,z*400+100 Plot y*400+400,z*400+400 EndIf Wend SeekFile f,fdatastart+1 While FilePos(f)<fdataend t=AddTriangle(surf,ReadbeShort(f),ReadbeShort(f),ReadbeShort(f)) Wend SeekFile f,tdatastart v=0 While FilePos(f)<tdataend If view Then VertexTexCoords surf,v,readBEfloat(f),readBEfloat(f) Else Plot readBEfloat(f)*200+200,readBEfloat(f)*200+50 v=v+1 Wend If Not view Then Text 100,0,"top" Text 500,0,"Front" Text 300,0,"UVs: (tex coords)",True Text 300,300,"Side" Flip WaitKey() End EndIf Return mesh End Function Function ReadBEInt(file) PokeByte tempb,3,ReadByte(file) PokeByte tempb,2,ReadByte(file) PokeByte tempb,1,ReadByte(file) PokeByte tempb,0,ReadByte(file) Return PeekInt(tempb,0) End Function Function ReadBEShort(file) PokeByte tempb,1,ReadByte(file) PokeByte tempb,0,ReadByte(file) Return PeekShort(tempb,0) End Function Function ReadBEFloat#(file) PokeByte tempb,3,ReadByte(file) PokeByte tempb,2,ReadByte(file) PokeByte tempb,1,ReadByte(file) PokeByte tempb,0,ReadByte(file) Return PeekFloat#(tempb,0) End Function Function findString(file,tex$) For a=0 To Len(tex$)-1 ch[a]=Asc(Mid$(tex$,a+1,1)) Next bp=FilePos(file) SeekFile file,0 For a=0 To siz-Len(tex$) b=ReadByte(file) If ch[0]=b Then If rec(file,2,Len(tex$)) Then SeekFile file,bp:Return a SeekFile file,a+1 EndIf Next SeekFile file,bp Return 0 End Function Function rec(file,st,en) b=ReadByte(file) If ch[st-1]=b Then If st=en Then Return 1 Else Return rec(file,st+1,en) EndIf Return 0 End FunctionBasically, I would like a little help with this. With the constant view=0, you can see the vertex positions, and uv mapping. I have made a little package with the three model files, their textures, and the C code that imports the meshs. You can get it here: http://www.freewebs.com/botbuilder/catmother.zip (312 KB)
You can also download all the source off the catmother website. the model file stuff is in the 'sgu' folder.
Note to anyone who tries to work on this: the readBEint etc. functions are actually to read big-endian integers/floats/shorts. I also made a recursive file string searcher I think is pretty cool( fast etc. ) :)
Once converted, I will of course release the models to the general community as they are very nice/high quality.
