Array

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
BraX
Posts: 36
Joined: Fri Jul 16, 2010 4:39 pm

Array

Post by BraX »

How can i put scene::IAnimatedMeshSceneNode* model into array and how i can change code to support more than one entity?

bxGame.cpp:

Code: Select all

void bxGame::funcCircle()
{
	scene::ISceneManager* sm = device->getSceneManager();
	
	printf( "Game: funcCircle()\n" );
	quakeLevelMesh = (scene::IQ3LevelMesh*) sm->getMesh("maps/map1.bsp");
	if ( quakeLevelMesh )
	{
		scene::quake3::tQ3EntityList &entityList = quakeLevelMesh->getEntityList();

		scene::quake3::IEntity search;
		search.name = "func_circle";
		s32 index = entityList.binary_search ( search );
		if ( index >= 0 )
		{
			const scene::quake3::SVarGroup *group;
			s32 notEndList;
			do
			{
				group = entityList[ index ].getGroup(1);

				u32 parsepos = 0;
				core::vector3df pos =
					scene::quake3::getAsVector3df ( group->get ( "origin" ), parsepos );

				parsepos = 0;
				f32 mdl = ( group->get ( "model" ), parsepos );

				parsepos = 0;
				int circle_radius = ( group->get ( "circle" ), parsepos );

				parsepos = 0;
				f32 scale = ( group->get ( "scale" ), parsepos );
				
            	scene::IAnimatedMeshSceneNode* model = sm->addAnimatedMeshSceneNode( sm->getMesh("bxgame/models/testModel.md3") );
                	
                if (model)
                {
                   model->setScale(core::vector3df(1,1,1));
				   model->setPosition ( pos );
				   scene::ISceneNodeAnimator* rotate =
      	           sm->createFlyCircleAnimator(pos, circle_radius);
                   if (rotate)
                   {
           	           model->addAnimator(rotate);
                 	   rotate->drop();
                   }   
                 }
                 
				index += 1;
				notEndList = index == 2;
			} while ( notEndList );
		}

	}	
}

bxGame.h:

Code: Select all

 	struct func_circle
	{
		scene::IAnimatedMeshSceneNode* model;
		core::vector3df pos;
	};  
    core::array<func_circle> funcsCircle;
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Post by Auradrummer »

Could you be more clear?

If I understood ... you want to make an array of 'func_circles' and evaluate them independently, right?

Build another 'func_circle', configure and initialize everything of it and make

Code: Select all

funcsCircle.push_back(newFuncCircle).
So, you can evaluate them by making a

Code: Select all

for(u32 i=0; i < funcsCircle.size(); i++)
When destroying one, make funcsCircle.delete(i).

Worked fine for stack.
Professional Software Developer and Amateur Game Designer ;-)
BraX
Posts: 36
Joined: Fri Jul 16, 2010 4:39 pm

Post by BraX »

Well, i placed three entities with name "func_circle" on map and only one entity is working but i want them all working, so if i place 5 entities i will see 5 etc..

BTW. I'm a newbie and i cant understand your method...
Tr3nT
Posts: 65
Joined: Thu Nov 29, 2007 5:19 pm

Post by Tr3nT »

using an array(or list) of objects?
u create the object,create an array of them and anytime you want use your function to set the values of the object(position, mesh) using a counter(using this one you could prefer to use an array,because u can the number to refer to the array,but you are limited for the number o entities)
BraX
Posts: 36
Joined: Fri Jul 16, 2010 4:39 pm

Post by BraX »

Can you post the code?
Waigie
Posts: 1
Joined: Wed Jun 16, 2010 11:05 am

Post by Waigie »

Well try to use std:vector<IAnimatedMeshSceneNode*>

this should fit your needs.
It's possible to address each element via index but you have a flexible length.
Post Reply