Blender 2.5 and + blender2orge trying to get UVs correct on a cube

Using Blender and this exporter blender2ogre. Im trying to do something really simple

I have a cube uv mapped to have 6 sides. I have a uv image that looks like a cross and represents the 6 sides of the box.



Im trying to make a simple DICE out of the box



If I render the image in blender it looks find the dots line up on the correct sides of the object





But when I load model into jme3 it doesnt put the texture in the correct place. It seems like the UV is flipped

[java]

Spatial cube = assetManager.loadModel(“Models/Cube.mesh.xml”);

material = new Material(assetManager,

“Common/MatDefs/Misc/ColoredTextured.j3md”);

material.setTexture(“ColorMap”,

assetManager.loadTexture(“Textures/Dice.tga”));

[/java]



Any Ideas?

Well given your suspicion, did you try flipping the image? You should be able to do that in jMP, right-click the image and press “Edit Texture”.

Can you show what’s in your mesh.xml file?

I’ve been fiddling a lot with blender 2.5 and blender2ogre, and one way I managed to get it working is by rearranging file schema a lot.

Also, have you tried loading it in jMP?

I tried loading the Cube.mesh.xml in JMP but I dont really know how to use it.

I can see a red cube.

I dont know how to set a texture on a mesh.







Blender Render







Inside JME3



Cube.mesh.xml

[xml]

<mesh>

<sharedgeometry vertexcount=“24”>

<vertexbuffer normals=“true” positions=“true” texture_coords=“1”>

<vertex>

<position x="-1.000000" y="-1.000000" z=“1.000000”/>

<normal x="-0.000000" y="-1.000000" z=“0.000000”/>

<texcoord u=“0.500000” v=“0.500000”/>

</vertex>

<vertex>

<position x="-1.000000" y="-1.000000" z="-1.000000"/>

<normal x="-0.000000" y="-1.000000" z=“0.000000”/>

<texcoord u=“0.500000” v=“0.250000”/>

</vertex>

<vertex>

<position x=“1.000000” y="-1.000000" z="-1.000000"/>

<normal x="-0.000000" y="-1.000000" z=“0.000000”/>

<texcoord u=“0.250000” v=“0.250000”/>

</vertex>

<vertex>

<position x=“1.000000” y="-1.000000" z=“1.000000”/>

<normal x="-0.000000" y="-1.000000" z=“0.000000”/>

<texcoord u=“0.250000” v=“0.500000”/>

</vertex>

<vertex>

<position x="-1.000000" y=“1.000000” z=“0.999999”/>

<normal x="-0.000000" y=“1.000000” z=“0.000000”/>

<texcoord u=“0.500000” v=“0.750000”/>

</vertex>

<vertex>

<position x="-0.999999" y=“1.000000” z="-1.000001"/>

<normal x="-0.000000" y=“1.000000” z=“0.000000”/>

<texcoord u=“0.500000” v=“1.000000”/>

</vertex>

<vertex>

<position x=“1.000000” y=“1.000000” z="-1.000000"/>

<normal x="-0.000000" y=“1.000000” z=“0.000000”/>

<texcoord u=“0.250000” v=“1.000000”/>

</vertex>

<vertex>

<position x=“1.000000” y=“1.000000” z=“1.000000”/>

<normal x="-0.000000" y=“1.000000” z=“0.000000”/>

<texcoord u=“0.250000” v=“0.750000”/>

</vertex>

<vertex>

<position x="-1.000000" y="-1.000000" z=“1.000000”/>

<normal x="-1.000000" y=“0.000000” z=“0.000000”/>

<texcoord u=“0.500000” v=“0.500000”/>

</vertex>

<vertex>

<position x="-1.000000" y="-1.000000" z=“1.000000”/>

<normal x="-0.000000" y=“0.000000” z=“1.000000”/>

<texcoord u=“0.500000” v=“0.500000”/>

</vertex>

<vertex>

<position x=“1.000000” y="-1.000000" z=“1.000000”/>

<normal x="-0.000000" y=“0.000000” z=“1.000000”/>

<texcoord u=“0.250000” v=“0.500000”/>

</vertex>

<vertex>

<position x=“1.000000” y="-1.000000" z=“1.000000”/>

<normal x=“1.000000” y=“0.000000” z=“0.000000”/>

<texcoord u=“0.250000” v=“0.500000”/>

</vertex>

<vertex>

<position x=“1.000000” y="-1.000000" z="-1.000000"/>

<normal x=“1.000000” y=“0.000000” z=“0.000000”/>

<texcoord u=“0.000000” v=“0.500000”/>

</vertex>

<vertex>

<position x=“1.000000” y="-1.000000" z="-1.000000"/>

<normal x="-0.000000" y=“0.000000” z="-1.000000"/>

<texcoord u=“0.250000” v=“0.250000”/>

</vertex>

