i'm having trouble projecting a simple movement of a ball for a pong-style game from 2d to 3d. the code i'm currently using simply stretches the movement along the axis so that a 2d rectangle (the turf) becomes a parallelogram in 3d. but that does not make for perspectivical distortion (i want the far side of the turf to be shorter than the close side). i really have no clue how to do this cos deflection angles would have to be adjusted also.
this is the relevant passage of code
you need to actually treat the movement as if it was in the 3 dimensions and so have x, y & z coordinates and then in flash we will create a fake 3d environment
becuase flash has its origin it isnt really suited to this so set an xCenter and yCenter such that they are flash's equivalent
i.e on a 800x600 movie
code:
xCenter = 400
yCenter = 300
select a focal length for your 3d decption, i have found that 100 is generally the best - this is at what depth you want your lens to be focused as if it was a camera
therefore when the z coordinate is 0 you will have everything at its original size and increasing z decreases the size and vice versa
code:
_xscale = _yscale = scale*100 //shrinks or englardes the object
as all measurements are stretched, so too is the distance from the center. therefore you need to create scaled versions of the x and y coordinates for this particular z value and then add them on to the center which is the vanishing point
Basically, this pong game is a 2d game. Usually we design our game 2d and plot the result onto a 3d model view. I think, it is more difficult to design a model 3d and then plot it 2d.
Here is how we plot 3d view.
Those constants are difficult to "solve". I just pick values to match your board as close as possible.
I remove many elements in the movie. It contains only the necessary part for demonstration.
that is f*****g awesome!! thank you so much!
you absolutly ROCK. i was about to abandon the idea cos i thought it was too complicated. you are the man!