Blitz3D+ Command Reference

RotateEntity entity,pitch#,yaw#,roll#[,global]

Parameters

entity - entity handle

pitch# - angle in degrees of pitch rotation
yaw# - angle in degrees of yaw rotation
roll# - angle in degrees of roll rotation

global (optional) - true to set the orientation in world space rather than relative to a parent entity's orientation; false (default)

Description

Rotates an entity to an absolute orientation.

Pitch is the x angle of an entity - tilting forwards and backwards.
Yaw is the y angle - turning left and right.
Roll is the z angle - tilting left and right.

RotateEntity sets the orientation outright, while TurnEntity adds to the current orientation. Use RotateEntity when you know the exact facing you want (an object driven by stored angles, a camera set to look down 30 degrees); use TurnEntity for continuous spinning and steering. A common pattern drives RotateEntity directly from stored values, e.g. RotateEntity camera,cam_pitch,cam_yaw,0 in a mouselook.

For a child entity the angles are relative to its parent unless you pass true for global.

See also: TurnEntity, PointEntity, EntityPitch, EntityYaw, RotateMesh.

Example

; RotateEntity Example
; --------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,0,-5

light=CreateLight()
RotateEntity light,45,45,0

; A dart to steer
dart=CreateCone(16)
EntityColor dart,255,100,0

pitch#=0
yaw#=0
roll#=0

While Not KeyDown(1)

    ; Cursor keys and Z/X adjust the stored angles
    If KeyDown(208) Then pitch=pitch-1
    If KeyDown(200) Then pitch=pitch+1
    If KeyDown(203) Then yaw=yaw-1
    If KeyDown(205) Then yaw=yaw+1
    If KeyDown(44) Then roll=roll-1
    If KeyDown(45) Then roll=roll+1

    ; RotateEntity sets an ABSOLUTE orientation - the same angles always give
    ; the same pose. Compare TurnEntity, which rotates relative to the
    ; current orientation.
    RotateEntity dart,pitch,yaw,roll

    RenderWorld

    Text 0,0,"Cursors: pitch/yaw   Z/X: roll   Esc: exit"
    Text 0,20,"RotateEntity dart,"+pitch+","+yaw+","+roll

    Flip

Wend

End

Index