Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Game programming question - 3D to 2D formula ?
Message
 
 
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00814964
Message ID:
00818789
Views:
13
Wow, thanks for the visuals! I appreciate your help on the ball size based on the Z axis. Like I had stated, I wasn't even to that point yet as I was trying to figure out a formula for converting the ball's actual X,Y,Z coordinates (i.e. inches) with the SCREEN coordinates of X and Y (i.e. pixels).

A friend of mine gave me some insight with the following code. This is assuming a room like your image, in an 800x600 screen resolution, but would work on other resolutions as well.

Note this is only for the Y location of the ball and does not take into account gravity, friction, etc.

parameters xreal,yreal,zreal
courtdeepreal=479
courthighreal=239
courtwidereal=239
backwallheighthinpixels=200
screenheightinpixels=599
heightbase=(courtdeepreal-zreal)*(backwallheighthinpixels/courtdeepreal)
updownrange=screenheightinpixels-(2*heightbase)
pixely=screenheightinpixels - ( heightbase + ( updownrange * (1-(yreal/courthighreal)) ) )
return pixely

Thanks again!
-Kevin
Kevin Scott
kehvn@carolina.rr.com


Hey! It's not my fault. It's some General named Protection!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform