Rotate
From MaratisWiki
(Difference between revisions)
(Created page with "Rotates the object. The first 3 zeros are X,Y,Z values and the last is the angle. To increase rotating speed, put higher value at angle. Example 1 : Continuous rotation ...") |
Dahnielson (Talk | contribs) m |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{lua-function|rotate|object, vector, angle, local}} | |
− | To increase rotating speed, put higher value at angle. | + | Rotates the object. The first 3 zeros are X,Y,Z values and the last is the angle. The "local" argument is optional (local coordinates), without it the transformation is global (global coordinates). To increase rotating speed, put higher value at angle. |
− | Example 1 : Continuous rotation | + | {{lua-function-param|object|object to operate on}} |
+ | {{lua-function-param|vector|vector}} | ||
+ | {{lua-function-param|angle|angle}} | ||
+ | {{lua-function-param|local|local}} | ||
+ | |||
+ | '''Example 1:''' Continuous rotation | ||
object = getObject("object") | object = getObject("object") | ||
Line 11: | Line 16: | ||
end | end | ||
− | Example 2 : Rotation on key press (Space) | + | '''Example 2:''' Rotation on key press (Space) |
object = getObject("object") | object = getObject("object") | ||
Line 18: | Line 23: | ||
if isKeyPressed("SPACE") then rotate(object, {0, 0, 1}, 1, "local") end | if isKeyPressed("SPACE") then rotate(object, {0, 0, 1}, 1, "local") end | ||
end | end | ||
+ | |||
+ | [[Category:Lua scripting]] | ||
+ | [[Category:Lua function]] | ||
+ | [[Category:Transformation]] |
Latest revision as of 00:17, 9 February 2014
rotate(object, vector, angle, local)
Rotates the object. The first 3 zeros are X,Y,Z values and the last is the angle. The "local" argument is optional (local coordinates), without it the transformation is global (global coordinates). To increase rotating speed, put higher value at angle.
-
object
: object to operate on -
vector
: vector -
angle
: angle -
local
: local
Example 1: Continuous rotation
object = getObject("object") -- Scene update function onSceneUpdate() rotate(object, {0, 0, 1}, 1, "local") end
Example 2: Rotation on key press (Space)
object = getObject("object") -- Scene update function onSceneUpdate() if isKeyPressed("SPACE") then rotate(object, {0, 0, 1}, 1, "local") end end