Project 2c - Crowd Simulation.
Goal: The goal of this phase of the project was to display multiple animated figures in order to simulate a crowd. Each member of the crowd will have a goal (i.e. to get to a destination) and will interact with other members of the crowd. For example, the people will have to figure out how to reach the destination goal without running into other people in the crowd.

Tools Used: My project was written on Windows XP. I used IronCAD for the 3D Modeling and Processing 0095 Beta (http://processing.org) for the viewer.

Crowd: In order to make a crowd I decided to implement some useful classes. The first class is an animation class that reads in all the triangle mesh info at the beginning of the program, and delivers a triangle mesh animation frame upon request. This way no triangle mesh data is stored more than once, improving efficiency. I then created a person class which holds all the details about the individual people. This includes current position, size, color, speed, the current animation frame, and the goal position. Upon every call to draw I loop through the people array and draw each person. This action also automatically updates the person's animation frame and next position (discussed below). In the next phase I will add the capability to add or remove people from the crowd. I have five people in the crowd currently, and adding any more slows the applet down significantly. I think once level of detail control is working properly I can add more people to make things more interesting.

Collision Detection: Collisions are handled in a similar fashion to my first project. By default the person moves a static distance towards the goal unless that distance is inside another person's personal space bubble. Checking this only requires a loop through the people array and calculating the distance between the next potential position and the current position of everyone else.

Goal Reaching: Each time the updatePosition() function is called, the next point to move to is calculated. If there is nothing between the person and the goal, the person moves straight towards the goal. The distance moved is determined by the person's speed attribute, which is in pixels_per_second. pixels_per_second * (framerate)^-1 gives pixels_per_frame, which is the distance we want to move. If no collision is detected, everything is fine. However, if there is something in the way (such as people or walls) the person cannot move there. Currently a circle is drawn around the person with a radius of pixels_per_frame. 100 steps are taken around this circle, and at each step the distance to the goal is calculated. If there is no collision associated with this point, and it is smaller than any other point checked so far, it become the new next point. In theory this has the effect of finding the minimum path between the current position and the goal. However I found this solution to be a little quirky in practice. For example the people tend to make a lot of jerky back and forth motions. I might try to fix this by having the person stop and mingle around, or wander in a random direction.

Demo Pictures:
(click to enlarge)

ss1
An overhead view of the room.

ss2
A close up view of the action.

Demo Video: p2c-demo-divx.avi (10 MB, DivX Required)

Applet Instructions: the applet must be "clicked on" to activate key controls.
Use the mouse to rotate the view.
Press + and - to zoom in and out.


Applet:
To view this content, you need to install Java from java.com


Files:
Frame 1 STL - 00.stl
Frame 2 STL - 01.stl
Frame 3 STL - 11.stl
Frame 4 STL - 10.stl
Viewer Source Code - p2c.pde
Copyright Info :: W3C :: CSS