00001 /* 00002 * Physically Based Simulation, SS 2005 00003 * 00004 * Markus Liechti (liechtim@student.ethz.ch) 00005 * Yoshimi Takano (yoshi@student.ethz.ch) 00006 * Stefan Wismer (swismer@student.ethz.ch) 00007 * 00008 * $Id: train.h,v 1.7 2005/06/25 20:18:50 ytakano Exp $ 00009 */ 00010 00013 #ifndef __train_H__ 00014 #define __train_H__ 00015 00016 #include <vector> 00017 #include <cmath> 00018 #include "opengl.h" 00019 #include "bridge.h" 00020 #include "structures.h" 00021 00023 #define COACH_STIFFNESS 20000000.0 00024 00026 #define MASS_FACTOR 25 00027 00031 struct coach { 00033 component mass; 00034 00036 component length, height; 00037 00039 GLfloat texLeft, texRight, texTop, texBottom; 00040 00041 bool brokenAfterwards; 00042 }; 00043 00047 class Train { 00048 private: 00049 char filenameTexture[255]; 00050 char filenameMask[255]; 00051 SDL_Surface *texture, *mask; 00052 00053 bool stopTrain; 00054 Bridge *bridge; 00055 00056 void loadTextures(); 00057 00058 public: 00060 vector<coach> coaches; 00061 00063 component trainLength; 00064 00066 vector<vertex> coachVertices; 00067 00069 vector<edge> coachEdges; 00070 00072 int textureWidth, textureHeight; 00073 00075 unsigned char *image; 00076 00078 bool hasSmoke; 00079 00081 Smoke smoke; 00082 00084 vector2 smokeSource; 00085 00089 void draw(); 00090 00094 bool loadFromFile(char *filename); 00095 00100 bool initialize(Bridge &bridge); 00101 00107 bool doPhysics(component timestep); 00108 00112 void finalize(); 00113 00117 void cleanUp(); 00118 }; 00119 00120 #endif