<vertex>

<position x="-1.000000" y="-1.000000" z="-1.000000"/>

<normal x="-0.000000" y=“0.000000” z="-1.000000"/>

<texcoord u=“0.500000” v=“0.250000”/>

</vertex>

<vertex>

<position x="-1.000000" y="-1.000000" z="-1.000000"/>

<normal x="-1.000000" y=“0.000000” z=“0.000000”/>

<texcoord u=“0.750000” v=“0.499999”/>

</vertex>

<vertex>

<position x="-0.999999" y=“1.000000” z="-1.000001"/>

<normal x="-0.000000" y=“0.000000” z="-1.000000"/>

<texcoord u=“0.500000” v=“0.000000”/>

</vertex>

<vertex>

<position x="-0.999999" y=“1.000000” z="-1.000001"/>

<normal x="-1.000000" y=“0.000000” z=“0.000000”/>

<texcoord u=“0.750000” v=“0.750000”/>

</vertex>

<vertex>

<position x="-1.000000" y=“1.000000” z=“0.999999”/>

<normal x="-1.000000" y=“0.000000” z=“0.000000”/>

<texcoord u=“0.500000” v=“0.750000”/>

</vertex>

<vertex>

<position x=“1.000000” y=“1.000000” z="-1.000000"/>

<normal x="-0.000000" y=“0.000000” z="-1.000000"/>

<texcoord u=“0.250000” v=“0.000000”/>

</vertex>

<vertex>

<position x=“1.000000” y=“1.000000” z="-1.000000"/>

<normal x=“1.000000” y=“0.000000” z=“0.000000”/>

<texcoord u=“0.000000” v=“0.750000”/>

</vertex>

<vertex>

<position x=“1.000000” y=“1.000000” z=“1.000000”/>

<normal x=“1.000000” y=“0.000000” z=“0.000000”/>

<texcoord u=“0.250000” v=“0.750000”/>

</vertex>

<vertex>

<position x=“1.000000” y=“1.000000” z=“1.000000”/>

<normal x="-0.000000" y=“0.000000” z=“1.000000”/>

<texcoord u=“0.250000” v=“0.750000”/>

</vertex>

<vertex>

<position x="-1.000000" y=“1.000000” z=“0.999999”/>

<normal x="-0.000000" y=“0.000000” z=“1.000000”/>

<texcoord u=“0.500000” v=“0.750000”/>

</vertex>

</vertexbuffer>

</sharedgeometry>

<submeshes>

<submesh material=“Material” usesharedvertices=“true”>

<faces count=“12”>

<face v1=“0” v2=“1” v3=“2”/>

<face v1=“0” v2=“2” v3=“3”/>

<face v1=“4” v2=“7” v3=“6”/>

<face v1=“4” v2=“6” v3=“5”/>

<face v1=“8” v2=“18” v3=“17”/>

<face v1=“8” v2=“17” v3=“15”/>

<face v1=“14” v2=“16” v3=“19”/>

<face v1=“14” v2=“19” v3=“13”/>

<face v1=“12” v2=“20” v3=“21”/>

<face v1=“12” v2=“21” v3=“11”/>

<face v1=“23” v2=“9” v3=“10”/>

<face v1=“23” v2=“10” v3=“22”/>

</faces>

</submesh>

</submeshes>

</mesh>



[/xml]

Try rearranging your XML schema of the mesh file to look like this

[java]

<mesh>

<submeshes>

<submesh>

<faces>

<face>

<face/>

</faces>

<geometry>

<vertexbuffer>

<vertex>

</vertex>

</vertexbuffer>

</geometry>

</submesh>

</submeshes>

</mesh>

[/java]



And set usesharedvertices=“false”.



Also, try flipping your normals in blender and export again.

Looks like you’re doing some collision detection with your object as well. Is that working out fine for you?

Flipping the actual Image Vertically Made the Mesh Texture Correctly in JME. This doesnt seem like a good solution to me.

Does anyone know if there is a setting on the exporter to flip the UVs?



BTW Collision is working Great in JME.

Guys guys guys…

There’s no need to modify the XML file.

It seems the exporter for blender might be exporting with flipped UVs, in that case just open the image in an editor and flip it vertically.

The reason I suggested to modify XML file was because that was the only way it started working for me (both import and collision detection).

Since there’s no documentation on xml schema format and accepted entries for mesh files (or scene and materials file formats, for that matter), I just converted it to conform with town example.

Didn’t have the flipped uvs problem when exporting though.

cephei said:
Didn't have the flipped uvs problem when exporting though.

Often times people dont recognize they work with inverted normals in blender because blender renders two sided.

Yeah, that was part of the reason I suggested flipping normals and exporting from blender again.

Yeah I made sure my Normals where pointing out.

I also found a parameter to not render double sided

and I tried converting quads to tris before exporting

all gave me same flipped result.