RotateTexture texture,angle#
Parameters
|
texture - texture handle angle# - rotation angle, in degrees |
Description
|
Rotates a texture over whatever it is painted on. The angle is absolute rather than a relative turn, so RotateTexture tex,45 always leaves the texture at 45 degrees no matter what it was before. Wind the angle up a little each frame for swirling smoke, spinning portals, vortices and hypnotic energy shields. Rotation happens about the texture origin rather than about the middle of the face, so a rotating tiled texture also appears to sweep across the surface. That is usually what you want for effects; when it is not, combine it with PositionTexture to shift where the swirl is centred. As with the other texture transforms, this affects the texture handle and therefore every surface painted with it. See also: PositionTexture, ScaleTexture, TextureCoords, EntityTexture. |
Example
; RotateTexture Example ; --------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() RotateEntity light,45,45,0 ; A crate whose texture we will spin crate=CreateCube() PositionEntity crate,0,0,5 tex=LoadTexture("media/b3dlogo.jpg") EntityTexture crate,tex angle#=0 spin#=1.0 While Not KeyDown(1) ; Press + / - to change how fast the texture spins If KeyDown(13) Then spin=spin+0.05 If KeyDown(12) Then spin=spin-0.05 ; Rotate the texture to an absolute angle, updated every frame angle=angle+spin RotateTexture tex,angle ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"+ / - : spin speed Arrows: camera Esc: exit" Text 0,20,"RotateTexture tex,"+angle Flip Wend End
Index