Changeset 4300 in orxonox.OLD for orxonox/branches/physics/src
- Timestamp:
- May 26, 2005, 3:17:24 PM (20 years ago)
- Location:
- orxonox/branches/physics/src/subprojects/particles
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/subprojects/particles/framework.cc
r4298 r4300 24 24 #include "debug.h" 25 25 #include "graphics_engine.h" 26 #include "light.h" 26 27 #include "resource_manager.h" 27 28 #include "camera.h" … … 41 42 42 43 // Draw the scene 43 draw(dt); 44 draw(dt); 44 45 } 45 46 } … … 58 59 59 60 } 61 62 60 63 float Framework::tick() 61 64 { 62 65 currFrame = SDL_GetTicks(); 63 float dt = (float)(currFrame - lastFrame) /1000.0; 64 if (dt == 0) 65 dist += (zoomTo-dist); 66 else 67 dist += (zoomTo-dist) *(float)dt; 68 rotatorP += rotatorV *(float)dt; 66 float dt = (float)(currFrame - lastFrame) / 1000.0; 67 lastFrame = currFrame; 69 68 70 69 ParticleEngine::getInstance()->tick(dt); 71 72 lastFrame = currFrame;73 70 74 71 NullParent::getInstance()->update(dt); … … 121 118 p1 = p2; 122 119 */ 120 123 121 124 122 } … … 128 126 { 129 127 PRINTF(4)("MouseWheel up\n"); 130 zoomTo *= .5;128 // zoomTo *= .5; 131 129 } 132 130 else if (event.button.button == 5) 133 131 { 134 132 PRINTF(4)("MouseWheel down\n"); 135 zoomTo *= 2.0;133 // zoomTo *= 2.0; 136 134 } 137 135 else if (event.button.button == 1) 138 136 { 139 137 mouse1Down = true; 140 int mX = event.button.x; 141 int mY = event.button.y; 142 int wH = GraphicsEngine::getInstance()->getResolutionY(); 143 int wW = GraphicsEngine::getInstance()->getResolutionX(); 144 Vector tmpV (mX, mY, sqrt ( (float) abs(wH * wH/4 - (wW/2-mX) * (wW/2-mX) - (wH/2-mY) * (wH/2-mY)) )); 145 p1 = tmpV-M; 146 p1.y = -p1.y; 147 138 movement[0] = event.button.x; 139 movement[1] = event.button.y; 140 movement[2] = 0; 141 movement[3] = 0; 142 printf("test %d %d\n", movement[0], movement[1]); 143 /* 144 int mX = event.button.x; 145 int mY = event.button.y; 146 int wH = GraphicsEngine::getInstance()->getResolutionY(); 147 int wW = GraphicsEngine::getInstance()->getResolutionX(); 148 Vector tmpV (mX, mY, sqrt ( (float) abs(wH * wH/4 - (wW/2-mX) * (wW/2-mX) - (wH/2-mY) * (wH/2-mY)) )); 149 p1 = tmpV-M; 150 p1.y = -p1.y; 151 */ 148 152 } 149 153 else … … 151 155 PRINTF(0)("MouseButton %d pressed at (%d,%d).\n", 152 156 event.button.button, event.button.x, event.button.y); 153 rotatorV = ( (float)GraphicsEngine::getInstance()->getResolutionY()/2 -event.button.x) / (float)GraphicsEngine::getInstance()->getResolutionY() / 100.0;154 157 } 155 158 … … 181 184 break; 182 185 case SDLK_a: 183 zoomTo /=2;186 //zoomTo /=2; 184 187 break; 185 188 case SDLK_z: 186 zoomTo *=2;187 189 //zoomTo *=2; 190 break; 188 191 } 189 192 break; … … 210 213 211 214 212 215 Framework::Framework() 213 216 { 214 217 … … 219 222 220 223 221 M = Vector(GraphicsEngine::getInstance()->getResolutionY()/2, GraphicsEngine::getInstance()->getResolutionX()/2, 0); 222 rotAxis = Vector (0.0,1.0,0.0); 223 rotAngle = 0; 224 225 matQ[0][0] = matQ[1][1] = matQ[2][2] = matQ[3][3] = 1; 226 rotQ = Quaternion (rotAngle, rotAxis); 227 rotQlast = rotQ; 228 dir = Vector (0.0, 0.0, 1.0); 229 up = Vector (0.0, 1.0, 0.0); 230 231 glEnable(GL_LIGHTING); 232 glEnable(GL_DEPTH_TEST); 233 234 GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0}; 235 GLfloat light0Position[] = {10.0, 10.0, 10.0, 0.0}; 236 GLfloat light1Position[] = {-10.0, -7.0, -6.0, 0.0}; 237 GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0}; 238 239 glEnable(GL_LIGHT0); 240 glLightfv(GL_LIGHT0, GL_POSITION, light0Position); 241 glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight); 242 glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight); 243 244 glEnable(GL_LIGHT1); 245 glLightfv(GL_LIGHT1, GL_POSITION, light1Position); 246 glLightfv(GL_LIGHT1, GL_DIFFUSE, whiteLight); 247 glLightfv(GL_LIGHT1, GL_SPECULAR, whiteLight); 248 249 224 LightManager::getInstance(); 250 225 glEnable(GL_TEXTURE_2D); 251 rotatorP = .0; 252 rotatorV = .0; 253 dist = 5.0; 254 zoomTo = dist; 226 255 227 // Build the font from a TGA image font.tga in the data directory 256 228 // Hide the mouse cursor … … 260 232 ResourceManager::getInstance()->setDataDir(DATA_DIRECTORY); 261 233 262 234 // Creating a Test Particle System 263 235 ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE); 264 236 system->setLifeSpan(5); 265 system->setConserve( 1);237 system->setConserve(.99); 266 238 system->setRadius(4, 3, 1, 2); 267 239 system->setColor(.5,0,0,.5, 1,1,0,1, 0,0,0,0); 268 240 269 241 // Creating a Test Particle Emitter 270 ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0), 0, 100, .01);242 ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0), M_PI_4, 20, .1); 271 243 emitter->setType(EMITTER_DOT ); 272 244 emitter->setSize(0); -
orxonox/branches/physics/src/subprojects/particles/framework.h
r4297 r4300 13 13 private: 14 14 Camera* camera; 15 float rotatorP;16 float rotatorV;17 15 18 float dist; 19 float zoomTo; 16 int movement [4]; 20 17 21 18 Uint32 lastFrame; 22 19 Uint32 currFrame; 23 24 Vector dir; 25 Vector up; 26 27 float matQ[4][4]; 28 29 Vector M; 30 Vector p1; 31 Vector p2; 32 Vector rotAxis; 33 float rotAngle; 34 Quaternion rotQ; 35 Quaternion rotQlast; 36 20 37 21 Uint8* keys; // This variable will be used in the keyboard routine 38 22 bool mouse1Down; 23 bool mouse2Down; 39 24 40 25 public:
Note: See TracChangeset
for help on using the changeset viewer.