S3DVertex - Pos question

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
DavidR
Posts: 34
Joined: Sat Jul 15, 2006 5:12 pm

S3DVertex - Pos question

Post by DavidR »

What exactly is the vertex position (S3DVertex::Pos) stored relative to?

Initially I assumed this was a fairly simple problem, and that it was stored relative to the position of the node in world space.

However, it appears I'm incorrect. I'm trying to get each vertex of an object, and adjust its Y axis, so its roughly the same as the terrain height underneath it.

I was planning to do something like this:

Code: Select all

f32 h = terrn->getHeight( 	
              node->getPosition().X +currentVertex[vtx].Pos.X  ,
               node->getPosition().Z+currentVertex[vtx].Pos.Z);
But then I found that a lot of the Pos.X's were -75, which means they were clearly not relative to the position of the node, and this caused getHeight() to return invalid answers (since it was outside the terrain).

So, excuse my stupidity if this question is obvious, but what are the vertex positions actually relative to?
CuteAlien
Admin
Posts: 9809
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Usually each vertex is relative to the origin of your model. But basically the origin (pivotpoint) can be set to any point. You do decide that when modeling and exporting your meshes in a tool like Blender or Maya. How you set that depends on on your needs. Typically you either set it to the base of objects or to the center of objects.

Within the game when you use meshes as part of nodes your vertexpositions are all relative to the nodeposition. The nodepositions are relative to the parentnode. To get absolute node positions (in worldcoordinates) you can use getAbsolutePosition.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply