0% found this document useful (0 votes)
36 views

Module 4

Uploaded by

maheswaranoop08
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Module 4

Uploaded by

maheswaranoop08
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

COMPUTER GRAPHICS MODULE IV

Module-4
Three Dimensional Graphics
The three-dimensional transformations are extensions of two-dimensional
transformation. In 2D two coordinates are used, i.e., x and y whereas in 3D three
coordinates x, y, and z are used.

Computer Graphics uses CAD. CAD allows manipulation of machine components which
are 3 Dimensional. It also provides automobile bodies, aircraft parts study. All these
activities require realism. For realism 3D is required. In the production of a realistic 3D
scene from 2D is tough. It requires three dimensions, i.e., depth.

THREE DIMENSIONAL DISPLAY METHODS

To obtain display of a three-dimensional scene that has been modeled in world coordinates. we must
first set up a coordinate reference for the "camera". This coordinate reference defines the position and
orientation for the plane of the carnera film which is the plane we want to us to display a view of the
objects in the scene. Object descriptions are then transferred to the camera reference coordinates and
projected onto the selected display plane. We can then display the objects in wireframe (outline) form,
or we can apply lighting surface rendering techniques to shade the visible surfaces.

1. Parallel Projection

• Parallel projection is a method for generating a view of a solid object is to project


points on the object surface along parallel lines onto the display plane.

• This technique is used in engineering and architectural drawings to represent an


object with a set of views that maintain relative proportions of the object.

1
COMPUTER GRAPHICS MODULE IV

2. Perspective Projection

• It is a method for generating a view of a three dimensional scene is to project points to the
display plane alone converging paths.

• In a perspective projection, parallel lines in a scene that are not parallel to the display plane are
projected into converging lines.

• Scenes displayed using perspective projections appear more realistic, since this is
the way that our eyes and a camera lens form images.

3. Depth Cueing

• Depth cueing is a method for indicating depth with wire frame displays is to vary the
intensity of objects according to their distance from the viewing position.

2
COMPUTER GRAPHICS MODULE IV

• Depth cueing is applied by choosing maximum and minimum intensity (or


color) values and a range of distance over which the intensities are to vary.

4. Visible Line and Surface Identification

• We can also clarify depth relationships in a wireframe display by identifying visible lines in
some way.

• The simplest method is to highlight the visible lines or to display them in a different color.

• Another technique, commonly used for engineering drawings, is to display the nonvisible lines
as dashed lines.

• Another approach is to simply remove the nonvisible lines

5. Surface Rendering

• Surface rendering method is used to generate a degree of realism in a displayed


scene.

• Realism is attained in displays by setting the surface intensity of objects


according to the lighting conditions in the scene andsurface characteristics.

• Lighting conditions include the intensity and positions of lightsources and the
background illumination.

3
COMPUTER GRAPHICS MODULE IV

• Surface characteristics include degree of transparency and howrough or smooth


the surfaces are to be.

6. Exploded and Cutaway View

• Exploded and cutaway views of objects can be to show the internal structure
and relationship of the objects parts.

• An alternative to exploding an object into its component parts isthe cut away
view which removes part of the visible surfaces to show internal structure.

7. Three-Dimensional and Stereoscopic View

Three-dimensional views can be obtained by reflecting a raster image from a vibrating flexible mirror.
The vibrations of the mirror are synchronized with the display of the scene on the CRT. As the mirror
vibrates, the focal length varies so that each point in the scene is projected to a position corresponding to

4
COMPUTER GRAPHICS MODULE IV

its depth. Stereoscopic devices present two views of a scene: one for the left eye and the other for the
right eye

Three Dimensional Object Representations

Representation schemes for solid objects are divided into two categories as follows:

1. Boundary Representation ( B-reps)

It describes a three dimensional object as a set of surfaces that separate the object interior from
the environment. Examples are polygon facets and spline patches.

2. Space partitioning representation

It describes the interior properties, by partitioning the spatial region containing an object into a set of
small, non-overlapping, contiguous solids(usually cubes). Eg: Octree Representation.

Polygon Surfaces
Polygon surfaces are boundary representations for a 3D graphics object is a set of polygons that
enclose the object interior.

(1)Polygon Tables

The polygon surface is specified with a set of vertex coordinates and associated attribute parameters.

For each polygon input, the data are placed into tables that are to be used in the subsequent processing.

Polygon data tables can be organized into two groups: Geometric tables and attribute tables.
(2)Geometric Tables

Contain vertex coordinates and parameters to identify the spatial orientation of the polygon surfaces.

5
COMPUTER GRAPHICS MODULE IV

(3)Attribute tables

Contain attribute information for an object such as parameters specifying the degree of
transparency of the object and its surface reflectivity and texture characteristics. A
convenient organization for storing geometric data is to create three lists:

1. The Vertex Table

Coordinate values for each vertex in the object are stored in this table.

2. The Edge Table

It contains pointers back into the vertex table to identify the vertices for each polygon edge.

3. The Polygon Table

It contains pointers back into the edge table to identify the edges for each polygon. This is shown in fig

Listing the geometric data in three tables provides a convenient reference to the individual components
(vertices, edges and polygons) of each object.

The object can be displayed efficiently by using data from the edge table to draw the
component lines.

6
COMPUTER GRAPHICS MODULE IV

Extra information can be added to the data tables for faster information extraction. For
instance, edge table can be expanded to include forward points into the polygon table so
that common edges between polygons can be identified more rapidly.

E1 : V1, V2, S1

E2 : V2, V3, S1

E3 : V3, V1, S1, S2

E4 : V3, V4, S2

E5 : V4, V5, S2

E6 : V5, V1, S2

It is useful for the rendering procedure that must vary surface shading smoothly across the edges from
one polygon to the next. Similarly, the vertex table can be expanded so that vertices are cross-referenced
to corresponding edges.

Additional geometric information that is stored in the data tables includes the slope for each edge and
the coordinate extends for each polygon. As vertices are input, we can calculate edge slopes and we can
scan the coordinate values to identify the minimum and maximum x, y and z values for individual
polygons.

The more information included in the data tables will be easier to check for errors. Some of the tests
that could be performed by a graphics package are:

• That every vertex is listed as an endpoint for at least two edges.

• That every edge is part of at least one polygon.

• That every polygon is closed.

• That each polygon has at least one shared edge.

• That if the edge table contains pointers to polygons, every edge referenced by a polygon pointer
has a reciprocal pointer back to the polygon.

7
COMPUTER GRAPHICS MODULE IV

• Plane Equations:

To produce a display of a 3D object, we must process the input data representation for the object
through several procedures such as,

• Transformation of the modeling and world coordinate descriptions to viewing coordinates.

• Then to device coordinates:

• Identification of visible surfaces

• The application of surface-rendering procedures.

For these processes, we need information about the spatial orientation of the individual
surface components of the object. This information is obtained from the vertex coordinate
value and the equations that describe the polygon planes.

The plane surface equation is expressed as:

Ax + By + Cz + D = 0

Where (x, y, z) is any point on the plane, and the coefficients A, B, C, and D are constants describing the
spatial properties of the plane. The values of A, B, C, and D can be obtained by solving the set of three
equations using the coordinate values of the non collinear points of the plane. It is assumed that the three
vertices of the plane are (x1, y1, z1), (x2, y2, z2) and (x3, y3, z3).

The equation for the ratios A/D, B/D, and C/D is solved for obtaining the values of A, B, C, and D.

(A/D) x1 + (B/D) y1 + (C/D) z1 = -1

(A/D) x2 + (B/D) y2 + (C/D) z2 = -1

(A/D) x3 + (B/D) y3 + (C/D) z3 = -1

To obtain the above equations in determinant form, apply Cramer’s rule to the above equations.

8
COMPUTER GRAPHICS MODULE IV

Expanding the determinants , we can write the calculations for the plane coefficients in the
form:

A = y1 (z2 –z3 ) + y2(z3 –z1 ) + y3 (z1 –z2 )

B= z1 (x2 -x3 ) + z2 (x3 -x1 ) + z3 (x1 -x2 )

C= x1 (y2 –y3 ) + x2 (y3 –y1 ) + x3 (y1 -y2 )

D= -x1 (y2 z3 -y3 z2 ) - x2 (y3 z1 -y1 z3 ) - x3 (y1 z2 -y2 z1)

