GetPosition

From MaratisWiki
(Difference between revisions)
Jump to: navigation, search
m
m
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
{{lua-function|getPosition|object}}
 +
 
Get the current object position in 3d space.
 
Get the current object position in 3d space.
  
objectpos = getPosition(object)
+
{{lua-function-param|object|object to operate on}}
 +
 
 +
  objectpos = getPosition(object)
  
 
Then you can use your object coordinates like this :
 
Then you can use your object coordinates like this :
  
objectpos[1] : X position  
+
* '''objectpos[1]:''' X position  
 
+
* '''objectpos[2]:''' Y position  
objectpos[2] : Y position  
+
* '''objectpos[3]:''' Z position
 
+
objectpos[3] : Z position
+
 
 
Example 1, Press Space to display the X position of the object in maratis
+
'''Example 1:''' Press Space to display the X position of the object in Maratis console window.
console window :
+
  
 
     object = getObject("object")  
 
     object = getObject("object")  
Line 21: Line 22:
 
     end
 
     end
  
See setPosition(object) func. for a more advanced usage [[http://wiki.maratis3d.org/index.php?title=SetPosition]]
+
See [[SetPosition|setPosition(object)]] function for a more advanced usage.
 +
 
 +
[[Category:Lua scripting]]
 +
[[Category:Lua function]]
 +
[[Category:Transformation]]

Latest revision as of 00:18, 9 February 2014

getPosition(object)

Get the current object position in 3d space.

  • object : object to operate on
 objectpos = getPosition(object)

Then you can use your object coordinates like this :

  • objectpos[1]: X position
  • objectpos[2]: Y position
  • objectpos[3]: Z position

Example 1: Press Space to display the X position of the object in Maratis console window.

   object = getObject("object") 
   -- Scene update
   function onSceneUpdate()
       objectpos = getPosition(object) -- you can rename objectpos whatever you want
       if isKeyPressed("SPACE") then print(objectpos[1]) end
   end

See setPosition(object) function for a more advanced usage.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox