Jump to content
  • Advertisement
Sign in to follow this  

Spherical Mapping problem

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

Hi, I use following to convert Cartesian to Spherical system to generate texture coordinats for my sphere model, but error on some parts. Can someone help? Image 1: sphereMapping01.jpg Image 2: sphereMapping02.jpg procedure Cartesian2Spherical(const dx,dy,dz:GLFloat; var scRad, scPhi, scTheta:Glfloat); begin scRad:=sqrt(dx*dx + dy*dy + dz*dz); if (dy>0.0) then scPhi:=ArcCos(dy/scRad) else scPhi:=PI-ArcCos(-dy/scRad); if (dx=0.0) and (dz>0.0) then scTheta:=PIdiv2; if (dx=0.0) and (dz<0.0) then scTheta:=PI+PIdiv2; if (dx>0.0) and (dz=0.0) then scTheta:=0.0; if (dx<0.0) and (dz=0.0) then scTheta:=PI; if (dx<>0.0) and (dy<>0.0) then begin if (dx>0.0) and (dz>0.0) then ang :=0.0; if (dx<0.0) and (dz>0.0) then ang :=PI; if (dx<0.0) and (dz<0.0) then ang :=PI; if (dx>0.0) and (dz<0.0) then ang :=PI2; scTheta:=ArcTan(dz/dx)+ang; end; end; texturecoord.s := scTheta / _2PI; texturecoord.t := (PI-scPhi) / PI; Thanks a lot, Daniel

Share this post

Link to post
Share on other sites
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!