More Texture Troubles

I’ve got the Ogre XML exporting to work now, but I’m coming up with a slightly different problem than before.



The top surface of the hexagon should have a texture, a 128x128 jpg file, but instead the top surface is always covered in a uniform color. If I change the texture image, the color changes to more or less match that image.



I’m using Blender 2.62



What it looks like in game:

http://i.imgur.com/r1If9.png



The texture I’m using:

http://i.imgur.com/IEsN0.png



Relevant source code…

[java]

public void simpleInitApp()

{

Spatial hex = assetManager.loadModel(“Models/Hex/Test5/Cube.mesh.xml”);

hex.setLocalTranslation(0,0,0);



rootNode.attachChild(hex);



AmbientLight al=new AmbientLight();

al.setColor(new ColorRGBA(1.8f,1.8f,1.8f,1.0f));

rootNode.addLight(al);

}

[/java]



My Mesh…

[xml]<?xml version=“1.0” encoding=“UTF-8”?>

<mesh>

<sharedgeometry vertexcount=“41”>

<vertexbuffer texture_coords=“0” positions=“true” colours_diffuse=“False” normals=“true”>

<vertex>

<position y=“0.883470” x="-0.852118" z="-1.098235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-0.852118" z="-1.098235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-0.852118" z=“0.901765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-0.852118" z=“0.901765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x=“0.013907” z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x=“0.013907” z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-0.852118" z=“0.901765”/>

<normal y=“0.000000” x=“0.500000” z=“0.866026”/>

</vertex>

<vertex>

<position y=“0.883470” x=“0.013907” z=“0.401765”/>

<normal y=“0.000000” x=“0.500000” z=“0.866026”/>

</vertex>

<vertex>

<position y=“1.009799” x=“0.013907” z=“0.401765”/>

<normal y=“0.000000” x=“0.500000” z=“0.866026”/>

</vertex>

<vertex>

<position y=“1.009799” x="-0.852118" z=“0.901765”/>

<normal y=“0.000000” x=“0.500000” z=“0.866026”/>

</vertex>

<vertex>

<position y=“0.883470” x=“0.013907” z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x=“0.013907” z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x=“0.013907” z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x=“0.013907” z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x=“0.013907” z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-0.852118" z="-1.098235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-0.852118" z="-1.098235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x=“0.013907” z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-0.852118" z=“0.901765”/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-0.852118" z=“0.901765”/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-1.718143" z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-1.718143" z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-1.718143" z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-0.852118" z="-1.098235"/>

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

</vertex>

<vertex>

<position y=“0.883470” x="-1.718143" z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-1.718143" z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-0.852118" z="-1.098235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x=“0.013907” z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“1.009799” x=“0.013907” z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-0.848125" z="-0.087213"/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-0.852118" z="-1.098235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-1.718143" z="-0.598235"/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-1.718143" z=“0.401765”/>

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

</vertex>

<vertex>

<position y=“1.009799” x="-0.852118" z=“0.901765”/>

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

</vertex>

</vertexbuffer>

</sharedgeometry>

<submeshes>

<submesh usesharedvertices=“true” material=“Grassy” use32bitindexes=“False”>

<faces count=“14”>

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

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

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

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

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

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

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

<face v1=“8” v2=“3” v3=“9”/>

<face v1=“34” v2=“35” v3=“36”/>

<face v1=“35” v2=“37” v3=“36”/>

<face v1=“38” v2=“36” v3=“37”/>

<face v1=“38” v2=“39” v3=“36”/>

<face v1=“39” v2=“40” v3=“36”/>

<face v1=“34” v2=“36” v3=“40”/>

</faces>

</submesh>

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

<faces count=“12”>

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

<face v1=“10” v2=“12” v3=“13”/>

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

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

<face v1=“18” v2=“19” v3=“20”/>

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

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

<face v1=“22” v2=“24” v3=“25”/>

<face v1=“26” v2=“27” v3=“28”/>

<face v1=“26” v2=“28” v3=“29”/>

<face v1=“30” v2=“31” v3=“32”/>

<face v1=“30” v2=“32” v3=“33”/>

</faces>

</submesh>

</submeshes>

</mesh>[/xml]



My Material

[java]

material missing_material

