I took a picture of legal pad paper with a digital camera, and then
texture-mapped it to a y-axis flattened cube to make a piece of paper.
About the letter, 26 letter images are created. As for the model, I
create on template letter box model. And then using the shell
script to replace related info inside the .obj file to create all
series of different kinds of letter box models, which saves some time
than creating them one by one. Modelling is done with Wings3D.
(ps. 2 images are in different scale. In reality, the letter box is
much smaller than the paper model.)
The code skeleton is based on Electro's 'viewobj' example code. User
can use mouse to rotate around the scene and using keyboard arrow keys
to move forward and backward, left/right keys to turn camera left and
right, PageUp/PageDown keys to move camera up and down.
Implementations
At the end of the project I found I spent most of the time getting
familar with lua data structure, especially using 'table'. But once I
got to be more familiar with it's actually really easy and handy to
'simulate' the C structure and object-oriented class concepts.
The main boid behavior is computed in Electro's "do_timer()" function.
There are 5 rules implemented, including 3 basic rules: 1. Boids try to
fly towards the center of mass of neighboring boids. 2. Boids try to
keep a small distance away from other objects 3. Boids try to match
velocity with near boids. Additional boundry and velocity limit rules
are added to limit with-in range and reasonable boid moving velocity.
One thing I found that might be a typo in the [2] pseudo code it that
in its calculating vector c in order to let the boid moving away the
other boid that is too close to itself, the equation should be "c = c + (bj.position
- b.position)", in order to use vector c moving input boid bj
away from near by boid b.
Courtesy of
http://hyperphysics.phy-astr.gsu.edu/hbase/vect.html
Inspired by a neat game GridWars2,
I try to add another rule to let boids follow a user controlled robot
(with w/s/a/d to move aroud x-z plane). The
rule is as simple as let each boid move 0.1% closer to the 'pod' bot
every frame.
(gridwars2 screensht)
Input file format
The input file use a naive format , each line represent a letter with
its initial position in x, y, z order. A sample input data file can be
downloaded from here.
Screenshots
Download Electro project zip file
The Electro lua script along with object models and textures can be
downloaded from here.
Q & A
Brian Uphoff: You said that you wanted to model the
behavior of the letter boids after the game Grid Wars 2. I've
never played the game but I thought your boid movement was
unique. The jitter and slow movement of the boids reminds me of
the Atari game Asteroids where the enemies slowly move toward you as a
group. Was this your intention or was it simply a side effect of
the behavior rules?
I never played Asteroids, but the the Wikipedia article,
I guess it might be similar to Grid War. Yes, the idea is to let the
basic flocking rules have heavier weighting than the goal rule (moving
toward the player controlled actor). So the result looks like to boids
are flocking together first and swarm toward the robot in groups
because once the boids are in a group, the basic rules are kind of
reach a "balance" static state. Then the goal attraction rule became
the dominant pulling force of boids' movements.