[RESOLVED] Converting 2d to 3d
This is my current code for a 2d movement of a ship:
Quote:
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