Ball can't roll straight in perspective

Started by
3 comments, last by SimoensS 13 years, 11 months ago
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?
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.
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?
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]
Thanks for the reply, I'll see into it

This topic is closed to new replies.

Advertisement