vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Console.h
Go to the documentation of this file.
1 #include <vrecko/Ability.h>
3 #include <vrecko/Timer.h>
4 
5 #include <osg/Geode>
6 #include <osgText/Text>
7 #include <osgText/Font>
8 #include <osg/BlendFunc>
9 #include <osg/Material>
10 #include <osg/StateSet>
11 #include <osg/Camera>
12 
13 #include <vector>
14 
15 #define CONSOLE_NO_ANIMATOR
16 
17 #include "../ObjectUtils/Animator.h"
18 
19 
20 // These constants might be also used in the LoadingConsole(.cpp)
21 #define CONSOLE_WINDOW_DEPTH -1000.0f
22 
23 #define CONSOLE_BORDER_X_RATIO 0.3f
24 #define CONSOLE_BORDER_Y_RATIO CONSOLE_BORDER_X_RATIO
25 #define CONSOLE_LINE_SPACE_CHAR_RATIO 0.3f
26 
27 #define CONSOLE_FONT "fonts/arial.ttf"
28 #define CONSOLE_CHAR_SIZE 15
29 
30 #define CONSOLE_TEXTCOLOR_NOTICE (osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f))
31 #define CONSOLE_TEXTCOLOR_WARNING (osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f))
32 #define CONSOLE_TEXTCOLOR_ERROR (osg::Vec4(1.0f, 0.5f, 0.5f, 1.0f))
33 #define CONSOLE_TEXTCOLOR_DEBUG (osg::Vec4(0.3f, 1.0f, 0.3f, 1.0f))
34 
35 
36 
37 using namespace vrecko;
38 
39 namespace APTextOutput {
40 
41 class Console: public Ability {
42  public:
43  Console();
44  ~Console();
45 
46  virtual void preInitialize();
47  virtual void postInitialize();
48  virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *pParametersNode);
49  virtual void update(void);
50 
51  void addLine(const char *line, const osg::Vec4 &color = *((osg::Vec4*)NULL));
52 
53  protected:
54  class Line {
55  public:
56  osg::ref_ptr<osgText::Text> text;
57  osg::Timer_t logTime; // from osg::Timer::instance()->tick()
58  osg::Timer_t necessaryTime; // time necessary to read (after that it will scroll away)
59  };
60 
61  std::vector<Line> lines;
62 
63  int viewWidth, viewHeight;
64  int borderXSize, borderYSize, lineSpace;
65  float slideMax;
66 
67  osg::Timer_t menuAwayTime; // when we should animate the menu away? (0 = already is away)
68 
69  bool bNewItemAdded; // was the new item added (informative variable for te update() method)
70 
71  osg::ref_ptr<vrecko::EnvironmentObject> eo;
73  osg::ref_ptr<osg::Camera> camera;
74  osg::ref_ptr<osg::Geode> geode;
75  osg::ref_ptr<osg::Geometry> geom;
76 
78 };
79 
80 }
81 
82