It is said that, for any point (x, y, z) with parameters A, B, C, and D,

•Ax + By + Cz + D ≠ 0 implies that the point is not on the plane.

•Ax + By + Cz + D < 0 implies that the point is inside the surface.

•Ax + By + Cz + D > 0 implies that the point is outside the surface.

Polygon Meshes
A set of polygonal and line segments approximate 3D surfaces and solids. Such surfaces are known as
polygonal meshes. In such meshes each of the edge is shared by at most two polygons. The skin of the
project is a combination of set of polygons or faces.
A broad class of solids/ surfaces are represented by this method. Hidden surface removal algorithms are
used for rendering the polygonal mesh. The mesh is represented in three different ways:

• Explicit representation
• Pointers to a vertex list
• Pointers to an edge list

9
COMPUTER GRAPHICS MODULE IV

One type of polygon mesh is the triangle strip.A triangle strip formed with 11 triangles
connecting 13 vertices.

This function produces n-2 connected triangles given the coordinates for n vertices.

Another similar function in the quadrilateral mesh, which generates a mesh of (n-1) by
(m-1) quadrilaterals, given the coordinates for an n by m array of vertices. Figure shows 20
vertices forming a mesh of 12 quadrilaterals.

Advantages
• Any object can be modelled by this mesh.
• Represented as a collection of vertices.
• Transformation of the mesh is easy.
• Easily can be drawn on the computer screen.
Disadvantages
• Curved surfaces can be describes approximately.

10
COMPUTER GRAPHICS MODULE IV

• Some types of objects like hair or liquid is difficult to simulate.

Sweep Representation

• Solid-modeling packages often provide a number of construction techniques.

• Sweep representations are useful for constructing three-dimensional objects that


possess translational, rotational, or other symmetries.

• We can represent such objects by specifying a two dimensional shape and a sweep
that moves the shape through a region of space.

• A set of two-dimensional primitives, such as circles and rectangles, can be provided


for sweep representations as menu options.

• Other methods for obtaining two-dimensional figures include closed spline curve
constructions and cross-sectional slices of solid objects.

1. Figure below illustrates a translational sweep. The periodic spline curve in Figure
(a) defines the object cross section.

1. We then perform a translational sweep by moving the control point’s p, through p3


a set distance along a straight line path perpendicular to the plane of the cross
section.

2. At intervals along this path, we replicate the cross-sectional shape and draw a set of
connecting lines in the direction of the sweep to obtain the wireframe representation
shown in Fig (b).

To obtain the wireframe representation we have to replicate the 2D shape and draw

11
COMPUTER GRAPHICS MODULE IV

a set of connecting lines in the direction of shape, as shown in the figure (8)

An example of object design using a rotational sweep is given in Figure below this time, the
periodic spline cross section is rotated about an axis of rotation specified in the plane of the cross
section to produce the wireframe representation shown in Fig (b).

12
COMPUTER GRAPHICS MODULE IV

1. Any axis can be chosen for a rotational sweep. If we use a rotation axis
perpendicular to the plane of the spline cross section in Fig. (a), we generate a two-
dimensional shape.

2. But if the cross section shown in this figure has depth, then we are using one three-
dimensional object to generate another.

In rotational sweeps, the 2D shape is rotated about an a axis of rotation specified in


the plane of 2D shape to produce three dimensional object. This is illustrated in
figure (9).

In general we can specify sweep constructions using any path. For translation we
can vary the shape or size of the original 2D shape along the sweep path. For
rotational sweeps, we can move along a circular path through any angular distance
from 0° to 360°. These sweeps whose generating area or volume changes in size,
shape or orientation as they are swept and that follow an arbitrary curved trajectory
are called general sweeps .General sweeps are difficult to model efficiently for
example, the trajectory and object shape may make the swept object intersect itself,
making volume calculations complicated. Further more, general sweeps do not

13
COMPUTER GRAPHICS MODULE IV

always generate solids. For example, sweeping a 2D shape in its own plane
generates another 2D shape.

Constructive Solid Geometry (CSG)

1. Definition

• Combine volume occupied by overlapping 3D objects using set Boolean operations


