Look, I'm really a newbie, so pls help me, but easilly!
That's what I wrote in the KeyDown event of the window:
select case Asc(Key)
case 30 //forward
mSphere.Position.X = Rb3DSpace1.Camera.Position.X
mSphere.Pitch -0.4
Rb3DSpace1.camera.MoveForward 100
case 31 //backwards
mSphere.Position.X = Rb3DSpace1.Camera.Position.X
mSphere.Pitch 0.4
Rb3DSpace1.camera.MoveForward -100
case 28 //left
Rb3DSpace1.camera.Yaw(.1)
case 29 //right
Rb3DSpace1.camera.Yaw(-.1)
end
mSphere.Position.Z = Rb3DSpace1.Camera.Position.Z - 350
Rb3DSpace1.Refresh //draw the new view
TileTerrain //make sure the terrain is in the right place
TileTerrain it's just a method, don't look at it.
mSphere is the ball that rolls on the ground.
What do I have to write? I left the "left" and "right" cases blank,
except for how much the camera has to Yaw.
Thank you
Nick
Il giorno 20/set/05, alle ore 16:39, Joseph J. Strout ha scritto:
At 3:01 PM +0200 9/20/05, Niccolo Zapponi wrote:
I'm trying to make a 3D ball moving into a space where a tile
terrain is.
I made the tile terrain and put a keydown event saying that if up-
arrow is pressed, the ball and the camera go forward of 100.
Same for backwards
But I cannot make it turn left or right because i have no idea on
how to do it!!! The only thing to remember for helping me is that
the camera must always show the ball in the center... (At the
begin the camera Z position is 200 behind the ball position.)
This isn't too hard; use ball.Yaw to make the ball turn left or
right. (Or if you want it to move left or right without turning,
you can just add an appropriate value to its X position.)
To make the camera maintain a constant position relative to the
ball, you can just call ball.ObjectToWorldTransform. Pass in a
ball-relative position like <0,0,-100>, and it will give you back
that same position in world coordinates, which is where you want to
set the camera.
Also check out the Rb3D FAQ, which has some functions you may find
handy like PointObjectAt (which you can use to make the camera look
at the ball no matter where they are). <http://www.strout.net/info/
coding/rb/>
Sounds like a neat app! Please keep us posted on your progress.
Best,
- Joe
--
Joe Strout REAL Software, Inc.
Vote for REALbasic (twice!) in the LinuxWorld Reader's Choice Awards:
http://linux.sys-con.com/general/readerschoice.htm
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|