5
1 Modelling o The creation and manipulation of a system representation is termed modelling o Any single representation is called a model of the system. o There are mainly two kinds (conventional): o Descriptive (e.g. a set of equations or rules to define parameter relationships) o Graphical/volumetric (e.g. architectural and engineering system). How to represent these objects in computer Example Methods Polygonal Polygonal Models o The most common type of model used in 3D - store faces of the object as planar polygons o Each polygonal face may be represented by its vertices or edges o Physical properties of the object may also be held as part of the representation, for example colour, light, texture o Representation methods such as this are called Boundary Representations or B-reps. o This type of representation may also be used to represent an approximation to a curved surface, where the curved surface is approximated by planar polygonal patches 3D Modeling with Polygons o We construct 3D models using groups of polygons. o Each polygon is planar we need a large number of small polygons to give the impression of curved surfaces: 48 polygons 120 polygons 300 polygons 1000 polygons Polygon Mesh A polygon mesh approximates the surface shape of an object by specifying a set of points in space these points representing vertices of various polygonal faces. we have 8 vertices and 6 (polygons) faces. A list of vertices for a polygon is created by looking at the polygon from the outside, listing the vertices in a counter-clockwise direction until a complete circle is made. Poly1 = {v1, v2, v3, v4} (front face) Poly2 = {v4, v3, v6, v5} (right face)

Example Methods Polygonal Models - Nottinghampszqiu/Teaching/Courses/G5BAGR/Slides/3-mod… · Polygon Mesh A polygon mesh approximates the surface shape of an object by specifying

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Example Methods Polygonal Models - Nottinghampszqiu/Teaching/Courses/G5BAGR/Slides/3-mod… · Polygon Mesh A polygon mesh approximates the surface shape of an object by specifying

1

Modelling

o The creation and manipulation of a system representation is termed modelling

o Any single representation is called a model of the system.

o There are mainly two kinds (conventional):

o Descriptive (e.g. a set of equations or rules to define parameter relationships)

o Graphical/volumetric (e.g. architectural and engineering system).

How to represent these objects in computer

Example Methods

Polygonal

Polygonal Models

o The most common type of model used in 3D - store faces of the object as planar polygons

o Each polygonal face may be represented by its vertices or edges

o Physical properties of the object may also be held as part of the representation, for example colour, light, texture

o Representation methods such as this are called Boundary Representations or B-reps.

o This type of representation may also be used to represent an approximation to a curved surface, where the curved surface is approximated by planar polygonal patches

3D Modeling with Polygonso We construct 3D models using groups of polygons.

o Each polygon is planar ⇒ we need a large number of small polygons to give the impression of curved surfaces:

48 polygons 120 polygons 300 polygons 1000 polygons

Polygon Mesh

A polygon mesh approximates the surface shape of an object by specifying a set of points in space these points representingvertices of various polygonal faces. we have 8 vertices and 6 (polygons) faces.

A list of vertices for a polygon is created by looking at the polygon from the outside, listing the vertices in a counter-clockwise direction until a complete circle is made.

Poly1 = {v1, v2, v3, v4} (front face)Poly2 = {v4, v3, v6, v5} (right face)

Page 2: Example Methods Polygonal Models - Nottinghampszqiu/Teaching/Courses/G5BAGR/Slides/3-mod… · Polygon Mesh A polygon mesh approximates the surface shape of an object by specifying

2

Polygon Mesh Example Methods

θθ2

4

cossin

==

y

xParametric surface

Example Methods

2222 rzyx =++

Implict surface: F(x, y, z) = Constant

Example Methods

Voxels: Uniform grid of volumetric samples

Space Subdivisiono This splits space into some

arrangement of cells that cover all of the space.

o With each cell a note is kept as to whether that cell is occupied by the model or not.

o Obviously this method has limited accuracy.

o Typically methods are based on quadtrees and octrees.

Sweep Objects

o Define a polygon by its edges then sweep it along a path

o Special cases

o Surface of revolution: rotate edges about an axiso Extrusion: Sweep along a straight line

Page 3: Example Methods Polygonal Models - Nottinghampszqiu/Teaching/Courses/G5BAGR/Slides/3-mod… · Polygon Mesh A polygon mesh approximates the surface shape of an object by specifying

3

Geometric Models

o Geometric models are collections of components with well defined geometry and often interconnections between components, including engineering and architectural structures, and other chemical structures

o Geometric models often have a hierarchical structure included by a bottom up construction process. Components are used as building blocks to create higher levels entities, which in turn serve as building blocks for yet higher level entities, and so on

o Generally represented as a tree, with transformations and instances at any node

Geometric Models

Geometric Modeling

o Each node may have its own local coordinate system

o Most useful for animating polygonal meshes

o Rendered by traversing the tree, applying transformations, and rendering the instances

o Consider a walking robot:

o Does the entire robot move in the same way?

o Does the position of one part of the robot depend on other parts?

Constructive Solid Geometry

o Constructive solid geometry (CSG) is a technique used in solidmodeling. CSG is often, but not always, a procedural modelingtechnique used in 3D computer graphics and CAD.

