Quellcode durchsuchen

Added animation test commands

Thomas Buck vor 10 Jahren
Ursprung
Commit
7a4a5c0a96
4 geänderte Dateien mit 68 neuen und 7 gelöschten Zeilen
  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 Datei anzeigen

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

+ 58
- 2
src/Game.cpp Datei anzeigen

@@ -272,6 +272,54 @@ int Game::command(std::vector<char *> *args) {
272 272
             gOpenRaider->mConsole->print("Invalid use of sound command!");
273 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 323
     } else if (strcmp(cmd, "help") == 0) {
276 324
         if (args->size() < 2) {
277 325
             gOpenRaider->mConsole->print("game-command Usage:");
@@ -280,6 +328,7 @@ int Game::command(std::vector<char *> *args) {
280 328
             gOpenRaider->mConsole->print("  move [walk|fly|noclip]");
281 329
             gOpenRaider->mConsole->print("  sound INT");
282 330
             gOpenRaider->mConsole->print("  mode MODE");
331
+            gOpenRaider->mConsole->print("  animate [BOOL|n|p]");
283 332
         } else if (strcmp(args->at(1), "sound") == 0) {
284 333
             gOpenRaider->mConsole->print("game-sound-command Usage:");
285 334
             gOpenRaider->mConsole->print("  game sound INT");
@@ -300,13 +349,20 @@ int Game::command(std::vector<char *> *args) {
300 349
             gOpenRaider->mConsole->print("  texture");
301 350
             gOpenRaider->mConsole->print("  vertexlight");
302 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 359
         } else {
304 360
             gOpenRaider->mConsole->print("No help available for game %s.", args->at(1));
305
-            return -12;
361
+            return -14;
306 362
         }
307 363
     } else {
308 364
         gOpenRaider->mConsole->print("Invalid use of game-command (%s)!", cmd);
309
-        return -13;
365
+        return -15;
310 366
     }
311 367
 
312 368
     return 0;

+ 3
- 0
src/Render.cpp Datei anzeigen

@@ -122,6 +122,9 @@ void Render::screenShot(char *filenameBase)
122 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 130
 // Public Mutators

+ 4
- 4
src/World.cpp Datei anzeigen

@@ -153,7 +153,7 @@ int World::getSector(int room, float x, float z) {
153 153
     int sector;
154 154
     room_mesh_t *r;
155 155
 
156
-    if ((room < 0) || (room >= mRooms.size()))
156
+    if ((room < 0) || (room >= (int)mRooms.size()))
157 157
         return -1;
158 158
 
159 159
     r = mRooms[room];
@@ -174,7 +174,7 @@ int World::getSector(int room, float x, float z) {
174 174
 unsigned int World::getRoomInfo(int room) {
175 175
     room_mesh_t *r;
176 176
 
177
-    if ((room >= mRooms.size()) || (room < 0))
177
+    if ((room >= (int)mRooms.size()) || (room < 0))
178 178
         return 0;
179 179
 
180 180
     r = mRooms[room];
@@ -190,12 +190,12 @@ bool World::isWall(int room, int sector) {
190 190
     room_mesh_t *r;
191 191
     sector_t *sect;
192 192
 
193
-    if ((room >= mRooms.size()) || (room < 0))
193
+    if ((room >= (int)mRooms.size()) || (room < 0))
194 194
         return true;
195 195
 
196 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 199
         return true;
200 200
 
201 201
     sect = r->sectors[sector];

Laden…
Abbrechen
Speichern