Terrain Rendering

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Terrain Rendering

Post by Elfinitiy »

Ok so I followed this tutorial http://irrlicht.sourceforge.net/docu/example012.html
and my question is

Code: Select all

camera->setPosition(core::vector3df(2700*2,255*2,2600*2));
How did we get these values ?
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Does it matter?
Those are just camera coordinates, they were probably picked at random, maybe these coordinates put you in the middle of the terrain or something

Don't dig too deep into that kind of stuff
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Post by Elfinitiy »

I know that they put me in the middle.
But how to calculate the middle of the terrain ?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Elfinitiy wrote:But how to calculate the middle of the terrain ?
trial and error !?
move camera around and print camera's position !?
calculate from terrain's position and size !?
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Post by Elfinitiy »

Acki wrote:
Elfinitiy wrote:But how to calculate the middle of the terrain ?
trial and error !?
move camera around and print camera's position !?
calculate from terrain's position and size !?
Thants pretty much the first thing that comes to mind.
But its kinda hard to position in the right spot.
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Post by blAaarg »

"Trial and error?" I hate that! :?

"calculate from terrain's position and size !?"

Interesting! Hmm, let's see if I get this right or should I go to sleep...

from the API:
scale,: The scale factor for the terrain. If you're using a heightmap of size 129x129 and would like your terrain to be 12900x12900 in game units, then use a scale factor of ( core::vector ( 100.0f, 100.0f, 100.0f ). If you use a Y scaling factor of 0.0f, then your terrain will be flat.
The heightmap being used is "terrain-heightmap.bmp" which is 256x256. and we scale it by 40 units in the X, Z direction,
// add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../../media/terrain-heightmap.bmp",
0, // parent node
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(40.f, 4.4f, 40.f), // scale <--here!
video::SColor ( 255, 255, 255, 255 ), // vertexColor
5, // maxLOD
scene::ETPS_17, // patchSize
4 // smoothFactor
);
So the terrain scene node is a bit over 10,000x10,000 units?

Then the camera gets set to a position of:
camera->setPosition(core::vector3df(2700*2,255*2,2600*2));
which would be like x=5400, z=5200 (in reduced terms) which is approximately the middle.

Then, of course, there's the Y value.

Hopefully, I got that right and it's helpful. :)
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Post by Elfinitiy »

Great Answer.
Thank you very much,this is what i needed.
Post Reply