Re. Creating an array of mesh nodes is it possible
Re. Creating an array of mesh nodes is it possible
Hi I am trying to creat an array of scene nodes as in name[amt] but i cannot get this working
the reason i want this is because i am working on an aplication which will generate alot of these models
if there is any ideas i would like to know - I did see that somebody has done this on the forums but he has not released his code to look at
Cheers
the reason i want this is because i am working on an aplication which will generate alot of these models
if there is any ideas i would like to know - I did see that somebody has done this on the forums but he has not released his code to look at
Cheers
-
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
What exactly were you trying? (Code snippet) And what exactly was the error you were getting? (Exact compiler messages)
Also state your compilation environment and used Irrlicht version.
You might consider using irr::core::array or std::vector or some other container instead of C style arrays. They are *much* easier to use, dynamically growing and just as fast.
Also state your compilation environment and used Irrlicht version.
You might consider using irr::core::array or std::vector or some other container instead of C style arrays. They are *much* easier to use, dynamically growing and just as fast.
Hi I hope this helps
when i try this it crashes before it even starts i have tried another method but this just places the object without a texture
I am using Dev C++ and IRR Version 0.12.0 with directX Support
I shall look forward to reading the solution
when i try this it crashes before it even starts i have tried another method but this just places the object without a texture
I am using Dev C++ and IRR Version 0.12.0 with directX Support
Code: Select all
IAnimatedMesh* mesh = smgr->getMesh("Objects/floor.x");
IAnimatedMeshSceneNode* node[1] = {smgr->addAnimatedMeshSceneNode( mesh )};
if (node[1])
{
node[1]->setMaterialFlag(EMF_LIGHTING, false);
node[1]->setPosition(vector3df(128-256,0,78));
// node->setFrameLoop(0, 310);
node[1]->setMaterialTexture( 0, driver->getTexture("Objects/Floor09.jpg") );
}
This would be the fixed-up code:
Code: Select all
IAnimatedMesh* mesh = smgr->getMesh("Objects/floor.x");
IAnimatedMeshSceneNode* node[1];
node[0] = smgr->addAnimatedMeshSceneNode( mesh ) ; // no need for braces here
if (node[0])
{
node[0]->setMaterialFlag(EMF_LIGHTING, false);
node[0]->setPosition(vector3df(128-256,0,78));
// node[0]->setFrameLoop(0, 310);
node[0]->setMaterialTexture( 0, driver->getTexture("Objects/Floor09.jpg") );
}
Last edited by ElementoY on Wed Feb 08, 2006 11:49 pm, edited 1 time in total.
d'oh! like Baal said, you should try using core::array instead because its much easier to use. I thought creating an array like x[3] = {a,b,c} makes constants, i dunno, anyway they're awkward and you cant 'redim' them.
Code: Select all
core::array<scene::ISceneNode*> aNodes;
aNodes.set_used(total);
aNodes[0] = smgr->addFooSceneNode();
...
aNodes[total-1] = smgr->addFooSceneNode();
-
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
Or using std::vector (would be similiar with irr::core::array)
Using C style arrays in this context is just inflexible and troublesome. Prefer full functional containers like STL containers or the ones Irrlicht provides.
Code: Select all
#include <vector>
using namespace std;
//...snip...
IAnimatedMesh* mesh = smgr->getMesh("Objects/floor.x");
vector<IAnimatedMeshSceneNode*> nodes;
// Creating five of them:
for (int i = 0; i < 5; ++i)
{
nodes.push_back(smgr->addAnimatedMeshSceneNode(mesh));
}
// Initialise the created nodes
for (size_t i = 0; i < nodes.size(); ++i)
{
nodes[i]->setMaterialFlag(EMF_LIGHTING, false);
nodes[i]->setPosition(vector3df(128-256,0,78));
nodes[i]->setMaterialTexture( 0, driver->getTexture("Objects/Floor09.jpg"));
}