Question

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 vector 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.

Was it helpful?

Solution

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:

  1. Define your own data structures for representing objects as a collection of points and a collection of polygons (which refer to the points).
  2. Write a loader which uses the parser to read an object in PLY format, and constructs an instance of your polygon type.
  3. Define a KD Tree data structure.
  4. Write a KD Tree builder which iterates through the polygons which comprise your object and constructs a KD Tree.
  5. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top