making a decent terrain

unclepauly

14-08-2006 17:52:50

hi,

can anyone tell me how to make a decent terrain to use with OgreNewt? i know how to make one using a texture.png and a heightmap, but this is no good with OgreNewt, because you cannot attach a collision object to it.

so i must create a terrain using .mesh files and .material files. i can find out how to do this using 3dsmax or something similar, but i have no idea what to do once i have these files!

the OgreNewt demos render terrain using meshes like this:

Ogre::Vector3 size(2.0,0.5,2.0);
Entity* floor;
SceneNode* floornode;
floor = mSceneMgr->createEntity("Floor", "simple_terrain.mesh" );
floornode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "FloorNode" );
floornode->attachObject( floor );
floor->setMaterialName( "Simple/BeachStones" );
floornode->setScale(size);

but this is for simple terrains with one testure. if i wanted a more complicated terrain with say, one base texture, a couple of alpha textures and a road, how would i do this? is there a tool where i can create my terrian and export a .mesh file and a .material file?

lonwolf

14-08-2006 18:02:09

hey there, here the piece of code i use to implement my terrain, its made with 3dsmax8 and its texture with photoshop (mesh and textured) and its colision body is created with TreeColision, hope it helps :wink:
Entity* teren = main_var.mSceneMgr->createEntity( "terenentity", "terenumeu.mesh" );
SceneNode *ts = main_var.mSceneMgr->getRootSceneNode()->createChildSceneNode("tn", Vector3(0,-180,0), Quaternion::IDENTITY);
ts->scale(200,200,200);
ts->attachObject( teren );
ts->setPosition(ts->getPosition()+main_var.pozElem);

OgreNewt::Collision* colDotScenw = new OgreNewt::CollisionPrimitives::TreeCollision( mWorld, ts, true );
OgreNewt::Body* bodDotScenw = new OgreNewt::Body( mWorld, colDotScenw );
delete colDotScenw;
bodDotScenw->attachToNode(ts);
bodDotScenw->setPositionOrientation(ts->getPosition(), ts->getOrientation());


dont mind main_var.pozElem (its just a position vector to set its position far away.. :D )

unclepauly

14-08-2006 18:22:01

hi lonwolf,

thank you very much. i cant see from your code how you are attaching the texture to the mesh - are you just calling setMaterialName? if so, then you must have just one texture file. is this just one texture, or have you created a whole scenery using many textures?

what i am confused about is how to apply my many textures to the terrian mesh, and in the right place. if i had just one texture (say 'grass.jpg') then i can do this easily by calling setMaterialName(grass.jpg).

so does photoshop allows you to create your terrain texture based on your mesh? for example i would like a few hills with an alpha texture in specific places on these hills. photoshop would have to load in the mesh in order for me to put these alpha textures in specific places. i have never used photoshop so im not sure if it can do this.

lonwolf

14-08-2006 19:42:49

hey :) well the code i gave you is to show the easiest way to create some custom terrain colision. If u want advanced texturing you have 2 options: make extremely realistic alpha, and high level textures using a technique called normal mapping using max or just edit some textures and wrap 'em up in a single .jpg file using photoshop and editing it, but Photoshop cant load a mesh and edit acording to the mesh.. its just "by the eye". But 3ds max is well suited for the texturing tehniques u seem to need/want.

Im not very familiar with normal mapping (im a c++ programer in our project) but my 3d designer is looking on the internet in order to learn how to do this properly. I strongly suggest you do the same :D

Nevertheles, the texture ive set has been bounded to the mesh with 3ds max and exported with oFusion in an .material file.. U dont need to reset theyr material (manually using setMaterial()) if uve exported the mesh and material with oFusion.

If u have anymore questions(need help) feel free to ask, im watching this topic :D

unclepauly

14-08-2006 22:13:13

i hope you are still here!

ive been looking into it and it looks like alpha splatting is what i am after. so, i need the .mesh file from my terrain, the .jpg files that are my textures, and a .material file that decribes how the textures are displayed on the mesh.

do you know if 3DSMax can do all this? i do actually have this piece of softwar, but never played with it. at the moment i am using freeworld3d, which is great but doesnt export the mesh :(

thanks for your help

lonwolf

15-08-2006 10:30:37

in my opinion that freeworld 3d stuff is just for texturing and its way more complicated to use for meshes than 3ds max. Heres how i created my own peninsula, with a golf, plains, hills and mountains:

open 3ds max, create a plane with lets say 20 lenght segments and 20 widht segments. After that i converted it into an editable mesh, went in vertex editing, and used a special very nice tool named SoftSelection which is available for each mesh. What does this tool do exactly? Well it selects for you the nearby vertexes (in a circle shape, the radius of this shape can be adjusted) of your selected vertex. And when you try and move upwards your selected vertex, the nearby ones start climbing too and you get a very nice smooth hill :lol:

for more info visit this site in OgreWiki. You can neglect the Heightmap part, it has pictures descibing the method i told you

http://www.ogre3d.org/wiki/index.php/3dsmax_Heightmaps

thats how i learned of soft selection. And the texture i used was just wraped up manualy in one huge one from diferent materials (i used the heightmap from 3ds max that i generated using that tutorial and built the texture manually with copy paste and some edge cuting directly on it :wink: so i can have an ideea where should the texure fit) and afterwards just applied it on my terrain, and export the mesh and material with oFusion.. and created a body with TreeColision

Have fun terrain makin :wink: hope it helps
Edit>> ill be back around 10.30,11.00 GMT :)