Permalink
Browse files

Particles with trails

  • Loading branch information...
bettsmatt committed Oct 16, 2012
2 parents c115732 + da311b0 commit 55cc08bfc2e1e536d9f6ca3ef7f98acf2c2b515b
Showing with 140,169 additions and 98 deletions.
  1. +13 −1 .cproject
  2. +6 −7 BSpline.cpp
  3. +1 −1 BSpline.h
  4. +2 −5 Ball.cpp
  5. +3 −4 Camera.cpp
  6. +18 −2 Collision.cpp
  7. +1 −1 ControlPoint.cpp
  8. +3 −1 ControlPoint.h
  9. +2 −0 GJK.cpp
  10. +1 −1 Makefile
  11. +69 −34 Particle.cpp
  12. +1 −1 Particle.h
  13. +10 −18 ParticleEmitter.cpp
  14. +11 −5 Skeleton.cpp
  15. +139,960 −0 bunny.obj
  16. +68 −17 main.cpp
View
@@ -38,7 +38,6 @@
<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>
@@ -52,4 +51,17 @@
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
+ <storageModule moduleId="refreshScope"/>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>make</buildCommand>
+ <buildArguments/>
+ <buildTarget>clean</buildTarget>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>true</useDefaultCommand>
+ <runAllBuilders>true</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
</cproject>
View
@@ -39,7 +39,7 @@ BSpline::~BSpline() {
}
void BSpline::init(){
- n = 3; // Degree of the curve
+ n = 3; // Degree of the curtestve
pointSelected = -1;
frames = NULL;
deltaTime = 0.01f;
@@ -80,8 +80,8 @@ void BSpline::assignColourId() {
//****************************************************************************
// DRAWING
//****************************************************************************
-void BSpline::draw(){
- drawControlPoints(GL_RENDER);
+void BSpline::draw(GLenum mode){
+ drawControlPoints(mode);
drawCurve();
}
@@ -108,8 +108,7 @@ void BSpline::drawControlPoints(GLenum mode) {
}
// draw the control points
for (int i = 0; i < controlPointsNum; i++) {
- //printf("i, pointSelected, point[i]: %i %i %f %f %f\n", i, pointSelected, controlPoints[i].x, controlPoints[i].y, controlPoints[i].z);
- controlPoints[i].draw(pointSelected == i);
+ controlPoints[i].draw(pointSelected == i, mode);
if(infoDisplay) controlPoints[i].showTime();
}
@@ -273,21 +272,21 @@ void BSpline::selectPoint(int x, int y){
glDisable(GL_FOG);
glDisable(GL_LIGHTING);
- drawControlPoints(GL_SELECT);
+ draw(GL_SELECT);
GLint viewport[4];
unsigned char pixel[3];
glGetIntegerv(GL_VIEWPORT, viewport); // get color information from frame buffer
glReadPixels(x, viewport[3] - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
- printf("pixel: %i %i %i\n", pixel[0], pixel[1], pixel[2]);
for (int i = 0; i < controlPointsNum; i++) {
if((controlPoints[i].r == pixel[0]) && (controlPoints[i].g == pixel[1]) && (controlPoints[i].b) == pixel[2]){
pointSelected = i;
break;
}
}
+
glutPostRedisplay();
}
View
@@ -60,7 +60,7 @@ class BSpline {
void printArray(float* a, int size);
void assignColourId();
- void draw();
+ void draw(GLenum mode);
void selectPoint(int x, int y);
void deselectPoint();
View
@@ -29,14 +29,11 @@ Ball::Ball(float* initialPosition, float* initialVelocity, bool sp) {
isSpecial = sp;
// Set initial velocity
- for(int i = 0 ; i < 3 ; i ++)
+ for(int i = 0 ; i < 3 ; i ++){
velocity[i] = initialVelocity[i];
-
- for(int i = 0 ; i < 3 ; i ++)
position[i] = initialPosition[i];
-
- for(int i = 0 ; i < 3 ; i ++)
acceletation[i] = 0;
+ }
mass = 1; // Default
View
@@ -80,15 +80,14 @@ void Camera::lookAt(BSpline* bs, int m, double winWidth, double winHeight, G308_
pos->y = f.ctrlPoint.y;
pos->z = f.ctrlPoint.z;
+ ref->N = ref->N + f.ctrlPoint;
+ ref->B = ref->B + f.ctrlPoint;
+
if (f.isLast == 1) {
if(m == 1) gluLookAt(f.ctrlPoint.x, f.ctrlPoint.y, f.ctrlPoint.z, 0, 0, 0, ref->B.x, ref->B.y,ref->B.z);
else if(m == 2) gluLookAt(f.ctrlPoint.x, f.ctrlPoint.y, f.ctrlPoint.z, ref->T.x, ref->T.y, ref->T.z, ref->B.x, ref->B.y,ref->B.z);
}
else{
- ref->N = ref->N + f.ctrlPoint;
- ref->B = ref->B + f.ctrlPoint;
-
- //printf("%i\nt: %f %f %f\tB: %f %f %f\n", count++, ref->T.x, ref->T.y, ref->T.z, ref->B.x, ref->B.y,ref->B.z);
if(m == 1) gluLookAt(f.ctrlPoint.x, f.ctrlPoint.y, f.ctrlPoint.z, 0, 0, 0, ref->B.x, ref->B.y,ref->B.z);
else if(m == 2) gluLookAt(f.ctrlPoint.x, f.ctrlPoint.y, f.ctrlPoint.z, ref->T.x, ref->T.y, ref->T.z, ref->B.x, ref->B.y,ref->B.z);
}
View
@@ -170,7 +170,7 @@ void Collision::checkCollision(double cor, Cube *c, Ball *b)
-
+ /*
// Get the center of the sphere relative to the center of the box
float* sphereCenterRelBox = new float[3];//Sphere.center - Box.center;
sphereCenterRelBox[0] = b->position[0] - c->position[0];
@@ -217,8 +217,24 @@ void Collision::checkCollision(double cor, Cube *c, Ball *b)
dist[1] = sphereCenterRelBox[1] - boxPoint[1];
dist[2] = sphereCenterRelBox[2] - boxPoint[2];
- if (dist[0]*dist[0] + dist[1]*dist[1] + dist[2]*dist[2] < b->mass*b->mass)
+ if (dist[0]*dist[0] + dist[1]*dist[1] + dist[2]*dist[2] < b->mass*b->mass){
printf("True\n");
+
+ float* test = new float[3];
+ test[1] = b->position[1] - b->velocity[1]; //Move back
+ test[0] = b->position[0] - b->velocity[0];
+ test[2] = b->position[2] - b->velocity[2];
+
+
+
+
+
+ }
+
+
+ delete[] sphereCenterRelBox;
+ delete[] boxPoint;
+ delete[] dist;*/
}
/*void Collision::checkCollision(double cor, G308_Geometry *g, Ball *b)
View
@@ -53,7 +53,7 @@ void ControlPoint::add(ControlPoint p){
z += p.z;
}
-void ControlPoint::draw(bool pointSelected){
+void ControlPoint::draw(bool pointSelected, GLenum mode){
glPushMatrix();
glColor3f(r / 255.0f, g / 255.0f, b / 255.0f);
if (pointSelected) {
View
@@ -8,6 +8,8 @@
#ifndef CONTROLPOINT_H_
#define CONTROLPOINT_H_
+#include <GL/glut.h>
+
class ControlPoint {
public:
float x,y,z;
@@ -22,7 +24,7 @@ class ControlPoint {
void setColourID(float rr, float gg, float bb);
void multiplyScalar(float);
void add(ControlPoint p);
- void draw(bool pointSelected);
+ void draw(bool pointSelected, GLenum mode);
void showTime();
void unprojectScreenCoord(int x, int y);
void normalize();
View
@@ -42,6 +42,7 @@ bool GJK::shapesIntersect(G308_Point* shape1, G308_Point* shape2, int shape1Coun
G308_Point A = maxPointInMinkDiffAlongDir(shape1, shape2, D);
if (pointDotProduct(A, D) < 0)
{
+ //printf("Miss\n");
return false;
}
@@ -50,6 +51,7 @@ bool GJK::shapesIntersect(G308_Point* shape1, G308_Point* shape2, int shape1Coun
if (updateSimplexAndDirection(simplex, D))
{
+ //printf("Hit\n");
return true;
}
}
View
@@ -1,7 +1,7 @@
CC = g++
LPATH = -L/usr/pkg/lib
LDPATH = -Wl,-R/usr/pkg/lib
-CFLAGS=-g -Wall
+CFLAGS=-g -Wall -Wextra -pedantic
LIBS=-lGL -lglut -lGLU -ljpeg -lpng15 -lm
IPATH= -I/usr/pkg/include
Oops, something went wrong.

0 comments on commit 55cc08b

Please sign in to comment.