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.
communism
Posts: 8 Joined: Tue Mar 13, 2012 1:59 pm
Post
by communism » Tue Mar 13, 2012 2:06 pm
I am trying to create an array of nodes to store each enemy ai "entity" such that I can loop through the array to update positions, animations, joints ect. of each node "entity". They could all be the same mesh for all I care, so long as I can access each member of the array independently and load each one into the "gamespace". Any ideas?
Code: Select all
IAnimatedMesh* mesh = smgr->getMesh("irrlicht-1.7.3/media/sydney.md2");
if(!mesh)
{
device->drop();
return 1;
}
core::array<scene::ISceneNode *> nodes;
for(u32 i=0; i < nodes.size(); i++)
{
//scene::ISceneNode * node = nodes[i];
nodes[i]->addAnimatedMeshSceneNode(mesh);
nodes[i]->setPosition(core:vector3df(10*i, 10*i, -10);
nodes[i]->setMaterialFlag(EMF_LIGHTING, false);
nodes[i]->setMD2Animation(scene::EMAT_RUN);
nodes[i]->setMaterialTexture(0, driver->getTexture("irrlicht-1.7.3/media/sydney.bmp"));
}
serengeor
Posts: 1712 Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania
Post
by serengeor » Tue Mar 13, 2012 2:33 pm
From the code you provided it seams that array size is 0, I can't see where you create and add the nodes to array.
Working on game:
Marrbles (Currently stopped).
Mel
Competition winner
Posts: 2292 Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain
Post
by Mel » Tue Mar 13, 2012 9:48 pm
Take a look at the built-in irr::core::array<> template. It works like the STL vector, and handles its size dynamically.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
serengeor
Posts: 1712 Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania
Post
by serengeor » Tue Mar 13, 2012 9:56 pm
Just looked at the code again, does it even compile??
Cause this line looks totally incorrect:
Code: Select all
nodes[i]->addAnimatedMeshSceneNode(mesh);
And as Mel said, you should use it like a stl vector (read the API doc).
Working on game:
Marrbles (Currently stopped).
communism
Posts: 8 Joined: Tue Mar 13, 2012 1:59 pm
Post
by communism » Thu Mar 15, 2012 12:12 pm
Thanks I'll check it out and post back here if its fixed.