Kaynağa Gözat

Added animation command

Thomas Buck 10 yıl önce
ebeveyn
işleme
9364789280
2 değiştirilmiş dosya ile 53 ekleme ve 58 silme
  1. 1
    0
      ChangeLog.md
  2. 52
    58
      src/Command.cpp

+ 1
- 0
ChangeLog.md Dosyayı Görüntüle

@@ -4,6 +4,7 @@
4 4
 
5 5
     [ 20140617 ]
6 6
     * Finally fixed SkeletalModel bug introduced a month ago
7
+    * Reimplemented *animate* command
7 8
 
8 9
     [ 20140615 ]
9 10
     * Added FontManager, selecting Font library to use depending on

+ 52
- 58
src/Command.cpp Dosyayı Görüntüle

@@ -64,6 +64,7 @@ int OpenRaider::command(std::string &c) {
64 64
     std::stringstream command(c);
65 65
     std::string cmd;
66 66
     command >> cmd;
67
+    command >> std::boolalpha >> std::ws;
67 68
 
68 69
     if (cmd.length() == 0)
69 70
         return 0;
@@ -98,12 +99,12 @@ int OpenRaider::command(std::string &c) {
98 99
             getConsole().print("  load      - load a level");
99 100
             getConsole().print("  set       - set a parameter");
100 101
             getConsole().print("  bind      - bind a keyboard/mouse action");
102
+            getConsole().print("  animate   - [BOOL|n|p] - Animate models");
101 103
 /*
102 104
             getConsole().print("  sshot     - make a screenshot");
103 105
             getConsole().print("  move      - [walk|fly|noclip]");
104 106
             getConsole().print("  sound     - INT - Test play sound");
105 107
             getConsole().print("  mode      - MODE - Render mode");
106
-            getConsole().print("  animate   - [BOOL|n|p] - Animate models");
107 108
             getConsole().print("  light     - BOOL - GL Lights");
108 109
             getConsole().print("  fog       - BOOL - GL Fog");
109 110
             getConsole().print("  viewmodel - INT - Change Laras model");
@@ -122,9 +123,57 @@ int OpenRaider::command(std::string &c) {
122 123
             getConsole().print("  help      - print command help");
123 124
             getConsole().print("  quit      - exit OpenRaider");
124 125
             getConsole().print("Use help COMMAND to get additional info");
126
+            getConsole().print("Pass BOOLs as true or false");
125 127
         } else {
126 128
             return help(tmp);
127 129
         }
130
+    } else if (cmd.compare("animate") == 0) {
131
+        if ((!mRunning) || (!getGame().isLoaded())) {
132
+            getConsole().print("Use animate command interactively!");
133
+            return -999;
134
+        }
135
+        if (command.peek() == 'n') {
136
+            // Step all skeletal models to their next animation
137
+            if (getRender().getFlags() & Render::fAnimateAllModels) {
138
+                for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
139
+                    Entity &e = getWorld().getEntity(i);
140
+                    SkeletalModel &m = e.getModel();
141
+                    if (e.getAnimation() < (m.size() - 1))
142
+                        e.setAnimation(e.getAnimation() + 1);
143
+                    else
144
+                        e.setAnimation(0);
145
+                }
146
+            } else {
147
+                getConsole().print("Animations need to be enabled!");
148
+            }
149
+        } else if (command.peek() == 'p') {
150
+            // Step all skeletal models to their previous animation
151
+            if (getRender().getFlags() & Render::fAnimateAllModels) {
152
+                for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
153
+                    Entity &e = getWorld().getEntity(i);
154
+                    SkeletalModel &m = e.getModel();
155
+                    if (e.getAnimation() > 0)
156
+                        e.setAnimation(e.getAnimation() - 1);
157
+                    else
158
+                        if (m.size() > 0)
159
+                            e.setAnimation(m.size() - 1);
160
+                }
161
+            } else {
162
+                getConsole().print("Animations need to be enabled!");
163
+            }
164
+        } else {
165
+            // Enable or disable animating all skeletal models
166
+            bool b = false;
167
+            if (!(command >> b)) {
168
+                getConsole().print("Pass BOOL to animate command!");
169
+                return -2;
170
+            }
171
+            if (b)
172
+                getRender().setFlags(Render::fAnimateAllModels);
173
+            else
174
+                getRender().clearFlags(Render::fAnimateAllModels);
175
+            getConsole().print(b ? "Animating all models" : "No longer animating all models");
176
+        }
128 177
 /*
129 178
     } else if (cmd.compare("mode") == 0) {
130 179
         std::string mode;
@@ -375,59 +424,6 @@ int OpenRaider::command(std::string &c) {
375 424
             getConsole().print("Invalid use of sound command!");
376 425
             return -12;
377 426
         }
378
-    } else if (cmd.compare("animate") == 0) {
379
-        if ((!mRunning) || (!getGame().isLoaded())) {
380
-            getConsole().print("Use animate command interactively!");
381
-            return -999;
382
-        }
383
-        if (args->size() > 0) {
384
-            char c = args->at(0)[0];
385
-            if (c == 'n') {
386
-                // Step all skeletal models to their next animation
387
-                if (getRender().getFlags() & Render::fAnimateAllModels) {
388
-                    for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
389
-                        Entity &e = getWorld().getEntity(i);
390
-                        SkeletalModel &m = e.getModel();
391
-                        if (e.getAnimation() < (m.size() - 1))
392
-                            e.setAnimation(e.getAnimation() + 1);
393
-                        else
394
-                            e.setAnimation(0);
395
-                    }
396
-                } else {
397
-                    getConsole().print("Animations need to be enabled!");
398
-                }
399
-            } else if (c == 'p') {
400
-                // Step all skeletal models to their previous animation
401
-                if (getRender().getFlags() & Render::fAnimateAllModels) {
402
-                    for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
403
-                        Entity &e = getWorld().getEntity(i);
404
-                        SkeletalModel &m = e.getModel();
405
-                        if (e.getAnimation() > 0)
406
-                            e.setAnimation(e.getAnimation() - 1);
407
-                        else
408
-                            if (m.size() > 0)
409
-                                e.setAnimation(m.size() - 1);
410
-                    }
411
-                } else {
412
-                    getConsole().print("Animations need to be enabled!");
413
-                }
414
-            } else {
415
-                // Enable or disable animating all skeletal models
416
-                bool b;
417
-                if (readBool(args->at(0), &b) < 0) {
418
-                    getConsole().print("Pass BOOL to animate command!");
419
-                    return -13;
420
-                }
421
-                if (b)
422
-                    getRender().setFlags(Render::fAnimateAllModels);
423
-                else
424
-                    getRender().clearFlags(Render::fAnimateAllModels);
425
-                getConsole().print(b ? "Animating all models" : "No longer animating all models");
426
-            }
427
-        } else {
428
-            getConsole().print("Invalid use of animate command!");
429
-            return -14;
430
-        }
431 427
     } else if (cmd.compare("viewmodel") == 0) {
432 428
         if ((!mRunning) || (!getGame().isLoaded())) {
433 429
             getConsole().print("Use viewmodel command interactively!");
@@ -526,8 +522,6 @@ int OpenRaider::help(std::string &cmd) {
526 522
         getConsole().print("load-Command Usage:");
527 523
         getConsole().print("  load levelfile.name");
528 524
 /*
529
-    } else if (cmd.compare("game") == 0) {
530
-        getConsole().print("Use \"game help\" for more info");
531 525
     } else if (cmd.compare("sshot") == 0) {
532 526
         getConsole().print("sshot-Command Usage:");
533 527
         getConsole().print("  sshot [console|menu]");
@@ -552,6 +546,7 @@ int OpenRaider::help(std::string &cmd) {
552 546
         getConsole().print("  texture");
553 547
         getConsole().print("  vertexlight");
554 548
         getConsole().print("  titlescreen");
549
+*/
555 550
     } else if (cmd.compare("animate") == 0) {
556 551
         getConsole().print("animate-Command Usage:");
557 552
         getConsole().print("  animate [n|p|BOOL]");
@@ -559,7 +554,6 @@ int OpenRaider::help(std::string &cmd) {
559 554
         getConsole().print("  BOOL to (de)activate animating all models");
560 555
         getConsole().print("  n to step all models to their next animation");
561 556
         getConsole().print("  p to step all models to their previous animation");
562
-*/
563 557
     } else {
564 558
         getConsole().print("No help available for %s", cmd.c_str());
565 559
         return -1;
@@ -614,7 +608,7 @@ char *OpenRaider::expandDirectoryNames(const char *s) {
614 608
 
615 609
 int OpenRaider::set(std::istream &command) {
616 610
     std::string var;
617
-    command >> var >> std::boolalpha;
611
+    command >> var;
618 612
 
619 613
     if (var.compare("size") == 0) {
620 614
         unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;

Loading…
İptal
Kaydet