Using Primitives for Simulation

[ LiB ]

Using Primitives for Simulation

The world we live in is very complex. Our environment is filled with all types of geometric objects. Some objects can be easily defined, like tables, basket -balls, rooms, houses , desks, beds, and so on. These objects fall into a common set of objects that are called primitives in computer graphics. Primitives can be used to simulate our real-world environment by using them singularly or by combining them to define complex geometry. For example, a sphere can be used to define a baseball, the planet, or a marble. A scene is composed of many types of objects. The collection of geometric objects in the scene is called the model and is composed of numerous types of primitives.

Primitives come in many forms and can make the modeling time less painful for an artist. The following sections briefly cover some of the common types of primitives in most 3D applications.

Plane

The most basic form of a primitive is the plane. A plane extends infinitely in four directions by definition but can be used to represent the boundary of objects such as the ground, the sky, or perhaps an infinite wall. Planes are very simple and easy to test for ray intersections. A simple example of a plane is a sheet of paper extending infinitely with no width or height.

Triangle

The triangle is composed of three points, but can be used to construct very complex geometry. Testing ray interactions on triangles can be a bit tricky but, if done correctly, triangles can define any type of complex geometry. Because of their simple definition, triangles can be used to easily do texture mapping. A set of triangles grouped together is called a mesh . A simple example of a triangle mesh is a pyramid.

Polygon

A polygon is more common in most 3D applications because you also can create complex geometry with fewer vertices as apposed to triangles. They are not limited to three points and can have n amount of points (often called n -gons for this reason). Polygons can be grouped together to create meshes. You can have convex polygons that define simple geometry or concave polygons that define irregular geometry. A simple example of a polygon mesh is a cube.

Box

A box or a cube is basically six polygons grouped together. A box can be a wall, tin, or file cabinet in the scene. Boxes can also be used to optimize rendering with an axis-aligned box surrounding objects. This is also known as a bounding volume . This can speed up rendering by testing bounding boxes against one another. This is a big advantage over testing primitives singularly because grouping a set of primitives in a volume and testing a volume with another volume speed up rendering.

Sphere

The sphere is the simplest primitive that can be tested for ray intersections. Basically almost all ray-tracing applications have this primitive. Scaling a sphere by different values along the different X, Y, and Z axes can cause the sphere to look ellipsoidal. The sphere can either look squashed or stretched . A simple example of a sphere is a basketball .

Cylinder

A cylinder is composed of a long circular shaft with two discs at the top and bottom. Intersecting a ray with a cylinder is similar to a sphere intersection, but the cylinder's length must be taken into account. A simple example of a cylinder is a soda can.

Cone

Cones are similar to cylinders . Cones are in almost all ray tracers because intersecting a ray with a cone is simple. A simple example of a cone is, yes you guessed itan ice cream cone.

Disk

A disk is not common in many rendering applications because intersecting rays with disks can be a pain in the neck when writing an intersection function. Disks are required to implement cones and cylinders without top and bottom faces. A typical example of a disk is a CD-ROM.

This book uses spheres and triangles only, because these are the two basic primitives that the application supports. This is because spheres are easy to set up and test for ray intersections. Triangles can also be used to read in very complex geometry, which is enough to build a very powerful application. You can extend the primitives any way you want to include the rest. Let's begin constructing the two most basic primitives for your 3D rendering environment. The two primitives are very different in definition but have one similarity in their internal intersection functions. The intersection functions will return a point that computes the exact hit point of an incoming ray. You can use C++'s polymorphism capability to aid you with the intersection methods . After you have designed these two primitives they will then be inherited into a final encapsulated layer called object . The material class will also be inherited into the object class that you will define later. This will encapsulate the primitive classes and the material class into one object, which allows you to break each element in your scene into smaller components . This means the elements can be used singularly or as a group , thus taking an object-oriented approach to making code reusable and easier to understand.

NOTE

NOTE

The 3D hardware boards (transfor mation and lighting hardware abstrac tion layer) available today can only understand the triangle primitive. They use squashed triangles to create lines,as well as triangle meshes to create other complex primitives.

[ LiB ]


Focus On Photon Mapping
Focus On Photon Mapping (Premier Press Game Development)
ISBN: 1592000088
EAN: 2147483647
Year: 2005
Pages: 128
Authors: Marlon John

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net