Register    Login    Forum    Search    FAQ

 Page 1 of 1 [ 1 post ]

A little help ..

 Print view Previous topic | Next topic

A little help ..

Author Message
 Post subject: A little help ..  Posted: December 14th, 2014, 8:31 pm

Joined: November 30th, 2013, 7:40 pm
Posts: 562
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

Display posts from previous:  Sort by

 Page 1 of 1 [ 1 post ]

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

 Search for: