Jump to content
  • Advertisement
Sign in to follow this  
SimoensS

Ball can't roll straight in perspective

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

I am trying to make a soccer game, faking 3D. My ball object has an x, y and z property wich I can influence by speedX/Y/Z, wind and gravity All the physics work just fine and when I plot the ball out in 2D spaces showing Top, Front or Side view the result is just as wanted. The perspective used in the game looks like this : http://www.simoenss.be/perspectiveproblem/problemImg1.jpg When moving the ball I calculate the speed for x/y and z like this : speedX = (targetX - currentX)/framecount same for y and z speeds now when I move the ball, all the values are correct, I can verify that by watching my 2D views But on the perspective view the ball seems to curve when a straight line is expected. Like this : http://www.simoenss.be/perspectiveproblem/problemImg2.jpg To show the ball on screen I need to translate the x, y and z positions of the ball to the normal x and y position flash can handle. It is this translation that must be wrong. What is the correct way to translate these x, y and z positions to x and y positions with this kind of perspective?

Share this post


Link to post
Share on other sites
Advertisement
I don't know what axes you have x, y, and z assigned to. It looks like you might be mixing 2 axes up, subtracting from x to compensate for height when you should presumably be subtracting from y. What is your existing formula for calculating the position? (Your speed formula is irrelevant here - only the position matters.)

You could use a proper projection transform for this, although if I were doing this myself I'd probably just use linear interpolation to find the position perpendicular to the ground and then add an offset based on height, again linearly interpolated to simulate perspective.

Share this post


Link to post
Share on other sites
Hey Kylotan,

Is it possible he is seeing a "fish bowl" effect like how in many games, things kinda distort as they go to the edge of the screen?

Share this post


Link to post
Share on other sites
Maybe the linear interpolation is the problem. Maybe the OP is calculating the up direction (on screen) with a simple linear interpolation, instead of the perspective division/logarithmic thingy.

[Edited by - szecs on April 30, 2010 10:39:04 AM]

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!