Tuesday 27 November 2012

Theme Park Scene 4

I have successfully added a Cylinder primitive to my program. The cylinder primitive contains two disc primitives which are used to approximate a circle for the top and base of the cylinder. From here, the cylinder allocates the top and bottom vertex, then bottom and top vertex around the discs for each face. The number of faces the cylinder has can be defined in the constructor, meaning you can get various levels of smoothness. It also means the class can be used to create prisms, passing three as the number of base points for example will produce a triangular prism. From here, I can use the disc and cylinder class as a basis to build both cones and quarter cylinders (to be used as corners on a go-kart track). I can also produce cylinders with no top face to be used as park bins, and I can also begin to model lights to go around the park. Below are some screenshots of the cylinder class being used.

A cylinder with 32 base points. Any more than 32 base points means that the indices being drawn will have to use negative values, as GLbyte is being used as the type for vertex indices.

A cylinder with 64 base points. This means 256 vertices for the central faces, plus 128 for the top and bottom discs,
a total of 512 vertices.

More vertices mean a more expensive computation when generating the cylinder, but do improve it's smoothness.

A triangular prism made by passing three as the number of base points.

No comments:

Post a Comment