Hi,
This is seemingly simple but just wont work for me!
I'm using:
selectedSceneNode = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
to find which node is selected. Once I have this node, I can apply properties to it, but how can I retrieve existing properties?
Say I have two teams, Team 1 and Team 2 and I need to find out which team the node belongs to. Obviously I could make lists and iterate through them, but this seems inefficient.
I have tried assigning names to the scenenodes, and then using:
selectedSceneNode->getName() == NAME
but this always returns false.
I have tried creating a parent node for each team and then creating all units for each team as children, and then using getParent(), but again, no luck.
Anyone got any ideas?, because I'm pretty stumped at the moment.
Thanks
Ben
Identifying scene nodes from getSceneNodeFromCameraBB(cam)
Unfortunately I'm using the ID already for a different purpose.
I just tried iterating through a list, and its not as bad as I expected... especially after including as many conditions as possible to make it do as little work as possible.
However this issue is one that I'm definitely going to encounter again in writing this game, so any improved solution is more than welcome.
I just tried iterating through a list, and its not as bad as I expected... especially after including as many conditions as possible to make it do as little work as possible.
However this issue is one that I'm definitely going to encounter again in writing this game, so any improved solution is more than welcome.
ok, then lets find whats the problem with the getName
as i tried, it returned the value what i expected. i think you have problem with the statement.
this one works for me with the collision example
as i tried, it returned the value what i expected. i think you have problem with the statement.
Code: Select all
if (selectedSceneNode->getName() == NAME)
{
printf("shouldnt find anything\n");
}
// it just compare the pointers of the chars (since its c8*), not the characters in the string
// so you have to use the strcmp function
if (!strcmp(selectedSceneNode->getName() == NAME)
{
printf("found my node! yey! \n");
}
Ahhhh many thanks!
I knew it would be something simple! I'm fairly new to programming.
I used the same concept but implemented it slightly differently;
because this way I could (if I need to) store more information in the name, by using the substring function to only look at the appropriate part of it! (ie the first nine characters in this case.)
This solves all my problems in this respect!
Thanks!
I knew it would be something simple! I'm fairly new to programming.
I used the same concept but implemented it slightly differently;
Code: Select all
stringc P1 = "PLAYERONE";
stringc P2 = "PLAYERTWO";
stringc NAME = selectedSceneNode->getName();
if (NAME == P1)
{
//...etc
This solves all my problems in this respect!
Thanks!