NTRT Simulator  Version: Master
 All Classes Namespaces 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 
29 // This application
30 #include "tgSimView.h"
31 #include "tgBulletRenderer.h"
32 // Bullet OpenGL_FreeGlut (patched files)
33 #include "tgGlutStuff.h"
34 // The Bullet Physics library
35 #ifdef _WINDOWS
36 #include "Win32DemoApplication.h"
37 #define PlatformDemoApplication Win32DemoApplication
38 #else
39 #include "tgGlutDemoApplication.h"
40 #define PlatformDemoApplication tgGlutDemoApplication
41 #endif
42 
43 #include "LinearMath/btAlignedObjectArray.h"
44 // The C++ Standard library
45 #include <iostream>
46 
47 // Forward declarations
48 class tgGLDebugDrawer;
49 
50 
51 // @todo: Provide ability to make render rate and simulation step rate independent
52 
53 class tgSimViewGraphics : public tgSimView, public PlatformDemoApplication
54 {
55 public:
56 
68  double stepSize = 1.0/120.0,
69  double renderRate = 1.0/60.0);
70 
71  //Exit physics should have already been called
72  //exitPhysics();
73  virtual ~tgSimViewGraphics();
74 
79  void run()
80  {
81  run(10);
82  }
83 
88  void setup();
89 
93  void teardown();
94 
98  void render();
99 
106  virtual void run(int steps);
107 
112  void reset();
113 
114  //Required by tgDemoApplication
115  void initPhysics(){
116  //Hope we've been setup by the time this is called
117  if(!isInitialzed()){
118  std::cerr << "Attempted initPhysics without setup!" << std::endl;
119  }
120  }
121 
122  //Required by tgDemoApplication
123  void exitPhysics(){
124  std::cout << "exiting physics" << std::endl;
125  teardown();
126  }
127 
131  virtual void clientMoveAndDisplay();
132 
136  virtual void displayCallback();
137 
142  virtual void clientResetScene();
143 
144 private:
145  tgGLDebugDrawer* gDebugDrawer;
146 };
147 
148 
149 
150 #endif
bool isInitialzed() const
Definition: tgSimView.h:162
virtual void clientResetScene()
tgSimViewGraphics(tgWorld &world, double stepSize=1.0/120.0, double renderRate=1.0/60.0)
virtual void clientMoveAndDisplay()
tgWorld & world()
Definition: tgSimView.h:65
Contains the definition of class tgSimView.
virtual void displayCallback()
Contains the definition of concrete class tgBulletRenderer.