Explorar el Código

Added animation test commands

Thomas Buck hace 10 años
padre
commit
7a4a5c0a96
Se han modificado 4 ficheros con 68 adiciones y 7 borrados
  1. 3
    1
      include/Render.h
  2. 58
    2
      src/Game.cpp
  3. 3
    0
      src/Render.cpp
  4. 4
    4
      src/World.cpp

+ 3
- 1
include/Render.h Ver fichero

212
 
212
 
213
     void addSkeletalModel(SkeletalModel *mdl);
213
     void addSkeletalModel(SkeletalModel *mdl);
214
 
214
 
215
+    unsigned int getFlags();
216
+
215
     //! \fixme should be private
217
     //! \fixme should be private
216
 
218
 
217
     ViewVolume mViewVolume; //!< View Volume for frustum culling
219
     ViewVolume mViewVolume; //!< View Volume for frustum culling
220
+    std::vector<SkeletalModel *> mModels;
218
 
221
 
219
 private:
222
 private:
220
 
223
 
331
 
334
 
332
     std::vector<RenderRoom *> mRoomRenderList;
335
     std::vector<RenderRoom *> mRoomRenderList;
333
     std::vector<RenderRoom *> mRooms;
336
     std::vector<RenderRoom *> mRooms;
334
-    std::vector<SkeletalModel *> mModels;
335
 
337
 
336
     unsigned int mFlags;                  //!< Rendering flags
338
     unsigned int mFlags;                  //!< Rendering flags
337
     unsigned int mMode;                   //!< Rendering mode
339
     unsigned int mMode;                   //!< Rendering mode

+ 58
- 2
src/Game.cpp Ver fichero

272
             gOpenRaider->mConsole->print("Invalid use of sound command!");
272
             gOpenRaider->mConsole->print("Invalid use of sound command!");
273
             return -11;
273
             return -11;
274
         }
274
         }
275
+    } else if (strcmp(cmd, "animate") == 0) {
276
+        if (args->size() > 1) {
277
+            char c = args->at(1)[0];
278
+            if (c == 'n') {
279
+                // Step all skeletal models to their next animation
280
+                if (mRender->getFlags() & Render::fAnimateAllModels) {
281
+                    for (unsigned int i = 0; i < mRender->mModels.size(); i++) {
282
+                        SkeletalModel *m = mRender->mModels[i];
283
+                        if (m->getAnimation() < ((int)m->model->animation.size() - 1))
284
+                            m->setAnimation(m->getAnimation() + 1);
285
+                        else
286
+                            if (m->getAnimation() != 0)
287
+                                m->setAnimation(0);
288
+                    }
289
+                } else {
290
+                    gOpenRaider->mConsole->print("Animations need to be enabled!");
291
+                }
292
+            } else if (c == 'p') {
293
+                // Step all skeletal models to their previous animation
294
+                if (mRender->getFlags() & Render::fAnimateAllModels) {
295
+                    for (unsigned int i = 0; i < mRender->mModels.size(); i++) {
296
+                        SkeletalModel *m = mRender->mModels[i];
297
+                        if (m->getAnimation() > 0)
298
+                            m->setAnimation(m->getAnimation() - 1);
299
+                        else
300
+                            if (m->model->animation.size() > 0)
301
+                                m->setAnimation(m->model->animation.size() - 1);
302
+                    }
303
+                } else {
304
+                    gOpenRaider->mConsole->print("Animations need to be enabled!");
305
+                }
306
+            } else {
307
+                // Enable or disable animating all skeletal models
308
+                bool b;
309
+                if (readBool(args->at(1), &b) < 0) {
310
+                    gOpenRaider->mConsole->print("Pass BOOL to animate command!");
311
+                    return -12;
312
+                }
313
+                if (b)
314
+                    mRender->setFlags(Render::fAnimateAllModels);
315
+                else
316
+                    mRender->clearFlags(Render::fAnimateAllModels);
317
+                gOpenRaider->mConsole->print(b ? "Animating all models" : "No longer animating all models");
318
+            }
319
+        } else {
320
+            gOpenRaider->mConsole->print("Invalid use of animate command!");
321
+            return -13;
322
+        }
275
     } else if (strcmp(cmd, "help") == 0) {
323
     } else if (strcmp(cmd, "help") == 0) {
276
         if (args->size() < 2) {
324
         if (args->size() < 2) {
277
             gOpenRaider->mConsole->print("game-command Usage:");
325
             gOpenRaider->mConsole->print("game-command Usage:");
280
             gOpenRaider->mConsole->print("  move [walk|fly|noclip]");
328
             gOpenRaider->mConsole->print("  move [walk|fly|noclip]");
281
             gOpenRaider->mConsole->print("  sound INT");
329
             gOpenRaider->mConsole->print("  sound INT");
282
             gOpenRaider->mConsole->print("  mode MODE");
330
             gOpenRaider->mConsole->print("  mode MODE");
331
+            gOpenRaider->mConsole->print("  animate [BOOL|n|p]");
283
         } else if (strcmp(args->at(1), "sound") == 0) {
332
         } else if (strcmp(args->at(1), "sound") == 0) {
284
             gOpenRaider->mConsole->print("game-sound-command Usage:");
333
             gOpenRaider->mConsole->print("game-sound-command Usage:");
285
             gOpenRaider->mConsole->print("  game sound INT");
334
             gOpenRaider->mConsole->print("  game sound INT");
300
             gOpenRaider->mConsole->print("  texture");
349
             gOpenRaider->mConsole->print("  texture");
301
             gOpenRaider->mConsole->print("  vertexlight");
350
             gOpenRaider->mConsole->print("  vertexlight");
302
             gOpenRaider->mConsole->print("  titlescreen");
351
             gOpenRaider->mConsole->print("  titlescreen");
352
+        } else if (strcmp(args->at(1), "animate") == 0) {
353
+            gOpenRaider->mConsole->print("game-animate-command Usage:");
354
+            gOpenRaider->mConsole->print("  game animate [n|p|BOOL]");
355
+            gOpenRaider->mConsole->print("Where the commands have the following meaning:");
356
+            gOpenRaider->mConsole->print("  BOOL to (de)activate animating all models");
357
+            gOpenRaider->mConsole->print("  n to step all models to their next animation");
358
+            gOpenRaider->mConsole->print("  p to step all models to their previous animation");
303
         } else {
359
         } else {
304
             gOpenRaider->mConsole->print("No help available for game %s.", args->at(1));
360
             gOpenRaider->mConsole->print("No help available for game %s.", args->at(1));
305
-            return -12;
361
+            return -14;
306
         }
362
         }
307
     } else {
363
     } else {
308
         gOpenRaider->mConsole->print("Invalid use of game-command (%s)!", cmd);
364
         gOpenRaider->mConsole->print("Invalid use of game-command (%s)!", cmd);
309
-        return -13;
365
+        return -15;
310
     }
