Pineapple3
(c)2004, Jean-Christophe Hoelt <jeko@ios-software.com>
Story Line
You are sheriff of a small village in the far west. During a dark night of
summer, the gang of reds, a bad group of crazy mind people, come to your town
to kill every one.
You must kill them all before all citizens are killed !
You'll earn 100 points per bad guy killed. You'll loose 10 points per citizen killed.
How To Play
Use the arrows to move and Space or Enter or Z to shoot. Esc switch from menu the game.
Technical Details
----- OBJ loader -----
This software uses OpenGL/Glut for rendering, models are imported from .obj files (you can find them on the "obj/" folder).
To achieve that goal I wrotte my own OBJ loader which support the following feature:
- any kind of polyones.
- auto-computation of vertex normals.
- materials.
- scale/translate/rotate object during loading.
// files: obj_model.h obj_model.cpp
----- Scene Graph -----
Except from the World itself, each model must be child of an other model, for that: each model contains a Vector of child. Childs are following the same movement than theirs parent plus their own movements.
The bounding box of a parent is equal to his own bounding box scaled to that it
also contains all his childs.
This allows us to do fast clipping as explained just bellow.
// files: basic_model.h basic_model.cpp
----- Bounding Cubes Clipping -----
Before rendering a model, we check if he is inside of the frustum, using the Frustum class. The algorithm is simple: if one side of the cube is in front of all the planes of the frustum, we render it.
If the cube is not inside the frustum, we do not render the model's childs as well.
// files: frustum.h frustum.cpp
----- Collision Detection -----
Two object on the world collide if their bounding cube intersect. If it is the case, we calcultate the collision point to put back models into a valid position. The speed is changed as well since the shock absorbs the part of the speed which make the object entering into the other.
But checking for each model if its bouding cube intersect with the one of each other model is very slow if we have a large number of models (complexity n^2). So I optimized things using an octree.
// files: basic_object.cpp::animate
----- Octree -----
Every models are stored into an octree which gives you on each leaf the models that are into the same small part of the world (depending on the octree depth). This allows the application to do fast collision detecting since the bounding cubes intersection test is now only needed between a small number of models.
The octree is also used to determine quickly who is hit by a bullet.
// files: octree.h octree.cpp
----- Character Animation -----
All the guy are being automaticly moved using some AI. Some movement policies are:
- ORBITAL: turn around someone (clockwise or anti-clockwise).
- FACE_AND_FOLLOW: follow some one, looking at him.
- FOLLOW: just follow.
- HUNTING: for a bad guy: choose an innocent citizen, go to him
and kill him !
All those policies can also be used by the camera.
// files: moving_model.h moving_model.cpp
----- Material Properties / Textures -----
My application also support nice textures properties, such as specularity, diffusion, etc. It's also possible to load bmp textures.
// files: material.h texture.h texture.cpp
