I can't seem to get it to make itself off of center properly .. can anyone help ?
Code: Select all
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);
}
}
};