Graphics Programs Reference
In-Depth Information
Figure 5-9
.
Blender: obtaining the center of object
Note
In the source code for this chapter, inside the Blender folder,
you will find Blender files named
pointLight*
. You can open
these files to see how you can add a point light source. Instead of us-
ing a sphere as a light source object, I have used an Icosphere mesh,
which can be easily added using the Add menu (from the
Info
win-
dow). I have used this object in both
VERTEX POINT LIGHTING
and
FRAGMENT POINT LIGHTING
applications.In these applic-
ations, I have demonstrated lighting/shading effects using a point
light source. This application contains the Tank and Light objects,
where the Light object is an Icosphere added from Blender.
▪ Because the normal vector (
N
) is in eye-space (to get points and
vectors in eye-space, they must be transformed using their re-
spective
MV
matrices), you must also transform the
S
vector into
eye-space, so it becomes possible to take their dot product. For
this, make sure the current vertex position and the light source po-
sition are transformed using their respective
MV
matrices. In most
graphical applications, the light source is usually fixed. However
in the application I have provided for demonstrating lighting/

Search WWH ::

Custom Search