command.h
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:13k
源码类别:

OpenGL

开发平台:

Visual C++

  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. #ifndef _COMMAND_H_
  10. #define _COMMAND_H_
  11. #define MAX_CONSTELLATIONS 100
  12. #include <iostream>
  13. #include <celutil/color.h>
  14. #include <celengine/execenv.h>
  15. #include <celengine/astro.h>
  16. class Command
  17. {
  18.  public:
  19.     Command() {};
  20.     virtual ~Command() {};
  21.     virtual void process(ExecutionEnvironment&, double t, double dt) = 0;
  22.     virtual double getDuration() const = 0;
  23. };
  24. typedef std::vector<Command*> CommandSequence;
  25. class InstantaneousCommand : public Command
  26. {
  27.  public:
  28.     InstantaneousCommand() {};
  29.     virtual ~InstantaneousCommand() {};
  30.     virtual double getDuration() const { return 0.0; };
  31.     virtual void process(ExecutionEnvironment&) = 0;
  32.     void process(ExecutionEnvironment& env, double /*t*/, double /*dt*/)
  33.     {
  34.         process(env);
  35.     };
  36. };
  37. class TimedCommand : public Command
  38. {
  39.  public:
  40.     TimedCommand(double _duration) : duration(_duration) {};
  41.     virtual ~TimedCommand() {};
  42.     double getDuration() const { return duration; };
  43.  private:
  44.     double duration;
  45. };
  46. class CommandWait : public TimedCommand
  47. {
  48.  public:
  49.     CommandWait(double _duration);
  50.     ~CommandWait();
  51.     void process(ExecutionEnvironment&, double t, double dt);
  52. };
  53. class CommandSelect : public InstantaneousCommand
  54. {
  55.  public:
  56.     CommandSelect(std::string _target);
  57.     ~CommandSelect();
  58.     void process(ExecutionEnvironment&);
  59.  private:
  60.     std::string target;
  61. };
  62. class CommandGoto : public InstantaneousCommand
  63. {
  64.  public:
  65.     CommandGoto(double t, double dist,
  66.                 Vec3f _up, ObserverFrame::CoordinateSystem _upFrame);
  67.     ~CommandGoto();
  68.     void process(ExecutionEnvironment&);
  69.  private:
  70.     double gotoTime;
  71.     double distance;
  72.     Vec3f up;
  73.     ObserverFrame::CoordinateSystem upFrame;
  74. };
  75. class CommandGotoLongLat : public InstantaneousCommand
  76. {
  77.  public:
  78.     CommandGotoLongLat(double t,
  79.                        double dist,
  80.                        float _longitude, float _latitude,
  81.                        Vec3f _up);
  82.     ~CommandGotoLongLat();
  83.     void process(ExecutionEnvironment&);
  84.  private:
  85.     double gotoTime;
  86.     double distance;
  87.     float longitude;
  88.     float latitude;
  89.     Vec3f up;
  90. };
  91. class CommandGotoLocation : public InstantaneousCommand
  92. {
  93.  public:
  94.     CommandGotoLocation(double t,
  95.                         const Point3d& translation, const Quatf& rotation);
  96.     ~CommandGotoLocation();
  97.     void process(ExecutionEnvironment&);
  98.  private:
  99.     double gotoTime;
  100.     Point3d translation;
  101.     Quatf rotation;
  102. };
  103. class CommandSetUrl : public InstantaneousCommand
  104. {
  105.  public:
  106.     CommandSetUrl(const std::string& _url);
  107.     void process(ExecutionEnvironment&);
  108.  private:
  109.     std::string url;
  110. };
  111. class CommandCenter : public InstantaneousCommand
  112. {
  113.  public:
  114.     CommandCenter(double t);
  115.     ~CommandCenter();
  116.     void process(ExecutionEnvironment&);
  117.  private:
  118.     double centerTime;
  119. };
  120. class CommandFollow : public InstantaneousCommand
  121. {
  122.  public:
  123.     CommandFollow();
  124.     void process(ExecutionEnvironment&);
  125.  private:
  126.     int dummy;   // Keep the class from having zero size
  127. };
  128. class CommandSynchronous : public InstantaneousCommand
  129. {
  130.  public:
  131.     CommandSynchronous();
  132.     void process(ExecutionEnvironment&);
  133.  private:
  134.     int dummy;   // Keep the class from having zero size
  135. };
  136. class CommandLock : public InstantaneousCommand
  137. {
  138.  public:
  139.     CommandLock();
  140.     void process(ExecutionEnvironment&);
  141.  private:
  142.     int dummy;
  143. };
  144. class CommandChase : public InstantaneousCommand
  145. {
  146.  public:
  147.     CommandChase();
  148.     void process(ExecutionEnvironment&);
  149.  private:
  150.     int dummy;
  151. };
  152. class CommandTrack : public InstantaneousCommand
  153. {
  154.  public:
  155.     CommandTrack();
  156.     void process(ExecutionEnvironment&);
  157.  private:
  158.     int dummy;
  159. };
  160. class CommandSetFrame : public InstantaneousCommand
  161. {
  162.  public:
  163.     CommandSetFrame(ObserverFrame::CoordinateSystem,
  164.                     const std::string&, const std::string&);
  165.     void process(ExecutionEnvironment&);
  166.  private:
  167.     ObserverFrame::CoordinateSystem coordSys;
  168.     std::string refObjectName;
  169.     std::string targetObjectName;
  170. };
  171. class CommandSetSurface : public InstantaneousCommand
  172. {
  173.  public:
  174.     CommandSetSurface(const std::string&);
  175.     void process(ExecutionEnvironment&);
  176.  private:
  177.     std::string surfaceName;
  178. };
  179. class CommandCancel : public InstantaneousCommand
  180. {
  181.  public:
  182.     CommandCancel();
  183.     void process(ExecutionEnvironment&);
  184.  private:
  185.     int dummy;   // Keep the class from having zero size
  186. };
  187. class CommandExit : public InstantaneousCommand
  188. {
  189.  public:
  190.     CommandExit();
  191.     void process(ExecutionEnvironment&);
  192.  private:
  193.     int dummy;   // Keep the class from having zero size
  194. };
  195. class CommandPrint : public InstantaneousCommand
  196. {
  197.  public:
  198.     CommandPrint(std::string, int horig, int vorig, int hoff, int voff,
  199.                  double duration);
  200.     void process(ExecutionEnvironment&);
  201.  private:
  202.     std::string text;
  203.     int hOrigin;
  204.     int vOrigin;
  205.     int hOffset;
  206.     int vOffset;
  207.     double duration;
  208. };
  209. class CommandClearScreen : public InstantaneousCommand
  210. {
  211.  public:
  212.     CommandClearScreen();
  213.     void process(ExecutionEnvironment&);
  214.  private:
  215.     int dummy;   // Keep the class from having zero size
  216. };
  217. class CommandSetTime : public InstantaneousCommand
  218. {
  219.  public:
  220.     CommandSetTime(double _jd);
  221.     void process(ExecutionEnvironment&);
  222.  private:
  223.     double jd;
  224. };
  225. class CommandSetTimeRate : public InstantaneousCommand
  226. {
  227.  public:
  228.     CommandSetTimeRate(double);
  229.     void process(ExecutionEnvironment&);
  230.  private:
  231.     double rate;
  232. };
  233. class CommandChangeDistance : public TimedCommand
  234. {
  235.  public:
  236.     CommandChangeDistance(double duration, double rate);
  237.     void process(ExecutionEnvironment&, double t, double dt);
  238.  private:
  239.     double rate;
  240. };
  241. class CommandOrbit : public TimedCommand
  242. {
  243.  public:
  244.     CommandOrbit(double _duration, const Vec3f& axis, float rate);
  245.     void process(ExecutionEnvironment&, double t, double dt);
  246.  private:
  247.     Vec3f spin;
  248. };
  249. class CommandRotate : public TimedCommand
  250. {
  251.  public:
  252.     CommandRotate(double _duration, const Vec3f& axis, float rate);
  253.     void process(ExecutionEnvironment&, double t, double dt);
  254.  private:
  255.     Vec3f spin;
  256. };
  257. class CommandMove : public TimedCommand
  258. {
  259.  public:
  260.     CommandMove(double _duration, const Vec3d& _velocity);
  261.     void process(ExecutionEnvironment&, double t, double dt);
  262.  private:
  263.     Vec3d velocity;
  264. };
  265. class CommandSetPosition : public InstantaneousCommand
  266. {
  267.  public:
  268.     CommandSetPosition(const UniversalCoord&);
  269.     void process(ExecutionEnvironment&);
  270.  private:
  271.     UniversalCoord pos;
  272. };
  273. class CommandSetOrientation : public InstantaneousCommand
  274. {
  275.  public:
  276.     CommandSetOrientation(const Vec3f&, float);
  277.     void process(ExecutionEnvironment&);
  278.  private:
  279.     Vec3f axis;
  280.     float angle;
  281. };
  282. class CommandLookBack : public InstantaneousCommand
  283. {
  284.  public:
  285.     CommandLookBack();
  286.     void process(ExecutionEnvironment&);
  287.  private:
  288.     int dummy;   // Keep the class from having zero size
  289. };
  290. class CommandRenderFlags : public InstantaneousCommand
  291. {
  292.  public:
  293.     CommandRenderFlags(int _setFlags, int _clearFlags);
  294.     void process(ExecutionEnvironment&);
  295.  private:
  296.     int setFlags;
  297.     int clearFlags;
  298. };
  299. class CommandConstellations : public InstantaneousCommand
  300. {
  301.  public:
  302.     CommandConstellations();
  303.     void process(ExecutionEnvironment&);
  304. void setValues(string cons, int act);
  305.     std::string constellation[MAX_CONSTELLATIONS];
  306. int active[MAX_CONSTELLATIONS];
  307.     int numConstellations;
  308. int all;
  309.     int none;
  310. };
  311. class CommandConstellationColor : public InstantaneousCommand
  312. {
  313.  public:
  314.     CommandConstellationColor();
  315.     void process(ExecutionEnvironment&);
  316. void setConstellations(string cons);
  317. void setColor(float r, float g, float b);
  318. void unsetColor();
  319.     std::string constellation[MAX_CONSTELLATIONS];
  320. Color rgb;
  321. int unset;
  322.     int numConstellations;
  323. int all;
  324.     int none;
  325. };
  326. class CommandLabels : public InstantaneousCommand
  327. {
  328.  public:
  329.     CommandLabels(int _setFlags, int _clearFlags);
  330.     void process(ExecutionEnvironment&);
  331.  private:
  332.     int setFlags;
  333.     int clearFlags;
  334. };
  335. class CommandOrbitFlags : public InstantaneousCommand
  336. {
  337.  public:
  338.     CommandOrbitFlags(int _setFlags, int _clearFlags);
  339.     void process(ExecutionEnvironment&);
  340.  private:
  341.     int setFlags;
  342.     int clearFlags;
  343. };
  344. class CommandSetVisibilityLimit : public InstantaneousCommand
  345. {
  346.  public:
  347.     CommandSetVisibilityLimit(double);
  348.     void process(ExecutionEnvironment&);
  349.  private:
  350.     double magnitude;
  351. };
  352. class CommandSetFaintestAutoMag45deg : public InstantaneousCommand
  353. {
  354.  public:
  355.     CommandSetFaintestAutoMag45deg(double);
  356.     void process(ExecutionEnvironment&);
  357.  private:
  358.     double magnitude;
  359. };
  360. class CommandSetAmbientLight : public InstantaneousCommand
  361. {
  362.  public:
  363.     CommandSetAmbientLight(float);
  364.     void process(ExecutionEnvironment&);
  365.  private:
  366.     float lightLevel;
  367. };
  368. class CommandSetGalaxyLightGain : public InstantaneousCommand
  369. {
  370.  public:
  371.     CommandSetGalaxyLightGain(float);
  372.     void process(ExecutionEnvironment&);
  373.  private:
  374.     float lightGain;
  375. };
  376. class CommandSet : public InstantaneousCommand
  377. {
  378.  public:
  379.     CommandSet(const std::string&, double);
  380.     void process(ExecutionEnvironment&);
  381.  private:
  382.     std::string name;
  383.     double value;
  384. };
  385. class CommandPreloadTextures : public InstantaneousCommand
  386. {
  387.  public:
  388.     CommandPreloadTextures(const std::string&);
  389.     void process(ExecutionEnvironment&);
  390.  private:
  391.     std::string name;
  392. };
  393. class CommandMark : public InstantaneousCommand
  394. {
  395.  public:
  396.     CommandMark(const std::string&, MarkerRepresentation);
  397.     void process(ExecutionEnvironment&);
  398.  private:
  399.     std::string target;
  400.     MarkerRepresentation rep;
  401. };
  402. class CommandUnmark : public InstantaneousCommand
  403. {
  404.  public:
  405.     CommandUnmark(const std::string&);
  406.     void process(ExecutionEnvironment&);
  407.  private:
  408.     std::string target;
  409. };
  410. class CommandUnmarkAll : public InstantaneousCommand
  411. {
  412.  public:
  413.     CommandUnmarkAll();
  414.     void process(ExecutionEnvironment&);
  415.  private:
  416.     int dummy;   // Keep the class from having zero size
  417. };
  418. class CommandCapture : public InstantaneousCommand
  419. {
  420.  public:
  421.     CommandCapture(const std::string&, const std::string&);
  422.     void process(ExecutionEnvironment&);
  423.  private:
  424.     std::string type;
  425.     std::string filename;
  426. };
  427. class CommandSetTextureResolution : public InstantaneousCommand
  428. {
  429.  public:
  430.     CommandSetTextureResolution(unsigned int);
  431.     void process(ExecutionEnvironment&);
  432.  private:
  433.     unsigned int res;
  434. };
  435. class CommandRenderPath : public InstantaneousCommand
  436. {
  437.  public:
  438.     CommandRenderPath(GLContext::GLRenderPath);
  439.     void process(ExecutionEnvironment&);
  440.  private:
  441.     GLContext::GLRenderPath path;
  442. };
  443. class CommandSplitView : public InstantaneousCommand
  444. {
  445.  public:
  446.     CommandSplitView(unsigned int, const std::string&, double);
  447.     void process(ExecutionEnvironment&);
  448.  private:
  449.     unsigned int view;
  450.     std::string splitType;
  451.     double splitPos;
  452. };
  453. class CommandDeleteView : public InstantaneousCommand
  454. {
  455.  public:
  456.     CommandDeleteView(unsigned int);
  457.     void process(ExecutionEnvironment&);
  458.  private:
  459.     unsigned int view;
  460. };
  461. class CommandSingleView : public InstantaneousCommand
  462. {
  463.  public:
  464.     CommandSingleView();
  465.     void process(ExecutionEnvironment&);
  466. };
  467. class CommandSetActiveView : public InstantaneousCommand
  468. {
  469.  public:
  470.     CommandSetActiveView(unsigned int);
  471.     void process(ExecutionEnvironment&);
  472.  private:
  473.     unsigned int view;
  474. };
  475. class CommandSetRadius : public InstantaneousCommand
  476. {
  477.  public:
  478.     CommandSetRadius(const std::string&, double);
  479.     void process(ExecutionEnvironment&);
  480.  private:
  481.     std::string object;
  482.     double radius;
  483. };
  484. class CommandSetLineColor : public InstantaneousCommand
  485. {
  486.  public:
  487.     CommandSetLineColor(const std::string&, Color);
  488.     void process(ExecutionEnvironment&);
  489.  private:
  490.     std::string item;
  491.     Color color;
  492. };
  493. class CommandSetLabelColor : public InstantaneousCommand
  494. {
  495.  public:
  496.     CommandSetLabelColor(const std::string&, Color);
  497.     void process(ExecutionEnvironment&);
  498.  private:
  499.     std::string item;
  500.     Color color;
  501. };
  502. class Execution;
  503. class RepeatCommand : public Command
  504. {
  505.  public:
  506.     RepeatCommand(CommandSequence* _body, int _repeatCount);
  507.     ~RepeatCommand();
  508.     void process(ExecutionEnvironment&, double t, double dt) = 0;
  509.     double getDuration();
  510.  private:
  511.     CommandSequence* body;
  512.     double bodyDuration;
  513.     int repeatCount;
  514.     Execution* execution;
  515. };
  516. #endif // _COMMAND_H_