Creating Models

Just starting out? Need help? Post your questions and find answers here.
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Creating Models

Post by LJ »

The Purebasic documents say: "Loads a new #Mesh from the disk. Mesh has to be in the OGRE .mesh format. To create or convert existing meshes into this format, some exporters exist (Milkshape, Lightwave, 3DS Max). More informations can be found directly on the OGRE website."

This is incorrect. No exporter exists for Milkshape (and don't argue with me about Milkshape, I've downloaded everything and installed it where it needs to be and the exporter doesn't work. Check your Milkshape.log file and you can see that it attempts to load the exporter.dll and then fails.)

Fred, is there anyway you can tweak the OGRE .dll engine to allow for the .x format and the .3ds format? Those who are making the OGRE 3D engine have made a serious mistake in not allowing these 2 model formats to be loaded into OGRE. Any serious 3D engine can at least load these models. Is there any way you can add these without trying to convince the OGRE project they should? Just sorta leave them in the dust on this 3D engine for Purebasic?
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

This is incorrect. No exporter exists for Milkshape (and don't argue with me about Milkshape...
8O

download this:
http://www.garyw.uklinux.net/3D/OgreMil ... porter.zip

copy all *.dll's into your Milkshape folder and then start Milkshape.

No exporter? tsk tsk! :)

I would love to see a more reliable exporter written though, this one crashes sometimes.

@Fred: Any chance of adding more formats to OGRE? or rewarding us with a *.x to *.mesh convertor?
--Kale

Image
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

If it still doesn't work you might want to copy the dll's (from the exporter) to your windows\system directory.. (can't exactly remember their names, but it was something like "devil.dll" or something..)

-Lars

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Hmmm

Post by LJ »

Hmmm... the only thing that did was add the OGRE export option to Milkshape. I tried making a simple cube and exporting it as a .mesh file and Milkshape crashed and the .mesh file was not exported.

I re-booted my computer and using brute force tactics ;) I managed to export what I thought was a cube.mesh file (about 1K), but Purebasic was unable to read and kept giving the error "Terminate!" from C++ library.

Worse, if you open the .mesh file with notepad, it's not like the .x format where you can see the vertices data.

Basically, the most promising avenue at this time seems to be the file called MeshManual.pb which shows how to create a .mesh file by reading in data statements. We may be able to write a .mesh editor that exports these data statements. These data statements look alot like a .x file that you open with notepad. For example, this is the data of a cube.mesh file from the MeshManual file:

Code: Select all

 CubeVertices:
    Data.f 0, 0, 0 ; Vertex index 0
    Data.f 1, 0, 0 ; Vertex index 1
    Data.f 1, 0, 1 ; Vertex index 2
    Data.f 0, 0, 1 ; Vertex index 3

    Data.f 0, 1, 0 ; Vertex index 4 - Note: exactly the same as above, but with 'y'
    Data.f 1, 1, 0 ; Vertex index 5
    Data.f 1, 1, 1 ; Vertex index 6
    Data.f 0, 1, 1 ; Vertex index 7

  CubeFacesIndexes:
    Data.w 0, 1, 2 ; bottom face (clockwise as it's reversed...)
    Data.w 2, 3, 0 
    Data.w 6, 5, 4 ; top face
    Data.w 4, 7, 6
    Data.w 1, 5, 6 ; right face
    Data.w 6, 2, 1
    Data.w 7, 4, 0 ; left face
    Data.w 0, 3, 7
    Data.w 5, 1, 0 ; back face
    Data.w 0, 4, 5
    Data.w 2, 6, 7 ; front face
    Data.w 7, 3, 2

  CubeTextureCoordinates:
    Data.f 0   , 0.33 ; Vertex 0
    Data.f 0.33, 0.33 ; Vertex 1
    Data.f 0.33, 0    ; Vertex 2
    Data.f 0,    0    ; Vertex 3

    Data.f 0.66, 1    ; Vertex 4
    Data.f 1,    1    ; Vertex 5
    Data.f 1,    0.66 ; Vertex 6
    Data.f 0.66, 0.66 ; Vertex 7
And here is the data of a cube.x:

Code: Select all

xof 0303txt 0032
template XSkinMeshHeader {
 <3cf169ce-ff7c-44ab-93c0-f78f62d172e2>
 WORD nMaxSkinWeightsPerVertex;
 WORD nMaxSkinWeightsPerFace;
 WORD nBones;
}

template VertexDuplicationIndices {
<b8d65549-d7c9-4995-89cf-53a9a8b031e3>
 DWORD nIndices;
 DWORD nOriginalVertices;
 array DWORD indices[nIndices];
}

template SkinWeights {
 <6f0d123b-bad2-4167-a0d0-80224f25fabb>
 STRING transformNodeName;
 DWORD nWeights;
 array DWORD vertexIndices[nWeights];
 array FLOAT weights[nWeights];
 Matrix4x4 matrixOffset;
}


Frame Scene_Root {


 FrameTransformMatrix {
  1.000000, 0.000000, 0.000000, 0.000000,
  0.000000, 1.000000, 0.000000, 0.000000,
  0.000000, 0.000000, 1.000000, 0.000000,
  0.000000, 0.000000, 0.000000, 1.000000;;
 }

  Frame Box01 {

   FrameTransformMatrix {
    1.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 1.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 1.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 1.000000;;
   }

   Mesh {
    24;
    -0.700000;1.125000;-1.300000;,
    -0.700000;-1.475000;-1.300000;,
    1.725000;1.125000;-1.300000;,
    1.725000;-1.475000;-1.300000;,
    1.725000;1.125000;-1.300000;,
    1.725000;-1.475000;-1.300000;,
    1.725000;1.125000;1.300000;,
    1.725000;-1.475000;1.300000;,
    1.725000;1.125000;1.300000;,
    1.725000;-1.475000;1.300000;,
    -0.700000;1.125000;1.300000;,
    -0.700000;-1.475000;1.300000;,
    -0.700000;1.125000;1.300000;,
    -0.700000;-1.475000;1.300000;,
    -0.700000;1.125000;-1.300000;,
    -0.700000;-1.475000;-1.300000;,
    -0.700000;1.125000;-1.300000;,
    1.725000;1.125000;-1.300000;,
    -0.700000;-1.475000;-1.300000;,
    1.725000;-1.475000;-1.300000;,
    -0.700000;1.125000;1.300000;,
    1.725000;1.125000;1.300000;,
    -0.700000;-1.475000;1.300000;,
    1.725000;-1.475000;1.300000;;
    12;
    3;0,2,1;,
    3;1,2,3;,
    3;4,6,5;,
    3;5,6,7;,
    3;8,10,9;,
    3;9,10,11;,
    3;12,14,13;,
    3;13,14,15;,
    3;20,21,16;,
    3;16,21,17;,
    3;18,19,22;,
    3;22,19,23;;

    MeshNormals {
     24;
     0.000000;0.000000;-1.000000;,
     0.000000;0.000000;-1.000000;,
     0.000000;0.000000;-1.000000;,
     0.000000;0.000000;-1.000000;,
     1.000000;0.000000;0.000000;,
     1.000000;0.000000;0.000000;,
     1.000000;0.000000;0.000000;,
     1.000000;0.000000;0.000000;,
     0.000000;0.000000;1.000000;,
     0.000000;0.000000;1.000000;,
     0.000000;0.000000;1.000000;,
     0.000000;0.000000;1.000000;,
     -1.000000;0.000000;0.000000;,
     -1.000000;0.000000;0.000000;,
     -1.000000;0.000000;0.000000;,
     -1.000000;0.000000;0.000000;,
     0.000000;1.000000;0.000000;,
     0.000000;1.000000;0.000000;,
     0.000000;-1.000000;0.000000;,
     0.000000;-1.000000;0.000000;,
     0.000000;1.000000;0.000000;,
     0.000000;1.000000;0.000000;,
     0.000000;-1.000000;0.000000;,
     0.000000;-1.000000;0.000000;;
     12;
     3;0,2,1;,
     3;1,2,3;,
     3;4,6,5;,
     3;5,6,7;,
     3;8,10,9;,
     3;9,10,11;,
     3;12,14,13;,
     3;13,14,15;,
     3;20,21,16;,
     3;16,21,17;,
     3;18,19,22;,
     3;22,19,23;;
    }

    VertexDuplicationIndices {
     24;
     20;
     0,
     1,
     2,
     3,
     4,
     5,
     6,
     7,
     8,
     9,
     10,
     11,
     12,
     13,
     14,
     15,
     16,
     17,
     18,
     19,
     12,
     6,
     13,
     7;
    }

   }
 }
 }
}

Look at the Mesh Normals section above, it's practically identical to the Purebasic code, here are both the sections: first Purebasic:

Code: Select all

    Data.w 0, 1, 2 ; bottom face (clockwise as it's reversed...)
    Data.w 2, 3, 0 
    Data.w 6, 5, 4 ; top face
    Data.w 4, 7, 6
    Data.w 1, 5, 6 ; right face
    Data.w 6, 2, 1
    Data.w 7, 4, 0 ; left face
    Data.w 0, 3, 7
    Data.w 5, 1, 0 ; back face
    Data.w 0, 4, 5
    Data.w 2, 6, 7 ; front face
    Data.w 7, 3, 2

And now the .x code:

Code: Select all

     3;0,2,1;,
     3;1,2,3;,
     3;4,6,5;,
     3;5,6,7;,
     3;8,10,9;,
     3;9,10,11;,
     3;12,14,13;,
     3;13,14,15;,
     3;20,21,16;,
     3;16,21,17;,
     3;18,19,22;,
     3;22,19,23;;
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

The 3ds exporter work fine!

Unfortunatly it takes about 4 steps to convert an object... Ther is no direct saving in mesh format :(
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

?

Post by LJ »

Almost all the exporting features in Milkshape work fine except for the OGRE one.

There is a way to directly save your .mesh data, hard coded data statements. See Game Programming forum .MESH Editor.
Post Reply