Heightmap and 3D models?

Hello i’m using at the moment a 3D model as a terrain (exported with ogre xml ) , i wanted to know if it’s possible to texturate like this :



[java]

mat_terrain = new Material(assetManager, “Common/MatDefs/Terrain/Terrain.j3md”);



mat_terrain.setTexture(“m_Alpha”, assetManager.loadTexture(“Textures/Terrain/alphatest.png”));



Texture grass = assetManager.loadTexture(“Textures/Terrain/herbe512p.jpg”);

grass.setWrap(WrapMode.Repeat);

mat_terrain.setTexture(“m_Tex1”, grass);

mat_terrain.setFloat(“m_Tex1Scale”, 64f);



Texture dirt = assetManager.loadTexture(“Textures/Terrain/splat/dirt.jpg”);

dirt.setWrap(WrapMode.Repeat);

mat_terrain.setTexture(“m_Tex2”, dirt);

mat_terrain.setFloat(“m_Tex2Scale”, 32f);



Texture rock = assetManager.loadTexture(“Textures/Terrain/chemin512p.jpg”);

rock.setWrap(WrapMode.Repeat);

mat_terrain.setTexture(“m_Tex3”, rock);

mat_terrain.setFloat(“m_Tex3Scale”, 128f);

[/java]



but on the 3D model , if yes can you please tell me how ?



Thanks

Yes, just apply that material to the terrain “terrainModel.setMaterial(mat_terrain)”. Of course there have to be proper texture coordinates in your model.

mhh…model.setMaterial(mat_terrain) does not work?





EDIT : rhaaa, Normen the mind reader…

normen said:
Yes, just apply that material to the terrain "terrainModel.setMaterial(mat_terrain)". Of course there have to be proper texture coordinates in your model.


Thanks a lot for that quick reply , what do you mean by proper texture coordinates ? is that meaning i have to do an UV mapping ?

Because i wanted to use the alphamap ( that was used for hello terrain ) to texturate , is that possible ?

I dont know exactly how the texture coordinates are layed out in the terrain system, I guess one Quad is 1x1 so a UV map that covers the whole terrain should be ok… Just try around…

i don’t know what to try since UV map means texturing the model , that i don’t want since i want to use the code i posted earlier.



Or do you mean by UV map the alphamap i can design ? if yes i wonder how to do that . If no , how do you set coordinates ?

…just try myModel.setMaterial(mat_terrain); how does it look?

it looks like that the texture is applied but strangely , since it’s very smally and appears only in a corner and repeated a few times :



http://img413.imageshack.us/img413/6246/screenfornormen.png



My alpha.png is 512 x512 , does my model has to be on the same dimension ?

danath said:
My alpha.png is 512 x512 , does my model has to be on the same dimension ?

No, mapping coordinates are normalized from 0 to 1.
I think the issue is that you don't have proper UV coordinates on your model.
You can create UV in 2 clicks in blender if your model is not so complex. Select you model go to edit mode, hit 'A' twice, hit the U key and choose UV unwrap.

Then re-export your model to ogre and see if that's better

thanks , do i have to texturate into the UV map in blender ?



Edit : thank you it’s working now !