Jump to content
  • Advertisement
Sign in to follow this  
Bouteille51

AABB tree : separating vertices

This topic is 5080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm working on an AABB Tree so I want to separate my vertex buffer (D3DXVECTOR3 *) in 2 parts. One with Vertex > to the middle of the axis choosen, other with vertex < to the middle of this axis. I've written this but it doesn't seem to work (I got bad boxes), if you see something wrong, please tell me what since i'm getting mad :) thanx
D3DXVECTOR3 pVertex1[MAXVERTICES];
D3DXVECTOR3 pVertex2[MAXVERTICES];
int IndexVertex1=0,IndexVertex2=0;


for(i=0;i<nbVertices-3;i++)
{

	if ((i%3)==0)
	{
			
		CentreFace[0] = (Vertex.x + Vertex[i+1].x + Vertex[i+2].x) / 3.0f;
		CentreFace[1] = (Vertex.y + Vertex[i+1].y + Vertex[i+2].y) / 3.0f;
		CentreFace[2] = (Vertex.z + Vertex[i+1].z + Vertex[i+2].z) / 3.0f;
				
		// Axelong is the axis choosen for separation
		// LongueurAxes are the middle of axes
		// CentreFace is the center of the current face
		if (CentreFace[AxeLong] <= LongueurAxes[AxeLong]) //fSplit
		{
			//Store the verts to the left.
			pVertex2[IndexVertex2++]=Vertex;
			pVertex2[IndexVertex2++]=Vertex[i+1];
			pVertex2[IndexVertex2++]=Vertex[i+2];
		}
		else
		{
			//Store the verts to the right.
			pVertex1[IndexVertex1++]=Vertex;
			pVertex1[IndexVertex1++]=Vertex[i+1];
			pVertex1[IndexVertex1++]=Vertex[i+2];
		}

	}

}

Edited by Coder: Use source tags. Check GDNet Forums FAQ [Edited by - Coder on August 18, 2004 10:31:15 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!