dxSpriteViewMode(sprite%,view_mode%)

Parameters

sprite - sprite handle

view_mode - view_mode of sprite
1: fixed (sprite always faces camera - default)
2: free (sprite is independent of camera)
3: upright1 (sprite always faces camera, but rolls with camera as well, unlike mode no.1)
4: upright2 (sprite always remains upright. Gives a 'billboard' effect. Good for trees, spectators etc.)

Description

Sets the view mode of a sprite.

The view mode determines how a sprite alters its orientation in respect to the camera. This allows the sprite to in some instances give the impression that it is more than two dimensional.

In technical terms, the four sprite modes perform the following changes:

1: Sprite changes its pitch and yaw values to face camera, but doesn't roll.
2: Sprite does not change either its pitch, yaw or roll values.
3: Sprite changes its yaw and pitch to face camera, and changes its roll value to match cameras.
4: Sprite changes its yaw value to face camera, but not its pitch value, and changes its roll value to match cameras.

Note that if you use sprite view mode 2, then because it is independent from the camera, you will only be able to see it from one side unless you use dxEntityFX flag 16 with it to disable backface culling.

See also: dxCreateSprite, LoadSprite.

Example

; dxSpriteViewMode Example
; ----------------------

dxGraphics3D 640,480
dxSetBuffer dxBackBuffer()

pivot=dxCreatePivot()
dxPositionEntity pivot,0,1,0

camera=dxCreateCamera(pivot)
dxPositionEntity camera,0,0,10

light=dxCreateLight()
dxRotateEntity light,90,0,0

plane=dxCreatePlane()
ground_tex=dxLoadTexture("media/Chorme-2.bmp")
dxEntityTexture plane,ground_tex

sprite=LoadSprite("media/b3dlogo.jpg")
dxPositionEntity sprite,0,1,0

pitch=-15
yaw=180
roll=0
view_mode=1
view_mode_info$=" (fixed)"

While Not dxKeyDown(1)

If dxKeyDown(208)=True And pitch<0 Then pitch=pitch+1
If dxKeyDown(200)=True And pitch>-89 Then pitch=pitch-1
If dxKeyDown(205)=True Then yaw=yaw+1
If dxKeyDown(203)=True Then yaw=yaw-1
If dxKeyDown(30)=True Then roll=roll+1
If dxKeyDown(31)=True Then roll=roll-1

; Change sprite view mode depending on key pressed
If dxKeyHit(2)=True Then view_mode=1 : view_mode_info$=" (fixed)"
If dxKeyHit(3)=True Then view_mode=2 : view_mode_info$=" (free)"
If dxKeyHit(4)=True Then view_mode=3 : view_mode_info$=" (upright1)"
If dxKeyHit(5)=True Then view_mode=4 : view_mode_info$=" (upright2)"

; Set sprite view mode
dxSpriteViewMode sprite,view_mode

dxRotateEntity pivot,pitch,yaw,0
dxPointEntity camera,sprite,roll

dxRenderWorld

dxText 0,0,"Use cursor keys to orbit camera around sprite"
dxText 0,20,"Press A and S keys to roll camera"
dxText 0,40,"Press keys 1-4 to change sprite view mode"
dxText 0,60,"dxSpriteViewMode: "+view_mode+view_mode_info$

dxFlip

Wend

End

Index