Vertex position in world space?

Started by
1 comment, last by Uffe Hammer 24 years, 8 months ago
The way I recommend getting world coordinates is to load a second copy of your geometry and transform it to world space once just after you load it. The vx,vy,vz fields of the vertex data structures hold the world coordinates. You need to have a camera set up before you transform like this:

for (seg = 0; seg < object->num_segments;
seg++)
object->segment_list[seg].flags |=
FLAG_ALWAYS_VISIBLE;

/* Transform the objec to world space */
PR_MatrixIdentity (PR_ViewMatrix);
PR_TransformEntity (ent);

/* Restore the transformation to camera
space */
PR_SetActiveCamera (camera);


If you only want one copy of the object and don't need to store the world coordinates every frame, remember to reset the flags so bounding box culling can be used:
for (seg = 0; seg < object->num_segments;
seg++)
object->segment_list[seg].flags &=
~FLAG_ALWAYS_VISIBLE;

This is the proper way to get world coordinates which are correct for any hierarchy.

Author of Power Render (http:/www.powerrender.com)
Advertisement

I'm trying to use collision detection between a sphere and several vertex points in a tunnel, however when i try to calculate the vertex point's position in world space, i get a result that is very close to, however not close enough, the calcs i'm using is roughly this:
object->face_list->vertext1.x + Entity->segment_orientation->location.x + Entity->orientation.location.x

for every face in the segment, and since i have first found the segment where the ship is located in the tunnel, the amount of calculations is very small, however it needs to be on vertex level, since the ship is moving through the object tunnel.

Thanks!
As far as i can see it worked perfectly, now i will try to make a generalized Collision detection routine, which should work on polygon level.

This topic is closed to new replies.

Advertisement