work done in the starter project can be seen in [1.1.6].
A vertex in a 3D scene
must hold information about its position; for example, in the figure
the verices (in blue) are positioned so that the faces that use them
form a cube. In general, a vertex can hold information other than the
position; for example if you want to apply a texture to the cube, the
the vertex must hold information about the texture coordinate that
correspond to it in the 2D texture. In the boxes figure, each box has
different per vertex data, a vertex of the cube in the upper left part
has only position data, a vertex of the one in th lower left part has
position and normal data, the normal is needed to perform the lightning
calculations. A vertex of the cube in the upper right part has
position, normal and texture coordinate data, and finally a vertex in
the cube of the lower right part has position, texture, tangent,
binormal and normal data (normal mapping is explained later in the
Now that you know how a vertex work, you should know how they are
finally drawn. We could create a three vertices and pass them to the
GPU to draw a face, and repeat the process for all the faces in a mesh,
but that would be extremely slow, because the time needed to establish
a communication channel between the CPU and the GPU is way higher than
the time that the GPU spends to draw a single face.
idea is to create an array with all the vertices that are going to be
used in the drawing of an object, and pass the whole array to the
graphics card, then pass another array defining the faces of the
In BetaCell you create a container that has two main
responsibilities; hold the vertex data and create the previously
mentioned array that is called a VertexBuffer in XNA.
In the tutorial, two options are shown. The first option is:
ProceduralModelers.CUBE_MODELER.createCube(10, 10, 10,
createCube always creates a cube with the center at the origin (0,0,0)
and receives the width, height and depth respectively as the first
The interesting parameter is the fourth one; its a
vertex container that holds the position and the color information.
BetaCell comes with some general vertex containers to let programmers
with little background in computer graphics have a little experience
before creating vertex containers by composition; more experienced
programmers will prefer the following vertex container declaration.
First an array that will hold the usages of the container is created:
BCVertexUsage usages = new
BetaCell.Common.Vertex.BCVertexUsage class represents a usage that a
vertex can have, some usages are position, normal, texture, color, etc.
Then the position and color usages are set to the array:
usages = BCVertexUsage.POSITION;
usages = BCVertexUsage.COLOR;
Notice how the different usages are static constants of the
Now a BetaCell.Common.Vertex.BCGeneralVertexContainer is created with
the usages array as a parameter.
the cube is created with the same call, except that the last parameter
isn't a BCVertexPosColorContainer but the more flexible
ProceduralModelers.CUBE_MODELER.createCube(10, 10, 10, generalPosColor);
The rest is just call the init method [1.1.6].