366
     }
311
 
367
 
312
     return 0;
368
     return 0;

+ 3
- 0
src/Render.cpp Ver fichero

122
     mTexture.glScreenShot(filenameBase, gOpenRaider->mWindow->mWidth, gOpenRaider->mWindow->mHeight);
122
     mTexture.glScreenShot(filenameBase, gOpenRaider->mWindow->mWidth, gOpenRaider->mWindow->mHeight);
123
 }
123
 }
124
 
124
 
125
+unsigned int Render::getFlags() {
126
+    return mFlags;
127
+}
125
 
128
 
126
 ////////////////////////////////////////////////////////////
129
 ////////////////////////////////////////////////////////////
127
 // Public Mutators
130
 // Public Mutators

+ 4
- 4
src/World.cpp Ver fichero

153
     int sector;
153
     int sector;
154
     room_mesh_t *r;
154
     room_mesh_t *r;
155
 
155
 
156
-    if ((room < 0) || (room >= mRooms.size()))
156
+    if ((room < 0) || (room >= (int)mRooms.size()))
157
         return -1;
157
         return -1;
158
 
158
 
159
     r = mRooms[room];
159
     r = mRooms[room];
174
 unsigned int World::getRoomInfo(int room) {
174
 unsigned int World::getRoomInfo(int room) {
175
     room_mesh_t *r;
175
     room_mesh_t *r;
176
 
176
 
177
-    if ((room >= mRooms.size()) || (room < 0))
177
+    if ((room >= (int)mRooms.size()) || (room < 0))
178
         return 0;
178
         return 0;
179
 
179
 
180
     r = mRooms[room];
180
     r = mRooms[room];
190
     room_mesh_t *r;
190
     room_mesh_t *r;
191
     sector_t *sect;
191
     sector_t *sect;
192
 
192
 
193
-    if ((room >= mRooms.size()) || (room < 0))
193
+    if ((room >= (int)mRooms.size()) || (room < 0))
194
         return true;
194
         return true;
195
 
195
 
196
     r = mRooms[room];
196
     r = mRooms[room];
197
 
197
 
198
-    if ((!r) || (sector >= r->sectors.size()) || (sector < 0))
198
+    if ((!r) || (sector >= (int)r->sectors.size()) || (sector < 0))
199
         return true;
199
         return true;
200
 
200
 
201
     sect = r->sectors[sector];
201
     sect = r->sectors[sector];

Loading…
Cancelar
Guardar