ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperLicht
forum topic indicator get current position of a object and change it
person icon
rej
Registered User
Quote
2014-02-26 08:04:09

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

person icon
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;


person icon
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?

person icon
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:










 

  

Possible 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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |