Archived

This topic is now archived and is closed to further replies.

Vertex position in world space?

This topic is 6694 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites