Quellcode durchsuchen

Added animation command

Thomas Buck vor 11 Jahren
Ursprung
Commit
9364789280
2 geänderte Dateien mit 53 neuen und 58 gelöschten Zeilen
  1. 1
    0
      ChangeLog.md
  2. 52
    58
      src/Command.cpp

+ 1
- 0
ChangeLog.md Datei anzeigen

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

+ 52
- 58
src/Command.cpp Datei anzeigen

64
     std::stringstream command(c);
64
     std::stringstream command(c);
65
     std::string cmd;
65
     std::string cmd;
66
     command >> cmd;
66
     command >> cmd;
67
+    command >> std::boolalpha >> std::ws;
67
 
68
 
68
     if (cmd.length() == 0)
69
     if (cmd.length() == 0)
69
         return 0;
70
         return 0;
98
             getConsole().print("  load      - load a level");
99
             getConsole().print("  load      - load a level");
99
             getConsole().print("  set       - set a parameter");
100
             getConsole().print("  set       - set a parameter");
100
             getConsole().print("  bind      - bind a keyboard/mouse action");
101
             getConsole().print("  bind      - bind a keyboard/mouse action");
102
+            getConsole().print("  animate   - [BOOL|n|p] - Animate models");
101
 /*
103
 /*
102
             getConsole().print("  sshot     - make a screenshot");
104
             getConsole().print("  sshot     - make a screenshot");
103
             getConsole().print("  move      - [walk|fly|noclip]");
105
             getConsole().print("  move      - [walk|fly|noclip]");
104
             getConsole().print("  sound     - INT - Test play sound");
106
             getConsole().print("  sound     - INT - Test play sound");
105
             getConsole().print("  mode      - MODE - Render mode");
107
             getConsole().print("  mode      - MODE - Render mode");
106
-            getConsole().print("  animate   - [BOOL|n|p] - Animate models");
107
             getConsole().print("  light     - BOOL - GL Lights");
108
             getConsole().print("  light     - BOOL - GL Lights");
108
             getConsole().print("  fog       - BOOL - GL Fog");
109
             getConsole().print("  fog       - BOOL - GL Fog");
109
             getConsole().print("  viewmodel - INT - Change Laras model");
110
             getConsole().print("  viewmodel - INT - Change Laras model");
122
             getConsole().print("  help      - print command help");
123
             getConsole().print("  help      - print command help");
123
             getConsole().print("  quit      - exit OpenRaider");
124
             getConsole().print("  quit      - exit OpenRaider");
124
             getConsole().print("Use help COMMAND to get additional info");
125
             getConsole().print("Use help COMMAND to get additional info");
126
+            getConsole().print("Pass BOOLs as true or false");
125
         } else {
127
         } else {
126
             return help(tmp);
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
     } else if (cmd.compare("mode") == 0) {
178
     } else if (cmd.compare("mode") == 0) {
130
         std::string mode;
179
         std::string mode;
375
             getConsole().print("Invalid use of sound command!");
424
             getConsole().print("Invalid use of sound command!");
376
             return -12;
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
     } else if (cmd.compare("viewmodel") == 0) {
427
     } else if (cmd.compare("viewmodel") == 0) {
432
         if ((!mRunning) || (!getGame().isLoaded())) {
428
         if ((!mRunning) || (!getGame().isLoaded())) {
433
             getConsole().print("Use viewmodel command interactively!");
429
             getConsole().print("Use viewmodel command interactively!");
526
         getConsole().print("load-Command Usage:");
522
         getConsole().print("load-Command Usage:");
527
         getConsole().print("  load levelfile.name");
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
     } else if (cmd.compare("sshot") == 0) {
525
     } else if (cmd.compare("sshot") == 0) {
532
         getConsole().print("sshot-Command Usage:");
526
         getConsole().print("sshot-Command Usage:");
533
         getConsole().print("  sshot [console|menu]");
527
         getConsole().print("  sshot [console|menu]");
552
         getConsole().print("  texture");
546
         getConsole().print("  texture");
553
         getConsole().print("  vertexlight");
547
         getConsole().print("  vertexlight");
554
         getConsole().print("  titlescreen");
548
         getConsole().print("  titlescreen");
549
+*/
555
     } else if (cmd.compare("animate") == 0) {
550
     } else if (cmd.compare("animate") == 0) {
556
         getConsole().print("animate-Command Usage:");
551
         getConsole().print("animate-Command Usage:");
557
         getConsole().print("  animate [n|p|BOOL]");
552
         getConsole().print("  animate [n|p|BOOL]");
559
         getConsole().print("  BOOL to (de)activate animating all models");
554
         getConsole().print("  BOOL to (de)activate animating all models");
560
         getConsole().print("  n to step all models to their next animation");
555
         getConsole().print("  n to step all models to their next animation");
561
         getConsole().print("  p to step all models to their previous animation");
556
         getConsole().print("  p to step all models to their previous animation");
562
-*/
563
     } else {
557
     } else {
564
         getConsole().print("No help available for %s", cmd.c_str());
558
         getConsole().print("No help available for %s", cmd.c_str());
565
         return -1;
559
         return -1;
614
 
608
 
615
 int OpenRaider::set(std::istream &command) {
609
 int OpenRaider::set(std::istream &command) {
616
     std::string var;
610
     std::string var;
617
-    command >> var >> std::boolalpha;
611
+    command >> var;
618
 
612
 
619
     if (var.compare("size") == 0) {
613
     if (var.compare("size") == 0) {
620
         unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;
614
         unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;

Laden…
Abbrechen
Speichern