I'm developing a 3d flight simulator for Android and am using a relatively large (10k triangles) scene in 3ds format for the scenery. The scene is one polygon soup, not separated into separate objects. Frustum culling per triangle would be time consuming. What techniques could I use to render the triangles that are only visible in the view-port?
Per-triangle culling is done by the GPU, so you should only draw entire objects. Some tips:
- Break down your scene into smaller objects, preferably doing it based on their material, so they are drawn in a single batch.
- Calculate a bounding box for each object, and intersect them with the view frustum. Discard or draw them based on this criteria.
- Use VBOs for your data, uploading it once to the GPU and then drawing them directly from VRAM.
- If you have a very large object, like a ground plane, consider implementing a quadtree approach (or octree if it isn't flat).
- Consider using level of detail (LOD) for detailed, distant objects.
You should separate the triangles in groups, as in making separate game objects, then assign a bounding volume to it and check the box geometry against the frustum planes to discard all triangles contained in the bounding volume.
You need to separate objects in order to define a local coordinate space/object center for each triangle group that makes a 3D object. You can't skip groups of triangles if the only information you have are just the vertex position of random triangles, so you need to define a local center for groups or triangles and these triangles' vertices be described relative to the local object center. Then for transforming the vertices' positions to the global coordinates, just add the object's center to each vertex to translate to the global coordinates (but this won't work for rotations, you should build a matrix instead if you want both a rotation and translation transform).
So either you make a file for each object, or parse the single file and separate them on loading, but the later is difficult and you will work better if geometries are already split and have a local origin defined.
Octrees are a good way to organize polygon soup scenes for visibility culling. The idea is similar to other sorts of recursive dividing techniques like BSP or even quicksort, but more 3 dimensional.