Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: A little help ..
 Post Posted: December 14th, 2014, 8:31 pm 
 

Joined: November 30th, 2013, 7:40 pm
Posts: 564
Location: Merville, British Columbia Canada
I have this cube grid thing i am trying to make ...
I can't seem to get it to make itself off of center properly .. can anyone help ?
Code:
void Create(D3DXVECTOR3 alphaCenter,float alphaWidth,float sectorRadius)
   {
      World = _AABB::Make(alphaCenter, alphaWidth / 2.0f, alphaWidth / 2.0f, alphaWidth / 2.0f);
      float r = alphaWidth /  ( 2.0f * sectorRadius) + 0.5f;
      int rows = (int)r;
      D3DXVECTOR3 StartPos = { (alphaCenter.x  - alphaWidth / 2.0f) / 2.0f ,
         (alphaCenter.y - alphaWidth / 2.0f) / 2.0f, (alphaCenter.z - alphaWidth / 2.0f) / 2.0f };
      count = rows * rows * rows;
      Sectors = new _AABB*[count];
      float xp, yp, zp;
      xp = StartPos.x;
      yp = StartPos.y;
      zp = StartPos.z;
      for (int x = 0; x < rows; x++)
      {
         yp = StartPos.y;
         
         for (int y = 0; y < rows; y++)
         {
            zp = StartPos.z;
            for (int z = 0; z < rows; z++)
            {
               _AABB B = _AABB::Make({ xp, yp, zp }, sectorRadius, sectorRadius, sectorRadius);
               const int index =  y * rows + z + x*rows*rows;
               Sectors[index] = new _AABB(B);
               zp += (2.0f * sectorRadius);
            }
            yp += (2.0f * sectorRadius);
         }
         xp += (2.0f * sectorRadius);
      }

   }
};

_________________
Curiosity killed the cat, satisfaction brought him back


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 1 post ] 

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: