Sign in to follow this  
SimoensS

Ball can't roll straight in perspective

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this