Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
identifying nodes

brian
Guest
Quote
2024-11-30 16:42:25

I am writing a first person game that requires the player to identify a node (using proximity).
Is the anyway a node can be identified in this condition.?


guest_Guru
Guest
Quote
2024-11-30 16:52:45

You can check for the property "Type" for a node it will give you the node type, you need to write the javascript code for it.


bob
Guest
Quote
2024-11-30 17:59:56

well if the on proximity is on the node you want to identify you can probably use something like

ccbGetSceneNodeProperty(ccbGetCurrentNode(), "Name");

check the js api


brian
Guest
Quote
2024-11-30 23:23:19

thanks for the help.
Unfortunately the snippet of code returns the name camera 1 (the current active camera )
i need to identify the node the camera is close to.
thanks anyway, I'll keep trying


guest
Guest
Quote
2024-12-01 02:44:14

here's a bit of code that demonstrates how to tell if the camera is beside something:
var nodes = ["cubeMesh1", "sphereMesh1", "cylinderMesh1"];
var cam = ccbGetActiveCamera();

ccbRegisterOnFrameEvent(function() {
var nearObject = false;

for (var i = 0; i < nodes.length; i++) {
var nodePos = ccbGetSceneNodeProperty(ccbGetSceneNodeFromName(nodes[i]), "Position");
var camPos = ccbGetSceneNodeProperty(cam, "Position");
var distance = getDistance(nodePos.x, nodePos.y, nodePos.z, camPos.x, camPos.y, camPos.z);

if (distance < 30) {
print("near to: " + nodes[i]);
nearObject = true;
break;
}
}

if (!nearObject) {
print("near to: nothing");
}
});

function getDistance(x1, y1, z1, x2, y2, z2) {
var dx = x2 - x1;
var dy = y2 - y1;
var dz = z2 - z1;

return Math.sqrt(dx * dx + dy * dy + dz * dz);
}



guest
Guest
Quote
2024-12-01 02:49:56

uhhh that distance check should be if distance <= 30 but you get the idea.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (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