• Each primitive is defined as a combination of half-spaces.
• Typical standard primitives are: cone, cylinder, sphere, torus, block, closed spline
surface, right angular wedge. swept solids (a revolution or linear sweep of a planar face
which may contain holes.
• Operations are union, intersection and difference.

2. Implementation with ray casting

Ray Casting is often used to implement CSG operation when objects are described
with boundary representation. We fire a ray from the plane xy (which represent the screen).
The surface limits for the composite object are determined by the specified set operation

14
COMPUTER GRAPHICS MODULE IV

Operation Surface Limit

Union A, D

Intersection C, B

Difference (Obj2 - Obj1) B, D

This method can also be used for physical simulation.

Constructive solid geometry (CSG; formerly called computational binary solid


geometry) is a technique used in solid modeling. Constructive solid geometry allows a

15
COMPUTER GRAPHICS MODULE IV

modeler to create a complex surface or object by using Boolean operators to combine


simpler objects, potentially generating visually complex objects by combining a few
primitive ones.

In 3D computer graphics and CAD, CSG is often used in procedural modeling. CSG can
also be performed on polygonal meshes, and may or may not be procedural and/or
parametric.

Workings

The simplest solid objects used for the representation are called primitives. Typically they
are the objects of simple shape: cuboids, cylinders, prisms, pyramids, spheres, cones. The
set of allowable primitives is limited by each software package. Some software packages
allow CSG on curved objects while other packages do not.

It is said that an object is constructed from primitives by means of allowable


operations, which are typically Boolean operations on sets: union, intersection and
difference, as well as geometric transformations of those sets.

A primitive can typically be described by a procedure which accepts some number of


parameters; for example, a sphere may be described by the coordinates of its center point,
along with a radius value. These primitives can be combined into compound objects
using operations like these:

16
COMPUTER GRAPHICS MODULE IV

Union
Merger of two objects into one

Difference
Subtraction of one object from another

Intersection
Portion common to both objects

Combining these elementary operations, it is possible to build up objects with high


complexity starting from simple ones.

Ray tracing

Rendering of constructive solid geometry is particularly simple when ray tracing. Ray
tracers intersect a ray with both primitives that are being operated on, apply the operator to
the intersection intervals along the 1D ray, and then take the point closest to the camera
along the ray as being the result.

Quadtrees
• Based on the divided-and-conquer principle, a quadtree is a data structure that recursively

17
COMPUTER GRAPHICS MODULE IV

subdivides a plane into 4 quadrants.

• The decision to subdivide is based on an attribute of the current quadrant. If the


quadrant is heterogeneous with respect to this attribute, further subdivision occurs.
If it is homogeneous, or we have reached the desired level of detail, we stop
subdividing.

We will apply quadtrees to storing planar polygons. Our attribute will be whether current
quadrant is filled by the interior of a polygon:

18
COMPUTER GRAPHICS MODULE IV

The successive subdivisions can be represented as a tree with heterogeneous quadrants as


nodes and homogeneous quadrants as leaves.

Octrees

An Octree is a recursive, axis-aligned, spatial partitioning data structure commonly used in computer
graphics to optimize collision detection, nearest neighbor search, and more. Conceptually, an Octree is a
simple data structure.

• Octrees are based on the same principle, but divide regions of 3D space (usually
into cubes).
• The scene is subdivided at each step with three mutually perpendicular planes,
aligned with the Cartesian coordinate planes.
• Individual partitions of 3D space are called Voxels (Volume Elements).
• Applications: raycasting, shadowcasting.

Octrees, like Quadtrees, use a node structure to store the volume elements:

19
COMPUTER GRAPHICS MODULE IV

In this figure, the octree has been refined twice. First, the root is refined into eight cells,
each representing an octant of the root's domain. Then, one of the root's children is refined
yet again.

An Octree is constructed by recursively subdividing space into eight cells until the remaining number
of objects in each cell is below a pre-defined threshold, or a maximum tree depth is reached. Every cell
is subdivided by three axis-aligned planes, which are usually placed in the middle of the parent node.
Thus, each node can have up to eight children. The possibility not to allocate certain child nodes allows,
in contrast to regular grids, to store sparsely populated worlds in Octrees.

20
COMPUTER GRAPHICS MODULE IV

21

You might also like