Jump to content
  • Advertisement
Sign in to follow this  
dan59314

Spherical Mapping problem

This topic is 4296 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
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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!