Ray Tracing using k-d trees for stanford bunny model
I am trying to ray trace the Stanford bunny model which is PLY format. I have a parser which parses the PLY file and gives me the value of co-ordinates of triangles and also their vertices. Now I am confused as to how to proceed ahead. Should I put these triangle vertices in a ve开发者_运维问答ctor and then pass them to build a k-d tree? Also does someone have a tutorial or a sample source code where a ply model is passed to the k-d tree and the k-d tree is then traversed to ray trace the scene? If anybody has a sample code which they can share, pls let me know. Thanks.
PLY is a file format for objects described as a collection of polygons. A KD Tree is an optimisation structure designed to speed up rendering times by eliminating unnecessary intersection tests.
So you need to:
- Define your own data structures for representing objects as a collection of points and a collection of polygons (which refer to the points).
- Write a loader which uses the parser to read an object in PLY format, and constructs an instance of your polygon type.
- Define a KD Tree data structure.
- Write a KD Tree builder which iterates through the polygons which comprise your object and constructs a KD Tree.
- Extend your ray-tracer to use the KD Tree.
Use google to find more info and sample code for KD Trees. The standard paper is by Vlastimil Havran which is available on-line.
精彩评论