Skip to content

Commit

Permalink
import particle engine research for reference
Browse files Browse the repository at this point in the history
This imports some particle engine work done by Chris Cummins into Rig
which we plan to use as a basis for integrating initial particle engine
support into Rig.
  • Loading branch information
Chris Cummins authored and rib committed Aug 22, 2013
1 parent 880f6cf commit 813593b
Show file tree
Hide file tree
Showing 33 changed files with 9,223 additions and 0 deletions.
144 changes: 144 additions & 0 deletions research/particle-engine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#
# Git ignore file
#
# A highly generic list of background noise and generated files that you don't
# want clogging up your git tree.
#
# Copyright (C) 2013 Chris Cummins <chrisc.101@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

#
# C project files
#
*.a
*.app
*.bin
*.dll
*.dylib
*.elf
*.exe
*.lib
*.la
*.lo
*.lst
*.o
*.o.*
*.out
*.so
*.so.*

#
# Autotools by-products
#
/aclocal.m4
/autom4te.cache
/build/*
/compile
/config.h
/config.h.in
/config.log
/config.status
/configure
/configure.scan
/depcomp
/install-sh
/libtool
/missing
/stamp-h1
Makefile
Makefile.in

#
# Editor backups and transient files
#
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
.elc
auto-save-list
tramp
.\#*
.*.s[a-w][a-z]
*.un~
Session.vim
.netrwhist

#
# Tags files
#
tmtags
TAGS
tags
!TAGS/
!tags/

#
# Patches, diffs and VCS integration
#
*.diff
*.orig
*.patch
*.rej
*/.cvsignore
*/CVS/*
.cvsignore
/CVS/*

#
# Archives and packages
#
*.7z
*.bz2
*.bzip
*.deb
*.dmg
*.egg
*.gem
*.gz
*.iso
*.jar
*.lzma
*.rar
*.rpm
*.tar
*.xpi
*.xz
*.zip

#
# Platform specific noise
#
$RECYCLE.BIN/
.*
.AppleDouble
.DS_Store
.LSOverride
.Spotlight-V100
.Trashes
Desktop.ini
ehthumbs.db
Icon
Thumbs.db

#
# We don't want to ignore this file
#
!.gitignore
7 changes: 7 additions & 0 deletions research/particle-engine/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SUBDIRS = pe

ACLOCAL_AMFLAGS = -I build

# Note the order here is important. The examples subdirectory must appear after
# the pe subdirectory in the SUBDIRS variable.
SUBDIRS += examples
47 changes: 47 additions & 0 deletions research/particle-engine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Particle engines

This repository contains a few examples of particle systems, with demonstration applications of each. Each particle system consists of a two part frontend + backend relationship:

* **The backend**: this is a common backend which supplies a means for constructing and drawing a particle system using Cogl. This is reponsible for assembling a cogl primitive from the particle vertices and managing the memory associated with them. The interface is defined in `pe/particle-engine.h`, and its implementation can be found in `pe/particle-engine.c`.

* **The frontend**: this is responsible for modelling the behaviour, movement and lifespan of the particles. It is here that the particles are assigned characterstics which defines how they behave, such as swarming patterns, flocking or deterministic movement. There are several frontend implementations for different purposes:

* **Particle Swarm** - `pe/particle-swarm.h`
* **Particle Emitter** - `pe/particle-emitter.h`
* **Particle System** - `pe/particle-system.h`

## 1. Particle Swarm

This is a fairly standard emulation of the 1986 [Boids](http://en.wikipedia.org/wiki/Boids) program. It models each particle (or boid) as a simple entity whose behaviour is determiend by three rules:

1. **Cohesion** - a particle steers towards the center of mass of its surrounding particles.
2. **Alignment** - a particle attempts to mimic the movement of its surrounding particles.
3. **Separation** - a particle avoids other particles to prevent bumping into each other and to maintain a maximum swarm density.

Additionally, there are extra influences affecting a particle's movement:

4. **Boundaries** - particles are contained within a bounding area, and will steer to avoid going out of these bounds.
5. **Global forces** - a global force can be applied uniformly to each of the particles, for example to model the effects of strong wind or a current in water.
6. **Speed limits** - the speed of a particle is determined by it's size, and has minimum and maximum speeds enforced.

The implementation of these rules is contained within the `particle_apply_swarming_behaviour()` function in `pe/particle-swarm.c`. Additionally, there is a JavaScript+HTML5 implementation of this which models the flocking behaviour of birds, and can be found in the web directory.

### Examples
* `./examples/ants`
* `./examples/fish`
* `web/index.html`

## 2. Particle Emitter

### Examples
* `./examples/catherine_wheel`
* `./examples/fireworks`
* `./examples/fountains`
* `./examples/snow`

## 3. Particle System

A rough and ready model for simulating circular Kepler orbits of particles about a fixed center of mass.

### Examples
* `./examples/galaxy`
11 changes: 11 additions & 0 deletions research/particle-engine/autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/sh

autoreconf --install

test -n "$srcdir" || srcdir=`dirname "$0"`
test -n "$srcdir" || srcdir=.
(
cd "$srcdir" &&
autoreconf --force --verbose --install
) || exit
test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
30 changes: 30 additions & 0 deletions research/particle-engine/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# autoconf
AC_PREREQ(2.59)
AC_INIT([pe], [0.0.1], [christopher.e.cummins@intel.com])
AC_CONFIG_MACRO_DIR([build])
AC_CONFIG_AUX_DIR([build])
AC_CONFIG_SRCDIR([pe/particle-engine.c])
AC_CONFIG_HEADERS([config.h])

# automake
AM_INIT_AUTOMAKE([1.11 -Wall foreign no-define])
AM_SILENT_RULES([yes])

AC_PROG_CC
AC_HEADER_STDC

AM_PROG_AR
AM_PROG_CC_C_O

LT_INIT

AC_DEFINE(COGL_ENABLE_EXPERIMENTAL_API, [], [Use the experimental Cogl API])

PKG_CHECK_MODULES([COGL], [cogl2 >= 1.99.0])
PKG_CHECK_MODULES([GLIB], [glib-2.0])

AC_OUTPUT([
Makefile
examples/Makefile
pe/Makefile
])
7 changes: 7 additions & 0 deletions research/particle-engine/examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/ants
/fish
/catherine_wheel
/fireworks
/fountains
/galaxy
/snow
42 changes: 42 additions & 0 deletions research/particle-engine/examples/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
noinst_PROGRAMS =

AM_CFLAGS = \
$(COGL_CFLAGS) \
$(GLIB_CFLAGS) \
-I$(top_srcdir) \
-I$(top_srcdir)/pe \
-Wall \
-Wextra \
-Wstrict-prototypes \
-Wno-unused-parameter \
$(NULL)

LDADD = \
$(top_srcdir)/pe/.libs/libpe.la \
$(COGL_LIBS) \
$(GLIB_LIBS) \
-lm \
$(NULL)

EXTRA_DIST = run-demos.sh

noinst_PROGRAMS += ants
ants_SOURCES = ants.c

noinst_PROGRAMS += catherine_wheel
catherine_wheel_SOURCES = catherine-wheel.c

noinst_PROGRAMS += fireworks
fireworks_SOURCES = fireworks.c

noinst_PROGRAMS += fish
fish_SOURCES = fish.c

noinst_PROGRAMS += fountains
fountains_SOURCES = fountains.c

noinst_PROGRAMS += galaxy
galaxy_SOURCES = galaxy.c

noinst_PROGRAMS += snow
snow_SOURCES = snow.c

0 comments on commit 813593b

Please sign in to comment.