I think it’s usually done considering the points in the table to be vertices rather than the centroids of triangles. Also when you put the triangles into the lists you need to make sure that if a triangle crosses the splitting plane (that is, if one vertex is on one side and another vertex is on the other side) you either cut the triangle into two polys along the splitting plane, or leave it intact and put it in the list for both sides. (Which of those choices you want depends on what you’re using the kd-tree for.)

Can someone please tell me if this is a correct approach ?

i don’t know but it feels something is wrong. what i am doing is

building a table -

triangle id centroid

Now if we want to split along x axis, then sort the records according

to x coordinates. Then use the median triangle as a splitting point.

Put all the records that appear till median including the median into left node and the ones that appear afterwards into right node. For child node,

splitting must be done along y axis, for grandchildren along the z axis. This

is done using a statement like axis = depth % 3 (axis = 0,1 ,2 for x,

y , z respectively. If the split point is split(x,y,z) and parent bounding box was given by vectors minB and maxB then children bounding boxes are given by minB.x, minB.y, minB.z and split.x, maxB.y, maxB.z

May be this is not a good approach but i need a working model in a limited time.