o Constructive solid geometry allows a modeler to create a complex surface or object by using Boolean operators to combine objects.

o Often CSG presents a model or surface that appears visually complex, but is actually little more than cleverly combined ordecombined objects.

o In some cases, constructive solid geometry is performed on polygonal meshes, and may or may not be procedural and/or parametric.

Constructive Solid Geometry

o The simplest solid objects used for the representation are called primitives.

o Typically they are the objects of simple shape: cuboids, cylinders, prisms, pyramids, spheres, cones.

o The set of allowable primitives is limited by each software package.

o Some software packages allow CSG on curved objects while other packages do not.

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

Constructive Solid Geometry

Union Difference Intersection

Page 4: Example Methods Polygonal Models - Nottinghampszqiu/Teaching/Courses/G5BAGR/Slides/3-mod… · Polygon Mesh A polygon mesh approximates the surface shape of an object by specifying

4

Constructive Solid Geometry Constructive Solid Geometry

o This object could be produced by gluing two rectangular blocks together and then drilling the hole

o in CSG terms the the union of two blocks is taken and then the difference of the resultant solid and a cylinder is carried out

o The basic primitive objects, the blocks and the cylinder, may have to be scaled to the correct size, possibly oriented and then placed in the correct positions relative to each other before the logical operations

Procedural Methods

o The pattern is produced by the code:

o polyline(ns+1,verts); for (i=0; i < nr; i++) { transverts(verts,ns,fc,fs); polyline(ns+1,verts);

} o where ns is the number of sides in

the polygon, nr is the number of repetitions of the polygon and the array verts holds the vertices of the current polygon. The function transverts applies a scaling and a rotation to the vertices at each step

Smoke Particle System

o Constantly create particles

o Particles move upwards, with turbulence added

o Draw them as partially transparent circles that fade over time

Particle Systems

o A particle has:o A position in the worldo Rules for how it moves over timeo Rules for how it is drawn

o A particle system:o Controls when particles are created and destroyedo Makes sure that all the particles are updated

Basic Ocean

o Ocean created with Computational Fluid Dynamics

Page 5: Example Methods Polygonal Models - Nottinghampszqiu/Teaching/Courses/G5BAGR/Slides/3-mod… · Polygon Mesh A polygon mesh approximates the surface shape of an object by specifying

5

Procedural Approach Procedural Approach

o Whilst being far from a solved problem, techniques have been developed for algorithmically generating convincing computer graphics models of landscapes, sea scapes, cloudscapes, forests, urban environment

Substratehttp://www.bartlett.ucl.ac.uk/ve/weblog/2004/10/procedural-urban-modelling.html

Modeling in OpenGL

o OpenGL provides a set of routines (API) for 3D graphicso derived from Silicon Graphics GLo draws simple primitives (points, lines, polygons)o provides control over transformations, lighting, texture etc.

o In OpenGL, all geometry is specified by stating the type of object and then giving the vertices of the object

o glBegin(…) …glEnd()o glVertex[34][fdv]

o Three or four components (regular or homogeneous)o Float, double or vector (eg float[3])

o Primitives are defined by vertices, for example to draw a triangle:glBegin (GL_POLYGON);

glVertex3v (0, 0, 0);glVertex3v (0, 1, 0);glVertex3v (1, 0, 1);

glEnd();

OpenGL Command Formats

glVertex3fv( glVertex3fv( vv ))

Number ofNumber ofcomponentscomponents

2 2 -- (x,y) (x,y) 3 3 -- (x,y,z)(x,y,z)4 4 -- (x,y,z,w)(x,y,z,w)

Data TypeData Type

b b -- bytebyteub ub -- unsigned byteunsigned bytes s -- shortshortus us -- unsigned shortunsigned shorti i -- intintui ui -- unsigned intunsigned intf f -- floatfloatd d -- doubledouble

VectorVector

omit “v” foromit “v” forscalar formscalar form

glVertex2f( x, y )glVertex2f( x, y )

Geometric Primitives

o All geometric objects in OpenGL are created from a set of basic primitives

o Certain primitives are provided to allow optimisation of geometry for improved rendering speed

o Line based primitives

GL_POINTS GL_LINES GL_LINE_STRIPGL_LINE_LOOP

v4

v1

v2

v3 v5

v6

v7v8v1

v2

v3 v5

v6

v7v8v1

v2

v3 v5

v6

v7v8v1

v2

v3 v5

v6

v7v8

v4 v4 v4

Geometric Primitives

o Polygon primitivesv4

v1

v2

v3 v5

v6

v7v8v1

v2

v3 v5

v6

v7v8v1

v2

v3 v5

v6

v7v8

GL_TRIANGLES GL_QUADS GL_POLYGON

GL_TRIANGLE_STRIP

v4 v4

v4

v1

v2v3 v5

v6

GL_TRIANGLE_FAN

v4v1

v2

v3v5

v1

v2

v3 v5

v6

v7

v8v4

GL_QUAD_STRIP