At 9:01 PM +0200 9/20/05, Niccolo Zapponi wrote:
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
Hmm, I don't quite follow your logic here, even for the forward/back
case. You're moving the sphere to the camera position, then pitching
it (to make it roll, I would guess), and then moving the camera. Why
not just move the ball?
Similarly, for the left/right case, you should yaw the ball, not the
camera. Then subsequently calling MoveForward on the ball will move
it in a new direction, which I assume is what you want.
To make the camera follow the ball, remove any reference to it from
your Select Case above, then add this below:
Dim v As New Vector3D(0, 0, -100)
Rb3DSpace1.camera.Position = mSphere.ObjectToWorldTransform(z)
which positions the camera a constant 100 units behind the ball, as I
was suggesting here:
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, in case you haven't done it yet, I hope you'll forgive me
repeating this recommendation:
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/>
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>
|