{

receive_shadows off

technique

{

pass

{

ambient 0.1 0.1 0.1 1.0

diffuse 0.8 0.0 0.0 1.0

specular 0.5 0.5 0.5 1.0 12.5

emissive 0.3 0.3 0.3 1.0

}

}

}



material Grassy

{

receive_shadows on

technique

{

pass

{

cull_hardware none

ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0

diffuse 0.6400000190734865 0.6400000190734865 0.6400000190734865 1.0

specular 0.5 0.5 0.5 1.0 12.5

emissive 0.0 0.0 0.0 1.0

scene_blend one zero

texture_unit

{

texture universe.jpg

tex_address_mode wrap

scale 1.0 1.0

env_map planar

colour_op_ex blend_manual src_current src_texture 0.0

}

}

}

}



material Material

{

receive_shadows on

technique

{

pass

{

cull_hardware none

ambient 0.09189679473638535 0.12606196105480194 0.025478877127170563 1.0

diffuse 0.07351743688460344 0.10084957034661723 0.020383102005468334 1.0

specular 0.5 0.46666666865348816 0.46666666865348816 1.0 12.5

emissive 0.0 0.0 0.0 1.0

scene_blend one zero

}

}

}

[/java]

It looks like the mesh has no texture coordinates so they are all ending up 0,0… so it’s stretching one pixel to the whole hexagon.

How would I fix that?

I don’t really know blender… probably something to do with UV mapping or something.

Have you:

  1. created a material (.j3m) and assigned it to your mesh?
  2. I don’t see the texture in the material code you posted, have you set your texture on that .j3m material?
  3. you will have to UV unwrap your mesh in blender (in edit mode select all faces and hit ‘u’), adjust accordingly



    why do you have 3 materials listed there?

The texture is specified Line 31 of the material. The texture loads. The color of the surface of the hexagon is always of a color very similar to the texture I’ve selected.



The texture is there. It loads the texture. Pspeed is on the right track, I’m just waiting for him to elaborate.



The first material seems to get stuck in by the OgreXML tool by default. The other two are there because there are two materials on the mesh. The surface, which should have a texture, and the edges which are a solid color.

@Sploreg said:
Have you:
1) created a material (.j3m) and assigned it to your mesh?
2) I don't see the texture in the material code you posted, have you set your texture on that .j3m material?
3) you will have to UV unwrap your mesh in blender (in edit mode select all faces and hit 'u'), adjust accordingly

why do you have 3 materials listed there?


To step 1: I'm using a .material file.
To step 2: It's on line 31 of the .material file as per my previous posts.
To step 3: "Adjust accordingly" What do you mean by this? I tried the UV Unwrap and now I just get a pile of errors when I try to export the model.

http://i.imgur.com/9GyaN.png

i even don’t know there is something like “Ogre Texture”. do you have SDK ogre ones? SDK → Tools → OgreXML → Install Blender OgreXML



but hey, you don’t need to set texture in blender, to later set it in JME. use j3m files and apply them via SceneComposer.



in blender: remove all materials/texture, add simple material to model and then try to export. and i hope you made this UV coords properly.

@oxplay2 said:
i even don't know there is something like "Ogre Texture".

but hey, you don't need to set texture in blender, to later set it in JME. use j3m files and apply them via SceneComposer.

in blender: remove all materials/texture, add simple material to model and then try to export. and i hope you made this UV coords properly.


The UV coords are entirely the problem. There are no texture coordinates in the mesh so no amount of material setting is going to fix the problem.

i think he done it, he said:


I tried the UV Unwrap and now I just get a pile of errors when I try to export the model.


i think problem with this errors he have now, is becouse he don't use proper OgreXML exporter OR he done something wrong to blender material.

edit: let's give him tutorial to be sure:

http://www.youtube.com/watch?v=obB9T3jXlak

Thank you for that video!



The materials and textures settings in blender are deceptive. It seemed like I had been setting all of that up though it seemed a little too easy to be true, but I never realized there was a much more complicated process hiding in there.



http://i.imgur.com/01DlZ.jpg

will it be puzzle game?



if not then you don’t make it optimize. you need to make voxel engine like. voxel give only surface faces making better framerate.



something like here:

http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/simple-voxel-engine-starter-kit/

but here are “boxes”, need to make “hexagens” voxel engine.



it’s not so easy to make a “good working” game.