Jump to content
  • Advertisement
Sign in to follow this  
cedricmobile

How to tansform normal and vertices to World Space?

This topic is 4214 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

Here are the variables we will need to backface cull in Object Space. Code: //the Camera Position World Space. cam_z cam_y cam_z //the Objects Orientation matrix. (ie final rotational state) objM //the position of the object in World Space. obj_x obj_y obj_z //a point on the plane/face that is being culled. (Object Space)face_x face_y face_z //the plane/face normal (calculated in Object Space once at start-up) face_norm_x face_norm_y face_norm_z Now for doing the calcs. Code: //first the Camera Object displacement (vector from camera to object) var Dx = obj_x - cam_x; var Dy = obj_y - cam_y; var Dz = obj_z - cam_z; // rotate the camera into Object Space (use the inverse of the displacement and the object Matrix) var newCamx = -Dx * objM.xx + -Dy * objM.xy + -Dz * objM.xz; var newCamy = -Dx * objM.yx + -Dy * objM.yy + -Dz * objM.yz; var newCamz = -Dx * objM.zx + -Dy * objM.zy + -Dz * objM.zz; //now get a vector from the plane/face to the camera var fx=newCamx - face_x; var fy=newCamy - face_y; var fz=newCamz - face_z; //and finally do the backface culling (take the dot product) if((fx*face_norm_x + fy*face_norm_y + fz*face_norm_z) >0) { //face is visible and NOT backface culled} I want to know how can I get the followings: cam_z cam_y cam_z objM obj_x obj_y obj_z is cam_z cam_y cam_z = Camera direction in camera space can be transformed to world coordinate space by multiplying transpose of model view matrix ? How to get objM then? abd how about obj_x obj_y obj_z ? Please help, thanks.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!