NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgSimViewGraphics.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
19 #ifndef TG_SIM_VIEW_GRAPHICS_H
20 #define TG_SIM_VIEW_GRAPHICS_H
21 
28 // This application
29 #include "tgSimView.h"
30 #include "tgBulletRenderer.h"
31 // Bullet OpenGL_FreeGlut (patched files)
32 #include "tgGlutStuff.h"
33 // The Bullet Physics library
34 #ifdef _WINDOWS
35 #include "Win32DemoApplication.h"
36 #define PlatformDemoApplication Win32DemoApplication
37 #else
38 #include "tgGlutDemoApplication.h"
39 #define PlatformDemoApplication tgGlutDemoApplication
40 #endif
41 
42 #include "LinearMath/btAlignedObjectArray.h"
43 // The C++ Standard library
44 #include <iostream>
45 
46 // Forward declarations
47 class tgGLDebugDrawer;
48 
49 
50 // @todo: Provide ability to make render rate and simulation step rate independent
51 
52 class tgSimViewGraphics : public tgSimView, public PlatformDemoApplication
53 {
54 public:
55 
67  double stepSize = 1.0/120.0,
68  double renderRate = 1.0/60.0);
69 
70  //Exit physics should have already been called
71  //exitPhysics();
72  virtual ~tgSimViewGraphics();
73 
78  void run()
79  {
80  run(10);
81  }
82 
83  void setup();
84 
85  void teardown();
86 
87  void render();
88 
93  virtual void run(int steps);
94 
95  // tgSimulation handles calling teardown and setup on this,
96  // since it knows when the new world is available
97  void reset();
98 
99  //Required by tgDemoApplication
100  void initPhysics(){
101  //Hope we've been setup by the time this is called
102  if(!isInitialzed()){
103  std::cerr << "Attempted initPhysics without setup!" << std::endl;
104  }
105  }
106 
107  //Required by tgDemoApplication
108  void exitPhysics(){
109  std::cout << "exiting physics" << std::endl;
110  teardown();
111  }
112 
113  virtual void clientMoveAndDisplay();
114 
115  virtual void displayCallback();
116  virtual void clientResetScene();
117 
118 private:
119  tgGLDebugDrawer* gDebugDrawer;
120 };
121 
122 
123 
124 #endif
bool isInitialzed() const
Definition: tgSimView.h:145
tgSimViewGraphics(tgWorld &world, double stepSize=1.0/120.0, double renderRate=1.0/60.0)
tgWorld & world()
Definition: tgSimView.h:64
Contains the definition of class tgSimView $Id$.
Contains the definition of concrete class tgBulletRenderer.