Hi,
I have instantiated an Entity (lets call it "oTree") . I now want to attach that same "entity" to multiple scenenodes (for instance to generate a quick forest). I tried the following
first I create the entity in my init code.
oTree = OgreRender->m_pSceneMgr->createEntity("tree.mesh");
Then I run this each time I need to add a tree.
{
OgreNodes[node_count]=OgreRender->m_pSceneMgr->getRootSceneNode()->createChildSceneNode();
OgreNodes[node_count]->attachObject(oTree);
OgreNodes[node_count]->setPosition(inmat->posit_x,inmat->posit_y,inmat->posit_z);
node_count++;
}
But Ogre craps out when doing the attach the second time in (node_count = 1). Is this not possible to do? Do I have to generate an Entity for each Tree?
Any advice would be most welcome.
Cheers
How to have multiple scenenodes use the same Entity.
-
- Bronze Sponsor
- Posts: 53
- Joined: Wed Mar 25, 2015 10:01 pm
-
- OGRE Expert User
- Posts: 1119
- Joined: Sat Jan 01, 2011 7:57 pm
- x 216
Re: How to have multiple scenenodes use the same Entity.
An Entity is a MovableObject. MovableObjects can be attached to at most one Node.
Yes. However, all these entities would use the same base Mesh, so there isn't really any duplication.Do I have to generate an Entity for each Tree?
-
- Bronze Sponsor
- Posts: 53
- Joined: Wed Mar 25, 2015 10:01 pm
Re: How to have multiple scenenodes use the same Entity.
Great, thanks! Makes sense I guess.
Cheers
Cheers