So, how are effects applied
Fortunately, BetaCell distinguishes the application developer and the
effect developer roles; in the tutorials you'll start at the
application developer position; meaning that many effects have already
been done for you, and that BetaCell provides a framework to use them
The first part of the initialize method is the basic initialization:
device = graphics.GraphicsDevice;
only parts that you should care about are the initialization of the
BCLogger and the BCInitializationManager initialization method. The
BCLogger class has a singleton instance (a lonely static public
object) that has methods to print information in the form of text in
the screen, this is very useful to debug programs.
The initialize method of the BCInitializationManager class loads the
necessary data to:
- Reads the necessary data to compose effects
- Loads the effects declared in the BCEffectStore
The Effect Store is a file inside
Content>BetaCell>, it contains the definitions of the
effects that are compiled at content creation time (when the game is
built). This is useful for the XBOX360 because it can't compile effects
at runtime. The default behavior in the PC is to compile the effects
at runtime, if you want to use only the effects in the effectStore.bce
file, set the following flag to false:
BCGlobalInfo.instance.runtimeEffects = false;
The flag can't be set in the XBOX360 because you can't choose to
compile effects at runtime on it.
The declaration of the effects in the file are very cryptic, to add an
effect in it see [1.1.7].
The next part of the initialization method is the creation of the
//Base black color for the lines
BCColorSet blackBase = new
//Function part that represents the base color of
BCFunction colorFunction = blackBase.getFunction("Shader.ColorSet");
BCDynamicEffectVisitor colorSetter =
new BCDynamicEffectVisitor(colorFunction , blackBase, 0);
that effects have to be parametrized? for example, the light effect can
have the following parameters: light position, light color, light
range, etc. well in BetaCell the object responsible for setting the
parameters of an effect is called an effect feeder and is represented
by the BetaCell.Effects.BCEffectFeeder interface.
about three different effects, the point light, the directional light
and the spot light. These effects can share the same feeder, in this
case a light feeder, so the effect feeder is a good place to administer
effects that have common characteristics.
In this tutorial, the
BCColorSet is an effect feeder, it is created to feed the effect with a
black color to draw the black lines in the wireframe spheres. So we
have the feeder but how about the effect?
The effect in this case has to set a constant color across the
objects that are drawn with it. In BetaCell, the functions that are
part of an effect are represented by the BCFunction class. Notice that
we obtain the function from the feeder passing the name of the
We have to create an
object capable of holding both the effect function and the feeder in
apply the effect to different objects in the scene, in this tutorial
that object is an effect visitor, and is represented by the class
Now we will discuss the parameters of the visitor's constructor one by
For now, think that the BCEffectFeeder.getFunction method returns an
applies color to the objects. Remember that the effect feeder
administers the effects? well blackBase is a feeder.
: since the lines
have to be black, this feeder will feed the effect with a black color.
: This parameter will be
dealt with later in the tutorials.
So now we have the colorSetter object that makes black everything it
last part of the initialization method is the construction of the
spheres; note that only the first sphere will be explained.
//Creating a sphere
= ProceduralModelers.SPHERE_MODELER.createSlicedSphere(4, 2, 1, new
has many modelers, one of them is the SPHERE_MODELER which is used to
create the sphere of this example. The method createSlicedSphere
the number of slices, you can think of them as the vertical slices that
yo make to an orange with a knife, the number of vertical divisions
specified in the following form: divs = pow(2,n-1) being n the second
parameter, what this means is that if you state 2 you will have 2
divisions, 3 will have 4 divisions, 4 will have 8 divisions, 5 will
have 16 divisions, etc. the next parameter is the radix and
one is a vertex container. vertex containers are discussed later in the
method prepares the sphere to be drawn, it's very important. The reason
why it's necessary will be explained later in the tutorials.
//Setting the effect
With BetaCell you set
the effect to the mesh, and when you draw the mesh, the effect is
automatically set to the graphics card. So the line where the effect is
set is just painting the sphere black.
//Setting the transform
Matrix.CreateTranslation(-1.25f, 1.25f, 0);
last part is to set the transform, in this case we are setting the
center of the sphere to 1.25f to the left and 1.25f up to draw
sphere in the upper left part.