Clone node ?
-
yellowdude42
- Posts: 10
- Joined: Sat Jun 19, 2010 6:55 pm
Clone node ?
Hi everybody,
how i can clone a node and give a name to it ?
Because i have one mesh, i want a create many node to duplique it and for each one do what i want.
For example :
-the first jump and second move left and the other walk etc etc etc..
its possible with irrlicht ?
With irr::scene::ISceneNode::cloneMembers(ISceneNode *toCopyFrom, ISceneManager *newManager)?
I really don't know how to do that :S
how i can clone a node and give a name to it ?
Because i have one mesh, i want a create many node to duplique it and for each one do what i want.
For example :
-the first jump and second move left and the other walk etc etc etc..
its possible with irrlicht ?
With irr::scene::ISceneNode::cloneMembers(ISceneNode *toCopyFrom, ISceneManager *newManager)?
I really don't know how to do that :S
-
yellowdude42
- Posts: 10
- Joined: Sat Jun 19, 2010 6:55 pm
Cool 
but i have this :
and he show me error :
error: invalid conversion from `irr::scene::ISceneNode*' to irr::scene::IAnimatedMeshSceneNode*'
but i have this :
Code: Select all
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
scene::IAnimatedMeshSceneNode* toto = modelNode->clone();error: invalid conversion from `irr::scene::ISceneNode*' to irr::scene::IAnimatedMeshSceneNode*'
do this
Code: Select all
scene::ISceneNode* toto = modelNode->clone();-
yellowdude42
- Posts: 10
- Joined: Sat Jun 19, 2010 6:55 pm
yeah thx a lot
its work but i have a last question 
I have this :
But i want to give a name for each node where duplicate with coordonate.
For example :
does it work ? or how i can do this ? please :s
I have this :
Code: Select all
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
scene::ISceneNode* toto = modelNode->clone();
For example :
Code: Select all
x = 5;
y = 9;
name = "my_new_node";
name = "my_new_node_x_y";
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
scene::ISceneNode* name = modelNode->clone();
no, this won't work !!!yellowdude42 wrote:does it work ? or how i can do this ? please :sCode: Select all
x = 5; y = 9; name = "my_new_node"; name = "my_new_node_x_y"; scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2"); scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh); scene::ISceneNode* name = modelNode->clone();
but how about using an 2 dimensional array, maybe like this:
Code: Select all
scene::ISceneNode* name[10][10];
x = 5;
y = 9;
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
name[x][y] = modelNode->clone();while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
yellowdude42
- Posts: 10
- Joined: Sat Jun 19, 2010 6:55 pm
Oh cool good idea 
But if i do function like that :
How i could use any name[x][y] when i want ?
Save in struct or its in the scene manager ? :S i really dunno
But if i do function like that :
Code: Select all
ISceneNode *clone_node(int x, int y)
{
scene::ISceneNode* name[10][10];
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
name[x][y] = modelNode->clone();
return (name[x][y]);
}
Save in struct or its in the scene manager ? :S i really dunno
well, this function is bad, because the array is only temporaly (local) created and deleted when leaving the function !!! 
there are several ways to solve this:
1st make the array global, so you can access it from anywhere...
2nd another approach would be to set the name of the node(s) and get them later by their names...later you can use this to get the node:
but I realy wonder why you do it this way, you're creating 2 scene nodes every time this function is called and using only the cloned one !?!?! 
you can use the created one directly and forget about the cloned one:
there are several ways to solve this:
1st make the array global, so you can access it from anywhere...
2nd another approach would be to set the name of the node(s) and get them later by their names...
Code: Select all
ISceneNode *clone_node(int x, int y)
{
stringc name = "name";
name += x;
name += ",";
name += y;
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
scene::ISceneNode* node = modelNode->clone();
node->setName(name);
return (node);
} Code: Select all
stringc name = "name";
name += x;
name += ",";
name += y;
scene::ISceneNode* node = smgr->getSceneNodeFromName(name);you can use the created one directly and forget about the cloned one:
Code: Select all
ISceneNode *clone_node(int x, int y)
{
stringc name = "name";
name += x;
name += ",";
name += y;
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh);
modelNode->setName(name);
return (modelNode);
} while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
yellowdude42
- Posts: 10
- Joined: Sat Jun 19, 2010 6:55 pm
hmm, in fact i have a map.
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
In each [] i have 7 ressources generate randomly.
So i don't want to getMesh all time.. :O
That why i need to clone it and when a player get one, my server game send me (for example) in case x y the ressource GOLD appear, or disappear.
so i need to save any node and iuse it when i want..
But i don't know how to create ressource, do clone and saving (i don't know where) and use to setVisible(false) or true.. :s
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
[][][][][][][][][]
In each [] i have 7 ressources generate randomly.
So i don't want to getMesh all time.. :O
That why i need to clone it and when a player get one, my server game send me (for example) in case x y the ressource GOLD appear, or disappear.
so i need to save any node and iuse it when i want..
But i don't know how to create ressource, do clone and saving (i don't know where) and use to setVisible(false) or true.. :s
why not ???yellowdude42 wrote:So i don't want to getMesh all time.. :O
you're using it now all the time in this function !!!
and let's say you call this function 100 times (map of 10x10 entries) you now get 200 nodes !!!
100 created (with addAnimatedMeshSceneNode) and 100 cloned nodes !!!
Last edited by Acki on Sun Jun 20, 2010 4:35 pm, edited 1 time in total.
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
no, it doesn't, the mesh will be loaded only one time !!!yellowdude42 wrote:because it get many memoryand lag :/
the way you do it now is a waste of memory (see my previous reply I edited) !!!
I guess you should start with something much easier and get some C/C++ books or tutorials !!!Acki wrote:and let's say you call this function 100 times (map of 10x10 entries) you now get 200 nodes !!!
100 created (with addAnimatedMeshSceneNode) and 100 cloned nodes !!!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
yellowdude42
- Posts: 10
- Joined: Sat Jun 19, 2010 6:55 pm
you don't know nothing about such basics and got a school project for a server/client project !?!?!yellowdude42 wrote:That why i need to clone it and when a player get one, my server game send me (for example) in case x y the ressource GOLD appear, or disappear.
what a crappy teacher you got there !?!?!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java

