Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Game programming question - 3D to 2D formula ?
Message
From
12/08/2003 11:59:36
 
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00814964
Message ID:
00819416
Views:
15
Glad that helped.
Joe.

>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
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Reply
Map
View

Click here to load this message in the networking platform