A little help ..

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

A little help ..

Post by MrGodin » December 14th, 2014, 8:31 pm

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: 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);
		}

	}
};
Curiosity killed the cat, satisfaction brought him back

Post Reply