Splitting Faces with Planes
I am in the process of developing a .MAP loader and am clipping the faces i have calculated from the map file with the planes. However I am unsure what size to make my arrays as I have two of them one for the verts on the plane and one for them out of the plane. I need to be able to lengthen the array as vertacie data is added.
This probubaly sounds a bit unclear, anyway please try and help
~Steve~
July 05, 2001 08:07 PM
Are you taking each plane, and making a huge possible polygon along it, then slipping that polygon by all the other planes?
If you are then don''t, thats a messy way to do it.
You have a cube with 6 faces,
For each face, make a cPolygon,
So now you have 6 polygons with no vertices in them,
Loop through the faces
Loop through the faces
Loop through the faces
Check if the 3 faces intersect
If they do and the intersection point is behind all the faces in the brush, then add it to the polygons you made for the faces you just checked for intersection.
so your cPolygon::AddVertex function will increase the size of its internal vertex array when you add a new vertex. Once this is all done, take the data out of your polygon classes and put it into a nice vertex array so your not hopping around the memory too much
If you are asking how to do dynamic arrays, the simplest possible way is like this. This adds a new element to the vertex array. Vertices is the current array. If you are doing this lots, it pays to grow the array in lots of 10 or 100 , so your not allocating/deallocating memory all the time, whatever suits.
Hope that helps,
FatalXC
If you are then don''t, thats a messy way to do it.
You have a cube with 6 faces,
For each face, make a cPolygon,
So now you have 6 polygons with no vertices in them,
Loop through the faces
Loop through the faces
Loop through the faces
Check if the 3 faces intersect
If they do and the intersection point is behind all the faces in the brush, then add it to the polygons you made for the faces you just checked for intersection.
so your cPolygon::AddVertex function will increase the size of its internal vertex array when you add a new vertex. Once this is all done, take the data out of your polygon classes and put it into a nice vertex array so your not hopping around the memory too much

If you are asking how to do dynamic arrays, the simplest possible way is like this. This adds a new element to the vertex array. Vertices is the current array. If you are doing this lots, it pays to grow the array in lots of 10 or 100 , so your not allocating/deallocating memory all the time, whatever suits.
|
Hope that helps,
FatalXC
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement