Results 1 to 6 of 6

Thread: [RESOLVED] Converting 2d to 3d

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    Resolved [RESOLVED] Converting 2d to 3d

    This is my current code for a 2d movement of a ship:

    Ship.Velocity.x = Ship.msngSpeed * System.Math.Sin(Ship.msngHeading)
    Ship.Velocity.y = Ship.msngSpeed * System.Math.Cos(Ship.msngHeading)

    Ship.Acceleration.x = Ship.ACCEL * System.Math.Sin(Ship.msngFacing)
    Ship.Acceleration.y = Ship.ACCEL * System.Math.Cos(Ship.msngFacing)

    sngXComp = Ship.Velocity.x + Ship.Acceleration.x
    sngYComp = Ship.Velocity.y + Ship.Acceleration.y

    Ship.msngSpeed = System.Math.Sqrt(sngXComp ^ 2 + sngYComp ^ 2)
    If Ship.msngSpeed > Ship.MAXSPEED Then Ship.msngSpeed = Ship.MAXSPEED

    If sngYComp > 0 Then Ship.msngHeading = System.Math.Atan(sngXComp / sngYComp)
    If sngYComp < 0 Then Ship.msngHeading = System.Math.Atan(sngXComp / sngYComp) + PI

    Ship.msngX = Ship.msngX + Ship.Velocity.x
    Ship.msngY = Ship.msngY - Ship.Velocity.y
    I am wanting to move this to a 3d world.

    I presume that I change the .y additions to .z

    This is my current turning code:
    Code:
            If Inp.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_LEFT) = True Then
                Ship.msngFacing = Ship.msngFacing - Ship.ROTATION_RATE * PI / 180
            End If
            If Inp.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_RIGHT) = True Then
                Ship.msngFacing = Ship.msngFacing + Ship.ROTATION_RATE * PI / 180
            End If
    I need to change the Ship.msngFacing (and the Ship.msngHeading I presume) to be a 3d coordinate for the direction of the 3d ship. Can I please have some help with this?

    Canning
    Last edited by Simon Canning; Oct 27th, 2011 at 10:59 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width