1 // command.h 2 // 3 // Copyright (C) 2001 Chris Laurel <claurel@shatters.net> 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License 7 // as published by the Free Software Foundation; either version 2 8 // of the License, or (at your option) any later version. 9 10 #ifndef _COMMAND_H_ 11 #define _COMMAND_H_ 12 13 #define MAX_CONSTELLATIONS 100 14 15 #include <iostream> 16 #include <celutil/color.h> 17 #include <celengine/execenv.h> 18 #include <celengine/astro.h> 19 20 21 class Command 22 { 23 public: Command()24 Command() {}; ~Command()25 virtual ~Command() {}; 26 virtual void process(ExecutionEnvironment&, double t, double dt) = 0; 27 virtual double getDuration() const = 0; 28 }; 29 30 typedef std::vector<Command*> CommandSequence; 31 32 33 class InstantaneousCommand : public Command 34 { 35 public: InstantaneousCommand()36 InstantaneousCommand() {}; ~InstantaneousCommand()37 virtual ~InstantaneousCommand() {}; getDuration()38 virtual double getDuration() const { return 0.0; }; 39 virtual void process(ExecutionEnvironment&) = 0; process(ExecutionEnvironment & env,double,double)40 void process(ExecutionEnvironment& env, double /*t*/, double /*dt*/) 41 { 42 process(env); 43 }; 44 }; 45 46 47 class TimedCommand : public Command 48 { 49 public: TimedCommand(double _duration)50 TimedCommand(double _duration) : duration(_duration) {}; ~TimedCommand()51 virtual ~TimedCommand() {}; getDuration()52 double getDuration() const { return duration; }; 53 54 private: 55 double duration; 56 }; 57 58 59 class CommandWait : public TimedCommand 60 { 61 public: 62 CommandWait(double _duration); 63 ~CommandWait(); 64 void process(ExecutionEnvironment&, double t, double dt); 65 }; 66 67 68 class CommandSelect : public InstantaneousCommand 69 { 70 public: 71 CommandSelect(std::string _target); 72 ~CommandSelect(); 73 void process(ExecutionEnvironment&); 74 75 private: 76 std::string target; 77 }; 78 79 80 class CommandGoto : public InstantaneousCommand 81 { 82 public: 83 CommandGoto(double t, double dist, 84 Vec3f _up, ObserverFrame::CoordinateSystem _upFrame); 85 ~CommandGoto(); 86 void process(ExecutionEnvironment&); 87 88 private: 89 double gotoTime; 90 double distance; 91 Vec3f up; 92 ObserverFrame::CoordinateSystem upFrame; 93 }; 94 95 96 class CommandGotoLongLat : public InstantaneousCommand 97 { 98 public: 99 CommandGotoLongLat(double t, 100 double dist, 101 float _longitude, float _latitude, 102 Vec3f _up); 103 ~CommandGotoLongLat(); 104 void process(ExecutionEnvironment&); 105 106 private: 107 double gotoTime; 108 double distance; 109 float longitude; 110 float latitude; 111 Vec3f up; 112 }; 113 114 115 class CommandGotoLocation : public InstantaneousCommand 116 { 117 public: 118 CommandGotoLocation(double t, 119 const Point3d& translation, const Quatf& rotation); 120 ~CommandGotoLocation(); 121 void process(ExecutionEnvironment&); 122 123 private: 124 double gotoTime; 125 Point3d translation; 126 Quatf rotation; 127 }; 128 129 class CommandSetUrl : public InstantaneousCommand 130 { 131 public: 132 CommandSetUrl(const std::string& _url); 133 void process(ExecutionEnvironment&); 134 135 private: 136 std::string url; 137 }; 138 139 140 class CommandCenter : public InstantaneousCommand 141 { 142 public: 143 CommandCenter(double t); 144 ~CommandCenter(); 145 void process(ExecutionEnvironment&); 146 147 private: 148 double centerTime; 149 }; 150 151 152 class CommandFollow : public InstantaneousCommand 153 { 154 public: 155 CommandFollow(); 156 void process(ExecutionEnvironment&); 157 158 private: 159 int dummy; // Keep the class from having zero size 160 }; 161 162 163 class CommandSynchronous : public InstantaneousCommand 164 { 165 public: 166 CommandSynchronous(); 167 void process(ExecutionEnvironment&); 168 169 private: 170 int dummy; // Keep the class from having zero size 171 }; 172 173 174 class CommandLock : public InstantaneousCommand 175 { 176 public: 177 CommandLock(); 178 void process(ExecutionEnvironment&); 179 180 private: 181 int dummy; 182 }; 183 184 185 class CommandChase : public InstantaneousCommand 186 { 187 public: 188 CommandChase(); 189 void process(ExecutionEnvironment&); 190 191 private: 192 int dummy; 193 }; 194 195 196 class CommandTrack : public InstantaneousCommand 197 { 198 public: 199 CommandTrack(); 200 void process(ExecutionEnvironment&); 201 202 private: 203 int dummy; 204 }; 205 206 207 class CommandSetFrame : public InstantaneousCommand 208 { 209 public: 210 CommandSetFrame(ObserverFrame::CoordinateSystem, 211 const std::string&, const std::string&); 212 void process(ExecutionEnvironment&); 213 214 private: 215 ObserverFrame::CoordinateSystem coordSys; 216 std::string refObjectName; 217 std::string targetObjectName; 218 }; 219 220 221 class CommandSetSurface : public InstantaneousCommand 222 { 223 public: 224 CommandSetSurface(const std::string&); 225 void process(ExecutionEnvironment&); 226 227 private: 228 std::string surfaceName; 229 }; 230 231 232 class CommandCancel : public InstantaneousCommand 233 { 234 public: 235 CommandCancel(); 236 void process(ExecutionEnvironment&); 237 238 private: 239 int dummy; // Keep the class from having zero size 240 }; 241 242 243 class CommandExit : public InstantaneousCommand 244 { 245 public: 246 CommandExit(); 247 void process(ExecutionEnvironment&); 248 249 private: 250 int dummy; // Keep the class from having zero size 251 }; 252 253 254 class CommandPrint : public InstantaneousCommand 255 { 256 public: 257 CommandPrint(std::string, int horig, int vorig, int hoff, int voff, 258 double duration); 259 void process(ExecutionEnvironment&); 260 261 private: 262 std::string text; 263 int hOrigin; 264 int vOrigin; 265 int hOffset; 266 int vOffset; 267 double duration; 268 }; 269 270 271 class CommandClearScreen : public InstantaneousCommand 272 { 273 public: 274 CommandClearScreen(); 275 void process(ExecutionEnvironment&); 276 277 private: 278 int dummy; // Keep the class from having zero size 279 }; 280 281 282 class CommandSetTime : public InstantaneousCommand 283 { 284 public: 285 CommandSetTime(double _jd); 286 void process(ExecutionEnvironment&); 287 288 private: 289 double jd; 290 }; 291 292 293 class CommandSetTimeRate : public InstantaneousCommand 294 { 295 public: 296 CommandSetTimeRate(double); 297 void process(ExecutionEnvironment&); 298 299 private: 300 double rate; 301 }; 302 303 304 class CommandChangeDistance : public TimedCommand 305 { 306 public: 307 CommandChangeDistance(double duration, double rate); 308 void process(ExecutionEnvironment&, double t, double dt); 309 310 private: 311 double rate; 312 }; 313 314 315 class CommandOrbit : public TimedCommand 316 { 317 public: 318 CommandOrbit(double _duration, const Vec3f& axis, float rate); 319 void process(ExecutionEnvironment&, double t, double dt); 320 321 private: 322 Vec3f spin; 323 }; 324 325 326 class CommandRotate : public TimedCommand 327 { 328 public: 329 CommandRotate(double _duration, const Vec3f& axis, float rate); 330 void process(ExecutionEnvironment&, double t, double dt); 331 332 private: 333 Vec3f spin; 334 }; 335 336 337 class CommandMove : public TimedCommand 338 { 339 public: 340 CommandMove(double _duration, const Vec3d& _velocity); 341 void process(ExecutionEnvironment&, double t, double dt); 342 343 private: 344 Vec3d velocity; 345 }; 346 347 348 class CommandSetPosition : public InstantaneousCommand 349 { 350 public: 351 CommandSetPosition(const UniversalCoord&); 352 void process(ExecutionEnvironment&); 353 354 private: 355 UniversalCoord pos; 356 }; 357 358 359 class CommandSetOrientation : public InstantaneousCommand 360 { 361 public: 362 CommandSetOrientation(const Vec3f&, float); 363 void process(ExecutionEnvironment&); 364 365 private: 366 Vec3f axis; 367 float angle; 368 }; 369 370 class CommandLookBack : public InstantaneousCommand 371 { 372 public: 373 CommandLookBack(); 374 void process(ExecutionEnvironment&); 375 376 private: 377 int dummy; // Keep the class from having zero size 378 }; 379 380 381 class CommandRenderFlags : public InstantaneousCommand 382 { 383 public: 384 CommandRenderFlags(int _setFlags, int _clearFlags); 385 void process(ExecutionEnvironment&); 386 387 private: 388 int setFlags; 389 int clearFlags; 390 }; 391 392 393 class CommandConstellations : public InstantaneousCommand 394 { 395 public: 396 CommandConstellations(); 397 void process(ExecutionEnvironment&); 398 void setValues(string cons, int act); 399 std::string constellation[MAX_CONSTELLATIONS]; 400 int active[MAX_CONSTELLATIONS]; 401 int numConstellations; 402 int all; 403 int none; 404 }; 405 406 407 class CommandConstellationColor : public InstantaneousCommand 408 { 409 public: 410 CommandConstellationColor(); 411 void process(ExecutionEnvironment&); 412 void setConstellations(string cons); 413 void setColor(float r, float g, float b); 414 void unsetColor(); 415 std::string constellation[MAX_CONSTELLATIONS]; 416 Color rgb; 417 int unset; 418 int numConstellations; 419 int all; 420 int none; 421 }; 422 423 424 class CommandLabels : public InstantaneousCommand 425 { 426 public: 427 CommandLabels(int _setFlags, int _clearFlags); 428 void process(ExecutionEnvironment&); 429 430 private: 431 int setFlags; 432 int clearFlags; 433 }; 434 435 436 class CommandOrbitFlags : public InstantaneousCommand 437 { 438 public: 439 CommandOrbitFlags(int _setFlags, int _clearFlags); 440 void process(ExecutionEnvironment&); 441 442 private: 443 int setFlags; 444 int clearFlags; 445 }; 446 447 448 class CommandSetVisibilityLimit : public InstantaneousCommand 449 { 450 public: 451 CommandSetVisibilityLimit(double); 452 void process(ExecutionEnvironment&); 453 454 private: 455 double magnitude; 456 }; 457 458 class CommandSetFaintestAutoMag45deg : public InstantaneousCommand 459 { 460 public: 461 CommandSetFaintestAutoMag45deg(double); 462 void process(ExecutionEnvironment&); 463 464 private: 465 double magnitude; 466 }; 467 468 class CommandSetAmbientLight : public InstantaneousCommand 469 { 470 public: 471 CommandSetAmbientLight(float); 472 void process(ExecutionEnvironment&); 473 474 private: 475 float lightLevel; 476 }; 477 478 479 class CommandSetGalaxyLightGain : public InstantaneousCommand 480 { 481 public: 482 CommandSetGalaxyLightGain(float); 483 void process(ExecutionEnvironment&); 484 485 private: 486 float lightGain; 487 }; 488 489 490 class CommandSet : public InstantaneousCommand 491 { 492 public: 493 CommandSet(const std::string&, double); 494 void process(ExecutionEnvironment&); 495 496 private: 497 std::string name; 498 double value; 499 }; 500 501 502 class CommandPreloadTextures : public InstantaneousCommand 503 { 504 public: 505 CommandPreloadTextures(const std::string&); 506 void process(ExecutionEnvironment&); 507 508 private: 509 std::string name; 510 }; 511 512 513 class CommandMark : public InstantaneousCommand 514 { 515 public: 516 CommandMark(const std::string&, MarkerRepresentation, bool); 517 void process(ExecutionEnvironment&); 518 519 private: 520 std::string target; 521 MarkerRepresentation rep; 522 bool occludable; 523 }; 524 525 526 class CommandUnmark : public InstantaneousCommand 527 { 528 public: 529 CommandUnmark(const std::string&); 530 void process(ExecutionEnvironment&); 531 532 private: 533 std::string target; 534 }; 535 536 537 class CommandUnmarkAll : public InstantaneousCommand 538 { 539 public: 540 CommandUnmarkAll(); 541 void process(ExecutionEnvironment&); 542 543 private: 544 int dummy; // Keep the class from having zero size 545 }; 546 547 548 class CommandCapture : public InstantaneousCommand 549 { 550 public: 551 CommandCapture(const std::string&, const std::string&); 552 void process(ExecutionEnvironment&); 553 554 private: 555 std::string type; 556 std::string filename; 557 }; 558 559 560 class CommandSetTextureResolution : public InstantaneousCommand 561 { 562 public: 563 CommandSetTextureResolution(unsigned int); 564 void process(ExecutionEnvironment&); 565 566 private: 567 unsigned int res; 568 }; 569 570 571 class CommandRenderPath : public InstantaneousCommand 572 { 573 public: 574 CommandRenderPath(GLContext::GLRenderPath); 575 void process(ExecutionEnvironment&); 576 577 private: 578 GLContext::GLRenderPath path; 579 }; 580 581 582 class CommandSplitView : public InstantaneousCommand 583 { 584 public: 585 CommandSplitView(unsigned int, const std::string&, double); 586 void process(ExecutionEnvironment&); 587 588 private: 589 unsigned int view; 590 std::string splitType; 591 double splitPos; 592 }; 593 594 595 class CommandDeleteView : public InstantaneousCommand 596 { 597 public: 598 CommandDeleteView(unsigned int); 599 void process(ExecutionEnvironment&); 600 601 private: 602 unsigned int view; 603 }; 604 605 606 class CommandSingleView : public InstantaneousCommand 607 { 608 public: 609 CommandSingleView(); 610 void process(ExecutionEnvironment&); 611 }; 612 613 614 class CommandSetActiveView : public InstantaneousCommand 615 { 616 public: 617 CommandSetActiveView(unsigned int); 618 void process(ExecutionEnvironment&); 619 620 private: 621 unsigned int view; 622 }; 623 624 625 class CommandSetRadius : public InstantaneousCommand 626 { 627 public: 628 CommandSetRadius(const std::string&, double); 629 void process(ExecutionEnvironment&); 630 631 private: 632 std::string object; 633 double radius; 634 }; 635 636 637 class CommandSetLineColor : public InstantaneousCommand 638 { 639 public: 640 CommandSetLineColor(const std::string&, Color); 641 void process(ExecutionEnvironment&); 642 643 private: 644 std::string item; 645 Color color; 646 }; 647 648 649 class CommandSetLabelColor : public InstantaneousCommand 650 { 651 public: 652 CommandSetLabelColor(const std::string&, Color); 653 void process(ExecutionEnvironment&); 654 655 private: 656 std::string item; 657 Color color; 658 }; 659 660 661 class CommandSetTextColor : public InstantaneousCommand 662 { 663 public: 664 CommandSetTextColor(Color); 665 void process(ExecutionEnvironment&); 666 667 private: 668 Color color; 669 }; 670 671 672 class Execution; 673 674 class RepeatCommand : public Command 675 { 676 public: 677 RepeatCommand(CommandSequence* _body, int _repeatCount); 678 ~RepeatCommand(); 679 void process(ExecutionEnvironment&, double t, double dt) = 0; 680 double getDuration(); 681 682 private: 683 CommandSequence* body; 684 double bodyDuration; 685 int repeatCount; 686 Execution* execution; 687 }; 688 689 690 691 #endif // _COMMAND_H_ 692