realbasic-games
[Top] [All Lists]

Re: 3D Ball

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: 3D Ball
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Tue, 20 Sep 2005 13:23:32 -0600
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <CD020872-E096-4573-95F2-38F1773C77B5 at nosrelo dot it> <a06200709bf55cf14c4d2 at [10 dot 0 dot 1 dot 4]> <9E9C131A-BEB0-4383-A268-52DC3AC9ECAF at nosrelo dot it>
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>

<Prev in Thread] Current Thread [Next in Thread>