Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Absolute Position and Collision Check

dipendra
Guest
Quote
2014-05-23 04:01:03

How do we get absolute position of a scene node in coppercube using external javascript.

I am trying to move Camera1 from pos1 to pos2. For this I did the DFS and found a path but now I want to check if taking a step results in collision or not with any node.
For this I am using -

for(var i=0; i<count; i++)
{
var child = ccbGetChildSceneNode(root, i);
if(child!=null)
{
var box = child.getTransformedBoundingBox();//getBoundingBox();
for(var k=0; k < ngbr.length;k++)
{
if(box!=null && box.isPointInside(ngbr[k]))
{
return false;
}
}
}
}
return true;

What confuses me is that my camera is rubbing against a counter but still bounding box gives me false. Also when I tried to find a position of the two node i.e. the counter and Camera I got some large numbers even though they were next to each other. Camera and Counter are child of the top scene node. I assume I am getting wrong numbers of position. I am usng -

ccbSetSceneNodeProperty(ccbGetSceneNodeFromName("Camera1"), "Position", pos.x, pos.y, pos.z);


dipendra
Guest
Quote
2014-05-23 08:39:54

I believe the core question is why in -

var child = ccbGetSceneNodeFromName("counter");
var box = child.getTransformedBoundingBox();

var x = child.getAbsolutePosition();
var y = box.getCenter();

are x and y way different?


niko
Moderator
Quote
2014-05-23 09:34:31

Not sure if that the the source to your problem. Maybe it is a bug somewhere else, for example, what is ngbr?

For the second quesion: The position of a node is basically the pivot of a node. Sometimes this might be the same as the center of its bounding box, but probably in most cases, it isn't. It depends on the transformation (rotation, scale etc) of your node, and as well how it was modelled by the 3d artist. The position might also be for example the top left position, or even totally outside of the 3d geometry. It is where the movement tools in coppercube are drawn when the node is selected.

So that's why both positions aren't the same.
You can center the pivot point in CopperCube by right clicking your mesh -> modify selection -> center pivot point.

Hope this clears it up a bit.


dipendra
Guest
Quote
2014-06-04 08:36:03

Sorry for my late reply.
Niko that was spot on, I found that the bounding box was offset. However I solved this problem by assuming a certain blocking radius from the center of this box. It was kind of hacky but it worked.


niko
Moderator
Quote
2014-06-04 19:46:56

Ah, nice to hear that it worked.


Robo
Guest
Quote
2021-01-09 00:57:27

I also found the bounding box is offset.

I can't add cool functionality to my game because of this problem - like opening a door as CC still finds the old bounding box along with the new one....so cannot access anything in between the wall and the door....like in a fridge for example.

any suggestions ?


veganpete
Registered User
Quote
2021-01-21 09:52:11

If you're certain that the bounding box is off-set, could you use a "parent" as the offset collision bounding-box and a "child" as a counter-offset visual object, (Kind of how a rifle get's zeroed on a range).

Sorry for not explaining properly - ie: try to compensate for the offset, rather than break your balls in trying to find a way to correct it?


Create reply:


Posted by: (you are not logged in)


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


Text:

 

  

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


   






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