Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Game programming question - 3D to 2D formula ?
Message
From
06/08/2003 11:09:03
 
 
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00814964
Message ID:
00817329
Views:
20
Kevin, I made a quick image www.cyberjetx.com/downloads/ballroom.jpg for a visual representation of what I was saying. As you can see animation is rather involved. However, once you have the basic algorithms in a group [read the engine] you can modify any number of the aspects of the scene. I hope this helps.

Joe.

>Kevin,
> Use x and y as they are. Decide how big your ball is when it is as close as possible to the user iDiaNear. Then decide how big the ball is when it is farthest away iDiaFar. Use Z as a multiplier for the ball diameter...
>
>eg if;
>max value for your Z is 480 [zmax]. ' Max room depth
>iDiaFar is 22. ' Diameter of the ball at the farthest point
>iDiaNear is 64. ' Diameter of the ball at the Nearest point
>Z = 240 then ' Current Z of th ball
>iBallDia = 38 ' Current diameter of the ball
>
>iBallDia = (iDiaNear - (iDiaFar*2+1)) / (z/zmax) ' Your diameter formula
>' ** iDiaFar*2+1 allows for a size freedom.
>
> The meat of this is to ignore z regarding placement. Z only regards perception. Use the formula above and you are all set. This all assumes your user cannot enter the room. If he can you need to figure his Z and subtract it from Z so perceptions are maintained. ;}
>
>Lastly, DirectX will handle this for you quite well, I tech edited DirectX 8 and Visual Basic Developement by Keith Sink. SAMS publishing 0-672-32225-0
>
>HTH,
>Joe
>
>>Hello everyone!
>>
>>I am wrestling with a problem that I was wondering if anyone might have an answer to...
>>
>>I am trying to write a formula for a ball bouncing in a room.
>>
>>The values I feel necessary are...
>>
>>Ball_X, Ball_Y, Ball_Z (current location of ball in 3Dimensional room.)
>>Screen_ball_X, Screen_ball_Y (actual location of ball on screen)
>>
>>Assuming room is 20 ft high, 20 ft wide, and 40 feet long (or perhaps better to say 240 by 240 by 480 inches) how would I transpose this three dimensional model into a two dimensional visual representation on the screen.
>>
>>I also recognize I need variables such as gravity, resistance (eg. ball rolling on floor), velocity and direction but right now I am just trying to figure out a simple formula for translating 3D ballX, BallY, and BallZ to 2D BallX and BallY.
>>
>>Any thoughts would be greatly appreciated!
>>
>>Thanks!
~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
Next
Reply
Map
View

Click here to load this message in the networking platform