Questions on how to use the list and array in irrlicht

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.
Post Reply
Daystar
Posts: 58
Joined: Tue Jul 17, 2007 3:53 pm
Contact:

Questions on how to use the list and array in irrlicht

Post by Daystar »

I would like to ask if anyone could help me with different examples of how to use the array and list functions in the irrlicht system?
DayStar
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes. What would you like to know?

Travis
Daystar
Posts: 58
Joined: Tue Jul 17, 2007 3:53 pm
Contact:

Post by Daystar »

I wanted to know if someone could give me some examples of using them.
DayStar
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

From scene::ISceneNode for lists:

Code: Select all

00308                 virtual void addAnimator(ISceneNodeAnimator* animator)
00309                 {
00310                         if (animator)
00311                         {
00312                                 Animators.push_back(animator);
00313                                 animator->grab();
00314                         }
00315                 }

Code: Select all

00328                 virtual void removeAnimator(ISceneNodeAnimator* animator)
00329                 {
00330                         core::list<ISceneNodeAnimator*>::Iterator it = Animators.begin();
00331                         for (; it != Animators.end(); ++it)
00332                                 if ((*it) == animator)
00333                                 {
00334                                         (*it)->drop();
00335                                         Animators.erase(it);
00336                                         return;
00337                                 }
00338                 }
And an array example, courtesy of me :) :) :)

Code: Select all

core::array< f32 > floats ;
floats.push_back( 10.f ) ; // adds a float to the end
floats.push_back( 11.f ) ; // another to the end
floats.push_front( 9.f ) ; // adds a float to the front of the array
floats[1] = 100.f ; // changes the second value ( currently 10.f ) to 100.f
for ( u32 t = 0 ; t < floats.size() ; ++ t )
floats[t] += 1.0f ; // adds one to every member of the array
monchito
Posts: 59
Joined: Thu Mar 08, 2007 9:38 pm

Post by monchito »

Here is one...

Code: Select all

list<ISceneNode*>NodeList;  // Create node list.

// create some cubes, fill the list     
void AddCubeNode(const s32 qty)
{
  ISceneNode* cube;
  
  for(s32 i = 0; i < qty; i++)
  {
    cube = smgr->addCubeSceneNode();
    // set random position
    cube->setPosition(vector3df( Random(), Random(), Random()));
    NodeList.push_front(cube);
  }
}

// test collision one node with the list
// select bool for yes/no  or ISceneNode* for who is colliding
bool CubeNodeCollision(ISceneNode* n)
{
  aabbox3df box = n->getTransformedBoundingBox();
  
  core::list<ISceneNode*>::Iterator it = NodeList.begin();
  for (; it != NodeList.end(); ++it)
  {    
     if(box.intersectsWithBox((*it)->getTransformedBoundingBox()))
        return true;    // return (*it);
  }
  return false;        // NULL;
}


Daystar
Posts: 58
Joined: Tue Jul 17, 2007 3:53 pm
Contact:

Post by Daystar »

Thanks you guys these examples really helped!
DayStar
Katsankat
Posts: 178
Joined: Sun Mar 12, 2006 4:15 am
Contact:

Post by Katsankat »

There is an array of struct SParticleImpact in the demo if I remember correctly.
Post Reply