hexagon tile map

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

hexagon tile map

Post by omar shaaban »

hexagon tile map or sphere tile map, is the same as square tile maps but using hexagon and just a small difference in the code
justposting the code here as i dont need it:

Code: Select all

for(int i=0;i<=10;i++)
      {
          for(int j=0;j<=10;j++)
      {
     for(int z=0;z<=10;z++)
      {//((i*((z%2)*1.5)))
      ISceneNode*tile=smgr->addSphereSceneNode(10);
      tile->setPosition(core::vector3df(((i+((z%2)*0.5)))*(0.88)*20,((j+((z%2)*0.5))-((i%2)/2.0))*20,z*(0.88)*20));
            tile->setMaterialFlag(EMF_LIGHTING, false);
            //            tile->setMaterialTexture( 0, driver->getTexture("tile.jpg") );

     }}}


well first there are 3 for loops wich represent the three dimenstion axes x,y,z
sofor x=1,y=1 the third loop makes all tiles in z axis in x=1,y=1
then x=2,y=2 and so on....
this is known in any 3d tile mapconstruction or even can be understood from 2d tile maps which are allover the net...
anyway the 2nd thing is the constant numbers found here:

Code: Select all

core::vector3df(((i+((z%2)*0.5)))*(0.88)*20,((j+((z%2)*0.5))-((i%2)/2.0))*20,z*(0.88)*20));
these numbers i set to replace many and not so many constants like sin(30) and cos(30) but u will find that number 20 in this code all depends on the diameter of the circle which i set its radius to 10.
so thats all !!
Post Reply