# AABB tree : separating vertices

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

## 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]

1. 1
2. 2
Rutin
21
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013601
×