Octree Help
I''ve read all the articles on Octrees (the gamasutra one, several others) - but I still can''t leap the boundary between theory and practice..
Should I read anything else? Is there any source code available (of any form)?
..Or should I just keep hacking and hope I get somewhere eventually?
The Octrees concept is very simple. If you can''t figure them out, start with a fixed subdivision first. Thus, divide your world space into 16x16x16 subspaces, and start from here. This way, you don''t have the subdivision problems and the like. If you have that working, proceed to octrees.
For a jumpstart:
- write code that generates or imports a simple scene
- write the code to calculate the boundbox of your scene
- Divide this space into equal sized blocks. Thus, if your scene boundbox ranges from (0,0,0) to (200,200,200), and you subdivide it into a 10x10x10 voxel, then the first block ranges from (0,0,0) to (20,20,20). The 2nd block around the X axis ranges from (20,0,0) to (40,20,20).
- Now, take a polygon from your scene, find the midpoint, and see in what block it is. Add it to that block.
- Repeat this.
- At the end, your scene is subdivided.
- In your render loop, determine which blocks are visible from the camera, and render all the polys in that block. This is a tricky part.
This is a simple but already quite effective subdivision scheme. You should experiment a bit to get the feeling.
DaBit.
For a jumpstart:
- write code that generates or imports a simple scene
- write the code to calculate the boundbox of your scene
- Divide this space into equal sized blocks. Thus, if your scene boundbox ranges from (0,0,0) to (200,200,200), and you subdivide it into a 10x10x10 voxel, then the first block ranges from (0,0,0) to (20,20,20). The 2nd block around the X axis ranges from (20,0,0) to (40,20,20).
- Now, take a polygon from your scene, find the midpoint, and see in what block it is. Add it to that block.
- Repeat this.
- At the end, your scene is subdivided.
- In your render loop, determine which blocks are visible from the camera, and render all the polys in that block. This is a tricky part.
This is a simple but already quite effective subdivision scheme. You should experiment a bit to get the feeling.
DaBit.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement