Be careful when using the EntityPitch command. It will return duplicate values at different points of rotation. It's better to use a variable to store the pitch value.
EntityYaw and EntityRoll return useful values, but they may not be the values you expect. I'd recommend experimentation.
EntityPitch, EntityYaw, and EntityRoll can be used as a set to take a snapshot of the total rotational state of an entity, however.
Here's some code that can be used to view the rotational values returned by these commands:-
Const C_CAM_TURN_RATE# = 1.0
Global timer = CreateTimer( 25 )
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()
Global cam = CreateCamera()
CameraZoom cam, 1.6
PositionEntity cam, 15.0, 0.0, 0.0
Global light = CreateLight()
Global cone_x = CreateCone() ; Cone points to X+.
RotateMesh cone_x, 0.0, 0.0, -90.0
UpdateNormals cone_x
HideEntity cone_x
Global cone_y = CreateCone() ; Cone points to Y+.
UpdateNormals cone_y
HideEntity cone_y
Global cone_z = CreateCone() ; Cone points to Z+.
RotateMesh cone_z, 90.0, 0.0, 0.0
UpdateNormals cone_z
HideEntity cone_z
Global cone = cone_z
ShowEntity cone
PointEntity cam, cone
Global axis = 1
While Not KeyHit( 1 )
If KeyHit( 57 )
axis = axis + 1
If axis = 4 Then axis = 1
RotateEntity cone, 0.0, 0.0, 0.0
HideEntity cone
If axis = 1 Then PositionEntity cam, 15.0, 0.0, 0.0 : cone = cone_z
If axis = 2 Then PositionEntity cam, 0.0, 15.0, 0.0 : cone = cone_x
If axis = 3 Then PositionEntity cam, 0.0, 0.0, 15.0 : cone = cone_y
ShowEntity cone
PointEntity cam, cone
EndIf
If axis = 1 Then TurnEntity cone, C_CAM_TURN_RATE#, 0.0, 0.0
If axis = 2 Then TurnEntity cone, 0.0, C_CAM_TURN_RATE#, 0.0
If axis = 3 Then TurnEntity cone, 0.0, 0.0, C_CAM_TURN_RATE#
UpdateWorld
RenderWorld
Color 255, 255, 255
Text 10, 10, "Press SPACE to switch to a new axis of rotation"
If axis = 1
Text 10, 40, "Pitch (X axis): " + EntityPitch( cone )
Text 10, 60, "Viewing from X+"
Text 10, 80, "Cone points to Z+"
EndIf
If axis = 2
Text 10, 40, "Yaw (Y axis): " + EntityYaw( cone )
Text 10, 60, "Viewing from Y+"
Text 10, 80, "Cone points to X+"
EndIf
If axis = 3
Text 10, 40, "Roll (Z axis): " + EntityRoll( cone )
Text 10, 60, "Viewing from Z+"
Text 10, 80, "Cone points to Y+"
EndIf
If axis <> 1
Color 200, 0, 0
; -- Draw X+ axis marker.
CameraProject cam, 5.0, 0.0, 0.0
Text ProjectedX# (), ProjectedY# (), "X+", True, True
;^^^^^^
; -- Draw X- axis marker.
CameraProject cam, -5.0, 0.0, 0.0
Text ProjectedX# (), ProjectedY# (), "X-", True, True
;^^^^^^
EndIf
If axis <> 2
Color 240, 240, 0
; -- Draw Y+ axis marker.
CameraProject cam, 0.0, 5.0, 0.0
Text ProjectedX# (), ProjectedY# (), "Y+", True, True
;^^^^^^
; -- Draw Y- axis marker.
CameraProject cam, 0.0, -5.0, 0.0
Text ProjectedX# (), ProjectedY# (), "Y-", True, True
;^^^^^^
EndIf
If axis <> 3
Color 0, 240, 0
; -- Draw Z+ axis marker.
CameraProject cam, 0.0, 0.0, 5.0
Text ProjectedX# (), ProjectedY# (), "Z+", True, True
;^^^^^^
; -- Draw Z- axis marker.
CameraProject cam, 0.0, 0.0, -5.0
Text ProjectedX# (), ProjectedY# (), "Z-", True, True
;^^^^^^
EndIf
Flip
WaitTimer( timer )
Wend
End