Title: Modelling
1Modelling
- The creation and manipulation of a system
representation is termed modelling - Any single representation is called a model of
the system. - There are mainly two kinds (conventional)
- Descriptive (e.g. a set of equations or rules to
define parameter relationships) - Graphical/volumetric (e.g. architectural and
engineering system).
2How to represent these objects in computer
3Example Methods
Polygonal
4Polygonal Models
- The most common type of model used in 3D - store
faces of the object as planar polygons - Each polygonal face may be represented by its
vertices or edges - Physical properties of the object may also be
held as part of the representation, for example
colour, light, texture - Representation methods such as this are called
Boundary Representations or B-reps. - 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
53D Modeling with Polygons
- We construct 3D models using groups of polygons.
- Each polygon is planar ? we need a large number
of small polygons to give the impression of
curved surfaces
6Polygon 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)
7Polygon Mesh
8Example Methods
Parametric surface
9Example Methods
Parametric surface
mapping from R2(u,v) to R3(x,y,z) Parametrized
by u and v.
xf(u,v)yg(u,v)zh(u,v)
10Example Methods
Allows easy enumeration of points. Just plug in
values for u and v. Differentiable Can have more
than one z value for each (x,y)
11Example Methods
Implict surface F(x, y, z) Constant
12Example Methods
Voxels Uniform grid of volumetric samples
13Space Subdivision
- This splits space into some arrangement of cells
that cover all of the space. - With each cell a note is kept as to whether that
cell is occupied by the model or not. - Obviously this method has limited accuracy.
- Typically methods are based on quadtrees and
octrees.
14Sweep Objects
- Define a polygon by its edges then sweep it along
a path - Special cases
- Surface of revolution rotate edges about an axis
- Extrusion Sweep along a straight line
15Geometric Models
- Geometric models are collections of components
with well defined geometry and often
interconnections between components, including
engineering and architectural structures, and
other chemical structures - 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 - Generally represented as a tree, with
transformations and instances at any node
16Geometric Models
17Geometric Modeling
- Each node may have its own local coordinate
system - Most useful for animating polygonal meshes
- Rendered by traversing the tree, applying
transformations, and rendering the instances -
- Consider a walking robot
- Does the entire robot move in the same way?
- Does the position of one part of the robot depend
on other parts?
18Constructive Solid Geometry
- Constructive solid geometry (CSG) is a technique
used in solid modeling. CSG is often, but not
always, a procedural modeling technique used in
3D computer graphics and CAD. - Constructive solid geometry allows a modeler to
create a complex surface or object by using
Boolean operators to combine objects. - Often CSG presents a model or surface that
appears visually complex, but is actually little
more than cleverly combined or decombined
objects. - In some cases, constructive solid geometry is
performed on polygonal meshes, and may or may not
be procedural and/or parametric.
19Constructive Solid Geometry
- 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.
20Constructive Solid Geometry
Union
Difference
Intersection
21Constructive Solid Geometry
22Constructive Solid Geometry
- This object could be produced by gluing two
rectangular blocks together and then drilling the
hole - 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 - 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
23Procedural Methods
- The pattern is produced by the code
- polyline(ns1,verts) for (i0
i lt nr i)
transverts(verts,ns,fc,fs)
polyline(ns1,verts) - 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
24Smoke Particle System
- Constantly create particles
- Particles move upwards, with turbulence added
- Draw them as partially transparent circles that
fade over time
25Particle Systems
- A particle has
- A position in the world
- Rules for how it moves over time
- Rules for how it is drawn
- A particle system
- Controls when particles are created and destroyed
- Makes sure that all the particles are updated
26Basic Ocean
- Ocean created with Computational Fluid Dynamics
27Procedural Approach
28Procedural Approach
- 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
Substrate
http//www.bartlett.ucl.ac.uk/ve/weblog/2004/10/pr
ocedural-urban-modelling.html
29Modeling in OpenGL
- OpenGL provides a set of routines (API) for 3D
graphics - derived from Silicon Graphics GL
- draws simple primitives (points, lines, polygons)
- provides control over transformations, lighting,
texture etc. - In OpenGL, all geometry is specified by stating
the type of object and then giving the vertices
of the object - glBegin() glEnd()
- glVertex34fdv
- Three or four components (regular or homogeneous)
- Float, double or vector (eg float3)
- 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()
30OpenGL Command Formats
glVertex3fv( v )
Number of components
Data Type
Vector
b - byte ub - unsigned byte s - short us -
unsigned short i - int ui - unsigned int f -
float d - double
omit v for scalar form glVertex2f( x, y )
2 - (x,y) 3 - (x,y,z) 4 - (x,y,z,w)
31Geometric Primitives
- All geometric objects in OpenGL are created from
a set of basic primitives - Certain primitives are provided to allow
optimisation of geometry for improved rendering
speed - Line based primitives
GL_LINE_STRIP
GL_LINE_LOOP
GL_LINES
GL_POINTS
32Geometric Primitives
v4
v4
v4
GL_POLYGON
GL_QUADS
GL_TRIANGLES
v4
v3
v8
v2
v4
v5
v6
v3
v2
v5
v2
v1
v4
v1
v6
v3
v5
v7
v1
GL_QUAD_STRIP
GL_TRIANGLE_STRIP
GL_TRIANGLE_FAN