Structure of a .mesh file

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
GoldenSunEmperor
Gnoblar
Posts: 9
Joined: Tue Jan 31, 2012 2:21 am

Structure of a .mesh file

Post by GoldenSunEmperor » Thu Jul 26, 2012 2:20 am

Hi,

I'm building my own program which has a list of all vertices used for a 3d object. I would like to put this list into a .mesh file via code. For that, I need to know the exact structure of a .mesh file including headers and how/where data is saved. Does this information exist? Where can I find it?

- Kevat
0 x

bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia

Re: Structure of a .mesh file

Post by bstone » Thu Jul 26, 2012 6:09 am

Consider generating XML output and using OgreXmlConverter to convert it to a valid .mesh file. The XML format is well documented here: Ogre meshxml DTD. Otherwise OgreMeshSerializerImpl.cpp is where you should look for details on the binary specification.
0 x

GoldenSunEmperor
Gnoblar
Posts: 9
Joined: Tue Jan 31, 2012 2:21 am

Re: Structure of a .mesh file

Post by GoldenSunEmperor » Thu Jul 26, 2012 8:57 pm

Well, that escalated quickly...;) The XML DTD was exactly what I was looking for, but I was hoping there would be a simple way to do this. I've got a 3d array of colors where each position in the array represents a point in space. I'll have to look through the definitions of each of these elements to find which ones fit best. I've got a few other questions I hope you don't mind answering:

1. Do you know which elements would work best? This would save me some time/reading.
2. Where do I find the definitions/structures for these elements? I have a feeling that I probably need to do a lot of low-level reading to understand these (in which case, where should I start?)
3. Are there any example .mesh.xml files for me to look at? I'd like to see it rendered in Ogre vs. the structure to reconfirm my understanding of it.

Thanks for your help, this is a great starting point. I found a couple of links to XML DTD in google, but those didn't work. I'm glad you got the right one.
0 x

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7152
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 19

Re: Structure of a .mesh file

Post by Kojack » Fri Jul 27, 2012 6:16 am

Do you want this data stored in a .mesh file on disk, or do you just want to render it directly?
If it's the latter, the ManualObject class lets you very easily build in code a list of points, lines or triangles (with uv's, colour, normals, etc).

Are there any example .mesh.xml files for me to look at? I'd like to see it rendered in Ogre vs. the structure to reconfirm my understanding of it.
Here's the xml of ogre's default cube mesh:

Code: Select all

<mesh>
    <submeshes>
        <submesh material="BaseWhite" usesharedvertices="false" use32bitindexes="false" operationtype="triangle_list">
            <faces count="12">
                <face v1="0" v2="1" v3="2" />
                <face v1="2" v2="3" v3="0" />
                <face v1="4" v2="5" v3="6" />
                <face v1="6" v2="7" v3="4" />
                <face v1="8" v2="9" v3="10" />
                <face v1="10" v2="11" v3="8" />
                <face v1="12" v2="13" v3="14" />
                <face v1="14" v2="15" v3="12" />
                <face v1="16" v2="17" v3="18" />
                <face v1="18" v2="19" v3="16" />
                <face v1="20" v2="21" v3="22" />
                <face v1="22" v2="23" v3="20" />
            </faces>
            <geometry vertexcount="24">
                <vertexbuffer positions="true" normals="true" texture_coord_dimensions_0="float2" texture_coords="1">
                    <vertex>
                        <position x="-50" y="-50" z="50" />
                        <normal x="0" y="-1" z="0" />
                        <texcoord u="1" v="1" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="-50" z="-50" />
                        <normal x="0" y="-1" z="0" />
                        <texcoord u="1" v="0" />
                    </vertex>
                    <vertex>
                        <position x="50" y="-50" z="-50" />
                        <normal x="0" y="-1" z="0" />
                        <texcoord u="0" v="0" />
                    </vertex>
                    <vertex>
                        <position x="50" y="-50" z="50" />
                        <normal x="0" y="-1" z="0" />
                        <texcoord u="0" v="1" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="50" z="50" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="0" v="1" />
                    </vertex>
                    <vertex>
                        <position x="50" y="50" z="50" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="1" v="1" />
                    </vertex>
                    <vertex>
                        <position x="50" y="50" z="-50" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="1" v="0" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="50" z="-50" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="0" v="0" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="-50" z="50" />
                        <normal x="0" y="0" z="1" />
                        <texcoord u="0" v="1" />
                    </vertex>
                    <vertex>
                        <position x="50" y="-50" z="50" />
                        <normal x="0" y="0" z="1" />
                        <texcoord u="1" v="1" />
                    </vertex>
                    <vertex>
                        <position x="50" y="50" z="50" />
                        <normal x="0" y="0" z="1" />
                        <texcoord u="1" v="0" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="50" z="50" />
                        <normal x="0" y="0" z="1" />
                        <texcoord u="0" v="0" />
                    </vertex>
                    <vertex>
                        <position x="50" y="-50" z="50" />
                        <normal x="1" y="0" z="0" />
                        <texcoord u="0" v="1" />
                    </vertex>
                    <vertex>
                        <position x="50" y="-50" z="-50" />
                        <normal x="1" y="0" z="0" />
                        <texcoord u="1" v="1" />
                    </vertex>
                    <vertex>
                        <position x="50" y="50" z="-50" />
                        <normal x="1" y="0" z="0" />
                        <texcoord u="1" v="0" />
                    </vertex>
                    <vertex>
                        <position x="50" y="50" z="50" />
                        <normal x="1" y="0" z="0" />
                        <texcoord u="0" v="0" />
                    </vertex>
                    <vertex>
                        <position x="50" y="-50" z="-50" />
                        <normal x="0" y="0" z="-1" />
                        <texcoord u="0" v="1" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="-50" z="-50" />
                        <normal x="0" y="0" z="-1" />
                        <texcoord u="1" v="1" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="50" z="-50" />
                        <normal x="0" y="0" z="-1" />
                        <texcoord u="1" v="0" />
                    </vertex>
                    <vertex>
                        <position x="50" y="50" z="-50" />
                        <normal x="0" y="0" z="-1" />
                        <texcoord u="0" v="0" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="-50" z="-50" />
                        <normal x="-1" y="0" z="0" />
                        <texcoord u="0" v="1" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="-50" z="50" />
                        <normal x="-1" y="0" z="0" />
                        <texcoord u="1" v="1" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="50" z="50" />
                        <normal x="-1" y="0" z="0" />
                        <texcoord u="1" v="0" />
                    </vertex>
                    <vertex>
                        <position x="-50" y="50" z="-50" />
                        <normal x="-1" y="0" z="0" />
                        <texcoord u="0" v="0" />
                    </vertex>
                </vertexbuffer>
            </geometry>
        </submesh>
    </submeshes>
    <submeshnames>
        <submeshname name="submesh0" index="0" />
    </submeshnames>
</mesh>
0 x

Post Reply