Re. Creating an array of mesh nodes is it possible

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

afecelis, beg pardon?
DGENXP
Posts: 124
Joined: Tue Dec 27, 2005 2:49 am
Contact:

Post by DGENXP »

YES I finally got it Thanking everyone who has helped me

IAnimatedMesh* mesh = smgr->getMesh("Objects/floor.x");

Code: Select all

vector<IAnimatedMeshSceneNode*> nodes; 
// Creating five of them: 
for (int i = -Ammountofblocks; i < 256*Ammountofblocks; i+=256) 
{ 
   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(i*256-128-256,0,78)); 
      nodes[i]->setPosition(vector3df(i*256-Boxes-128-256,0,78)); 
      nodes[i]->setMaterialTexture( 0, driver->getTexture("Objects/Floor09.jpg")); 
      //nodes[5]->setMaterialTexture( 0, driver->getTexture("Objects/Floor04.jpg"));
}


The above code works a Treat

Cheers
DGENXP
Posts: 124
Joined: Tue Dec 27, 2005 2:49 am
Contact:

Post by DGENXP »

Hi all A little help needed here

I would like to know if anybody can help me find the solution to my latest dilema :?

I would like my code to not just create a single line of blocks like this code does very well but also creates the same line of blocks severl times

like the below diagram

Ammount of blocks = 10 so the ammount of I's would equals 10

I I I I I I I I I I

Ammount of blocks = 10 per line with a total of 10 lines

I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I
I I I I I I I I I I

so the ammount of blocks variable would not equals 10 only but 10 per line

i think that i would need to somehow make the array multiply the ammount of blocks by itself to make the total number of blocks but when the ammount of blocks reaches itself reset the position of X and add 256 to the position of the Z Axis and do this the ammount of blocks times down

Here is the code to generate the line of blocks

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("Objects/floor.x"); 

vector<IAnimatedMeshSceneNode*> nodes; 
vector<IAnimatedMeshSceneNode*> hnodes; 
// Creating Ammountofblocks of them: 
for (int Boxes = -Ammountofblocks; Boxes < 256*Ammountofblocks; Boxes+=256) 
{ 
   nodes.push_back(smgr->addAnimatedMeshSceneNode(mesh)); 
} 

   for (int h = -Ammountofblocks; h < 256*Ammountofblocks; h+=256) 
{ 
   hnodes.push_back(smgr->addAnimatedMeshSceneNode(mesh)); 
} 

// Initialise the created nodes 
for (size_t f = 0; f < nodes.size(); ++f)
{
for (size_t i = 0; i < nodes.size(); ++i) 

{ 
      nodes[i]->setMaterialFlag(EMF_LIGHTING, false); 

      nodes[i]->setPosition(vector3df(i*256-128-256,0,78)); 
      nodes[i]->setMaterialTexture( 0, driver->getTexture("Objects/Floor09.jpg")); 
Boxes+=1;
} 

}
If there is an answer to this i would really like your help
Kaeles
Posts: 37
Joined: Thu Jun 03, 2004 12:43 am
Location: oklahoma
Contact:

Post by Kaeles »

I used an array to make my random wandering zombie code.

just say like ...

Code: Select all

IAnimatedMeshSceneNode nodeArray[100];
IAnimatedMesh = smgr->getMesh("zombie.ms3d");

for (int i =0; i < 100; i++)
{
nodeArray[i] = smgr->addAnimatedMeshSceneNode(mesh);
nodeArray[i]->setPosition((0.0f + rand()%100) , 0,  (0.0f + rand()%100))
}

Post Reply