we find everywhere actually that the
best option is always to divide into
triangles because any 3d surface in the
universe is able to be approximated by
fitting together triangles
in taking about how 3D computer generated images
are created and how they work there are
a number of different questions that we
need to address and problems that we
need to solve and the first of those is
how do we take a 3d object and represent
it in the computer and so the way we do
this is by using a coordinate system
with every day we maps and graphs and
things that all use this coordinate
systems got the Cartesian coordinate system
generally we have two axes one
collects won't go why if we want to
specify a point any point anywhere on
the graph we have two numbers which
represent the distances that we travel
along each axis so if we have point "2"
one we go on to "1" that's point two
one simple enough using this system we
can represent any unique point anywhere
on the plane described by these axes and
we can also you know go this way and
this way to have negative points as well
so that's plus X plus y minus X minus y
and this way we can have minus two minus
one here so that's two dimensions but
Sir if we want to specify points in
three dimensions we simply add another
axis going through the middle like this
it's perpendicular to X and Y but
obviously is a 2d piece of papers and
this is called Z so we'll go plus
Z and this minus said so now we can
have point to one and this is on plane
zero in Z so that's (2,1,0) and this
becomes minus 2 minus 1 is 0 using this
system and three number coordinates we
can specify any unique point
relative to the origin here and the axes
that we've specified what uses this when
we want to describe something like a
pyramid well typically what we want to
do is use our coordinate system to
specify the corners of the objects which
we call vertices let's get another piece
of paper let's describe the points of
our pyramid using our 3d coordinate
system it's called them a,b,c,d and then
round the back e using our coordinates a
will be at zero to zero say B will be at
minus 1 in X 0 and Y minus 1 in Z
C will be at plus 1 in X 0 in Y minus 1
n's head and so on for the other two
using these coordinates we can specify
the corners or the vertices of our
objects but that's not quite enough
because all we're doing is specifying
the corners and our representation says
nothing at all about the faces of the
pyramid so how do we go about
representing the faces well one way of
doing it the simple way would be to
specify a new set of vertices three
vertices three coordinates for every
face so we'll have one here one here one
here one here one here one here one here
one here one here etc the problem is
this incurs a lot of duplication of
vertices so for example this vertex at
the top point a on the diagram is
required by all four of these faces so
if we're specifying three coordinates
for every face we're duplicating the top
one 4 times for a simple object like
pyramid that's not too much of a problem
but if we have a model with a hundred
thousand vertices in then the wastage
can be quite considerable so there is a
better system for specifying the faces
of any geometry and to do that we use a
separate data structure to represent the
faces which references the vertices that
we've described using our Cartesian
coordinates so if we name them as we
have done on the diagram A B C we can
then say that this face is represented
by vertices A B C and this faces A C D
and then this phase A D E and then this
place is A C B and then we have a problem
because when we come to represent the
base of the pyramid it's a square and
that doesn't really fit into our system
of three vertices / face so what we
could do is find some way of specifying
that these faces all have three vertices
each and this one has four and for
another shape it might have five
vertices or something like that but in
practice it's better just to split the
base into two triangles we find
everywhere actually that the best option
is always to divide into triangles
because any 3d surface in the universe
is able to be approximated by fitting
together triangles why triangles so good
for this purpose but first of all it's
the simplest polygon there's only three
vertices in a in a triangle second of
all and more importantly any
arrangements of three vertices in 3d
space will always be coplanar which
means that no matter how you arrange the
three vertices of a triangle they will
always lie on the same plane in space
which is a crucial property if you want
to approximate a surface with a simple
two-dimensional polygon or set of them
and it doesn't work for other types of
polygons so a rectangle for example
in this case it's okay because the
vertices are all coplanar they're nice
and flat but if i were to lift one of
them let's go with this one out of the
plane of the other three we no longer
have a valid rectangle because these
three or a coplanar but this isn't I
mean there's got a curved surface to it
so it's not a proper rectangle anymore
so for that reason using rectangles or
higher order shapes other than triangles
are surfaces that we are approximating
might be in danger of having degenerate
faces faces that aren't properly
represented because we might have one
vertex that's raised out of the plane of
the face but triangles don't suffer from
this problem sean has asked me now to
demonstrate how a cylinder might be
represented by triangles so let's draw
some triangles on to it so let's start
the circle at the top generally it's
quite easy to subdivide into triangles
but what we find is that this curved
edge here will start to look a little
bit jaggi with these straight edges not
drawn on very well but of course the
more triangles we use the better the
approximation to the circle so as we add
more and more these straight lines
approximate a curve better and better on
the side of the cylinder we just use
almost exactly the same principle we can
create triangles like this I mean there
are millions of ways to do and it's the
same situation is on the top whereby the
more triangles we have the denser the
tessellation the better approximation to
the curved surface will get so as you
say I mean any surface pretty much this
a sphere anything can be represented by
triangles and need conceivable surface
in the universe in three dimensions at
any rate so there's a further problem in
that when we specify a triangle
a big city we're really specifying two
triangles one on the front and one on
the back in the pyramid we have the
triangles facing out in the triangles
facing in and sometimes we might want to
be able to differentiate between which
way a triangle is facing is it facing
out or is it facing in and the way that
is achieved is by being very careful
about the order in which the vertex
coordinates is specified it's called
winding when you basically decide
yes because your wind.. the winding the
indices the trick is we always go in one
direction clockwise or anti-clockwise it
doesn't matter which as long as we're
consistent so let's say and in fact I'll
actually done that here that going
anti-clockwise means the face is going
outwards clockwise means of face is
pointing inwards so let's have a look on
this pyramid here we can see that ABC
that's going anti-clockwise this face is
facing out a CD yep they're going it
anti-clockwise this face is facing and
now the back face which is facing away
from us it's A D E which is going
clockwise so that's facing away from us
so this way we can differentiate between
triangles that are facing out or facing
in which becomes very useful for example
when we're drawing a triangle we might
want to say well don't render the faces
that are facing away from us we want to
call those and not bother having to
shade the pixels for those back to faces
or we might want to say well we don't
want to draw the faces that are looking
towards us because we want to see the
inside of an objective when rendering go
cut away or something like that and so
that's how winding works in a nutshell
it doesn't matter whether you go
clockwise for forward front faces and
anti-clockwise for back faces or the
other way around as long as you're
consistent because further down the
pipeline when we come to turn these
triangles into pixels it might become
important to know whether it's facing
away or towards us
we've probably now covered enough to
know roughly how geometry is represented
inside the computer we can represent
vertices and faces made up of vertices
the next step is to take our description
of an object and move it around in 3D space