ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperLicht
get current position of a object and change it
Author Text

rej
Registered User
Quote
2014-02-26 08:04:09

How to find the current position of a object and change it?


niko
Moderator
Quote
2014-02-26 08:14:08

If you have your object, which is usually a sub class of SceneNode (http://www.ambiera.com/copperlic...), then use its .Pos property. It's the position relative to its parent, but in most cases, this should be enough, since most objects are directly in the root, usually. To create a message box with the position, do for example this:

alert( yourNode.Pos );

For changing for example the .x position, do this:

yourNode.Pos.X += 10.0;



rej
Registered User
Quote
2014-02-26 10:33:47

Thanks for your reply. I am using Coppercube. When i use

alert( yourNode.Pos );
, It shows undefined. But when I use

var s=ccbGetSceneNodeFromName(j);
var position = ccbGetSceneNodeProperty(s, "Position");
alert(position);

It shows an output
How can I get the x,y,z from it and add a value to each of it?


niko
Moderator
Quote
2014-02-26 12:42:08

Ah, you posted this into the CopperLicht forum, so I assumed you are using the CopperLicht API. The calls you are using, all starting with ccb, are the CopperCube JavaScript calls. But you can use them as well.
Changing a position there works similar:


var s=ccbGetSceneNodeFromName("name of your object");
var position = ccbGetSceneNodeProperty(s, "Position");

position.x += 10;

// now set the modified position into the objects position again:
ccbSetSceneNodeProperty(s, "Position", position);



Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.