Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: bettsmatt/BetaFX
base: d33e2801e7
...
head fork: bettsmatt/BetaFX
compare: 9c6889201c
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
40 .cproject
@@ -3,8 +3,8 @@
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
- <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1117717657">
- <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1117717657" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1387531906">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1387531906" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
@@ -16,17 +16,29 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.1117717657" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
- <folderInfo id="cdt.managedbuild.toolchain.gnu.base.1117717657.1154557254" name="/" resourcePath="">
- <toolChain id="cdt.managedbuild.toolchain.gnu.base.646186142" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
- <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1003008130" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
- <builder id="cdt.managedbuild.target.gnu.builder.base.575303207" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/>
- <tool id="cdt.managedbuild.tool.gnu.archiver.base.2122346734" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
- <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.440159698" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
- <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1067243657" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/>
- <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1349121597" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
- <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1935765714" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
- <tool id="cdt.managedbuild.tool.gnu.assembler.base.1626387459" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/>
+ <configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.1387531906" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="cdt.managedbuild.toolchain.gnu.base.1387531906.1358919173" name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.base.1115649109" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
+ <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1377043919" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
+ <builder id="cdt.managedbuild.target.gnu.builder.base.1136645911" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.2049046458" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.670141226" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.88242875" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1041169262" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.909571602" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.base.55228079" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.518055245" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.447282572" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.base.2060099739" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1582393259" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+
</toolChain>
</folderInfo>
</configuration>
@@ -35,7 +47,7 @@
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <project id="BetaFX.null.96281249" name="BetaFX"/>
+ <project id="BetaFx.null.741242528" name="BetaFx"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
View
BIN  BetaFX
Binary file not shown
View
14 Particle.cpp
@@ -33,13 +33,6 @@ Particle::Particle(float* initialVelocity) {
mass = 1; // Default
-
- /*
- * Color
- */
-
- color = new float [3];
-
/*
* Lifespan
*/
@@ -170,7 +163,7 @@ void Particle::applyAttractiveForce(Particle* p1, Particle* p2, float strength,
// Vector between particles
for(int i = 0 ; i < 3 ; i ++)
- vec[i] = p1->position[i] - p2->position[i];
+ vec[i] = p2->position[i] - p1->position[i];
// Distance
float dist = sqrt(
@@ -182,7 +175,7 @@ void Particle::applyAttractiveForce(Particle* p1, Particle* p2, float strength,
// Close enough
if(dist < minDist){
- float f = (strength * p1->mass * p2->mass) / (dist / dist);
+ float f = (strength * p1->mass * p2->mass) / (dist * dist);
float* vecN = new float[3];
@@ -193,13 +186,14 @@ void Particle::applyAttractiveForce(Particle* p1, Particle* p2, float strength,
// Apply to each particle
p1->applyForce(vecN);
+ /* Limited to one way
// Invert for p2
for(int i = 0 ; i < 3 ; i ++)
vecN[i] = -vecN[i];
// Apply to p2
p2->applyForce(vecN);
-
+ */
}
free(vec);
View
4 Particle.h
@@ -19,6 +19,7 @@
#include "define.h"
#include <GL/glut.h>
+#include <queue>
class Particle
{
@@ -32,9 +33,6 @@ class Particle
int lifeSpan;
- float* color;
-
-
public:
int lifeSpanLeft;
float* position; // x, y, z
View
80 ParticleEmitter.cpp
@@ -34,15 +34,51 @@ ParticleEmitter::ParticleEmitter(void) {
created = 0;
gravityOn = false;
- float* v = new float[3];
- gravity = new Particle(v);
- float* p = new float[3];
- p[0] = 5;
- p[1] = 0;
+ numGravity = 3;
+
+ float** v = (float**) malloc (sizeof (float) * numGravity);
+ float** p = (float**) malloc (sizeof (float) * numGravity);
+
+ for(int i = 0 ; i < numGravity ; i ++){
+ v[i] = new float[3];
+ p[i] = new float[3];
+ }
+
+ p[0][0] = 10;
+ p[1][0] = -10;
+ p[2][2] = 10;
+
+ for(int i = 0 ; i < numGravity ; i ++){
+
+ // Up
+ float* up = new float[3];
+ up[1] = 1;
+
+ // Take cross product of position and z, multiply by some number
+ v[i][0] = (up[1] * p[i][2] - up[2] * p[i][1]) * 0.001f;
+ v[i][1] = (up[2] * p[i][0] - up[0] * p[i][2]) * 0.001f;
+ v[i][2] = (up[0] * p[i][1] - up[1] * p[i][0]) * 0.001f;
+
+
+ }
+
+
+
+
+
+ /*
+ * Test Gravity Wells
+ */
+ numGravity = 3;
+ gravity = (Particle**) malloc (sizeof(Particle*) * numGravity);
+ for(int i = 0 ; i < numGravity ; i ++){
+ gravity[i] = new Particle(v[i]);
+ gravity[i]->setPosition(p[i]);
+ }
+
- setGravity(p);
- gravityOn=true;
+ gravityOn = true;
}
@@ -121,15 +157,29 @@ void ParticleEmitter::tick(){
// Alive!
if(!particles[i]->isDead()){
- //particles[i]->applyForce(force);
- particles[i]->tick(); // Simulate
- particles[i]->applyFriction(0.0001f);
+
+ particles[i]->applyFriction(0.001f);
if(gravityOn)
- particles[i]->applyAttractiveForce(particles[i],gravity,-0.002f,100);
+ for(int j = 0 ; j < numGravity ; j ++)
+ particles[i]->applyAttractiveForce(particles[i], gravity[j], 0.2f, 100);
+
+ particles[i]->tick(); // Simulate
}
+
+ for(int i = 0 ; i < numGravity ; i ++){
+ for(int j = 0 ; j < numGravity ; j ++){
+ if(i != j)
+ gravity[i]->applyAttractiveForce(gravity[i], gravity[j], 0.002f, 1000);
+ }
+ }
+
+ for(int i = 0 ; i < numGravity ; i ++){
+ gravity[i]->tick();
+ }
+
}
void ParticleEmitter::applyWind(float* wind){
@@ -190,9 +240,6 @@ void ParticleEmitter::setVector(float* v){
}
-void ParticleEmitter::setGravity(float* pos){
- gravity->setPosition(pos);
-}
void ParticleEmitter::turnGravityOn(){
gravityOn = true;
}
@@ -235,6 +282,8 @@ void ParticleEmitter::renderParticles() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+
// Loop through all active particles drawing them
for(int i = 0; i < MAX_PARTICLES && i < created ; i ++)
@@ -246,7 +295,8 @@ void ParticleEmitter::renderParticles() {
glDisable(GL_POINT_SPRITE_ARB);
glDisable(GL_TEXTURE_2D);
- gravity->renderParticle();
+ for(int i = 0; i < numGravity ; i ++)
+ gravity[i]->renderParticle();
glPopMatrix();
View
3  ParticleEmitter.h
@@ -38,7 +38,8 @@ class ParticleEmitter
int created;
int index;
- Particle* gravity;
+ int numGravity;
+ Particle** gravity;
bool gravityOn;
public:
View
17 main.cpp
@@ -164,6 +164,21 @@ void tick (){
particeEmitter->collideWithBalls(balls[i], c);
}
+
+ /*
+ * Rotate the camera for effect
+ */
+ /*
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(G308_FOVY, (double) g_nWinWidth / (double) g_nWinHeight, G308_ZNEAR_3D, G308_ZFAR_3D);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ float x = sin(camAngle) * 50.0f;
+ float z = cos(camAngle) * 50.0f;
+ */
+
for(int i = 0; i < maxBalls; i++){
for(int j = 0; j < 5; j++){
c->checkCollision(1.0, cubes[j], balls[i]);
@@ -354,7 +369,7 @@ void G308_keyboardListener(unsigned char key, int x, int y) {
}
if(key == 'e')
- for(int i = 0 ; i < 50 ; i ++)
+ for(int i = 0 ; i < 100 ; i ++)
particeEmitter->emit();
// b,n,m decide which coordinate of the control point to change.

No commit comments for this range

Something went wrong with that request. Please try again.