c++ - Ogre3d scenenode array -


currently working on pcg city in ogre3d, getting close room marked city spawn city there. kind of @ loss on how "store" buildings array , checking positions handle collision. in method size of plane buildings need spawn in, after create _citynode, house building nodes in it. these set in for-loop. in buildings variable try buildingnode in array can check collision in method. have 2 questions:

  1. how buildingnode array?
  2. is method approach of "uniqueness of buildingnodes correct or need approach?

    void citymanager::generatecity(int sizex, int sizez, int _numberofbuildings) {  #if ogre_platform == ogre_platform_win32 file* fp; freopen_s(&fp, "conout$", "w", stdout); _rootnode = gamemanager::getsingletonptr()->getscenemanager()->getrootscenenode(); _citynode = _rootnode->createchildscenenode("citynode"); printf(" number of buildings: %d \n", _numberofbuildings); printf(" location of x: %d  location of z: %d \n", sizex, sizez); (int = 0; < _numberofbuildings; i++) {     ogre::scenenode* buildingnode = _citynode->createchildscenenode("buildingnode" + i);     ogre::entity* _buildingentity = gamemanager::getsingletonptr()->getscenemanager()->createentity("cube.mesh");      buildingnode->createchildscenenode()->attachobject(_buildingentity);     buildingnode->setposition(rand() % sizex , 50, rand() % sizez);     buildingnode->setscale(rand() % 6+1 , rand() % 6 + 1, rand() % 6 + 1);       ogre::vector3 buildingpos = buildingnode->getposition();     ogre::vector3 buildingscale = buildingnode->getscale();     //_buildings = new ogre::scenenode[buildingnode];     checkcollision();     checkentryway();      printf("positions of building nodes %f, %f, %f " , buildingpos.x, buildingpos.y, buildingpos.z);     printf("scale of building nodes %f, %f, %f \n", buildingscale.x, buildingscale.y, buildingscale.z);   } fclose(fp); #endif } 

you can use stl container want, ogre::scenenode* compatible them.

as example can collect nodes in std::vector like

std::vector<ogre::scenenode*> buildings_; (int = 0; < _numberofbuildings; i++) {   /* ... */   buildings_.push_back(buildingnode); } 

and later access them like

for (auto : buildings_) {   ogre::vector3 buildingpos = i->getposition();   ogre::vector3 buildingscale = i->getscale(); } 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -