Animated Mesh and getSceneNodefromCoordinatesBB

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ColeZero
Posts: 20
Joined: Wed Jul 27, 2005 2:33 pm

Animated Mesh and getSceneNodefromCoordinatesBB

Post by ColeZero »

here is the question:

i add a Node and use the getSceneNodefrom....-method to get the scene node.
for checking which scenenode is selected, i'am using:

if(selectedScenenOde == SampleNode)
.....


But if i add the same node twice or more the if-statement doesn't work anymore.

for example.

Code: Select all

int i = 0;
while(i<10)
{
  Node = SceneManager->addANimatedMeshSceneNode(Mesh);
  Node->setPostion(...);
 ...
 i++;
}

selectedNode = ColMgr->getSceneNodeFromCordinatesBB(mousePos);

if(selectedNode == Node)
..
...

Well the problem is, the if-statement isn't working, so the Node must have changed or it isn't working because the Node is added twice.

How could i get it to work?
I don't want to add the node ten times per hand.[/code]
Guest

Post by Guest »

Please, can anyone help me.
The idea is, like a RTS-Game.
You produce a unit and klick on it.
i need help...
Guest

Post by Guest »

ok i see, either no one will help or no one can't help me.
Maybe i find another solution in the next days,
Guest

Post by Guest »

it works for me, so you do something wrong. i give you some code:

Code: Select all

ISceneNode* getMousePickingNode()
{
	ISceneNode* Node;
	Node = CollisionManager->getSceneNodeFromScreenCoordinatesBB(
	CursorControl->getPosition(), 0);

	if(Node == 0){return 0;}
	else{return Node;}
}
just call it like this:
//call getMousePickingNode everytime you do a mouseclick, it will then return the node under the mouse cursor. if there is no node under the mousecursor, it will return always 0.
ISceneNode* node = getMousePickingNode();

//which will mean, if there is no node under the cursor when you execute the command above, node is 0.
you could then do something like this:

Code: Select all

//if node is 0, the app will crash, so thats why we check if the node exist 
if(node)
{
// display a window with entity statistics (you have to code it yourself, just an example, syntax is "setEntityWindow(ISceneNode* Node, bool visible)") 
yourguifunction->setEntityWindow(node, true);
}
you get what i mean?

and if you do not want to create the nodes yourself, do it like this:

Code: Select all

//this is called an array 
IAnimatedMeshSceneNode* nodes[10];

for(int x = 0; x < 10; ++x)
{
nodes[x] = SceneManager->addAnimatedMeshSceneNode(yourmesh);
nodes[x]->setPosition(vector3df(0.0f*x, 0.0f*x, 0.0f*x));
}

i hope this could help :)
Guest

Post by Guest »

mmmh strange, but sounds logical.
i'll try it.
thx
Post Reply