This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SofaScene.h
120 lines (94 loc) · 2.88 KB
/
SofaScene.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef SOFA_NEWGUI_SofaScene_H
#define SOFA_NEWGUI_SofaScene_H
#include <SofaSimpleGUI/config.h>
#include <vector>
#include <string>
#include <sofa/simulation/Node.h>
namespace sofa {
namespace simulation {
class Simulation;
}
namespace simplegui {
class Interactor;
/** @brief A sofa scene graph with simulation functions.
*
* There are methods to initialize and update the visual models, but rendering must be performed externally, see e.g. class SofaGL.
*
* The typical life cycle is:
*
loadPlugins( list of plugin names );
setScene( scenegraph ); or open(filename)
initVisual()
[ your main loop: ]
step(dt);
updateVisual();
[ use a SofaGL object to display the simulated objects ]
* @author Francois Faure, 2014
*/
class SOFA_SOFASIMPLEGUI_API SofaScene
{
public:
/**
* @brief Initialize Sofa
*/
SofaScene();
virtual ~SofaScene(){}
/**
* @brief load the given plugin
* @param plugins names of the plugins
*/
void loadPlugins( const std::vector<std::string>& plugins );
/**
* @brief Load a scene file. The previous scene graph, if any, is deleted.
* @param fileName Scene file to load
*/
void open( const std::string& fileName );
/**
* @brief Set the scene graph. The previous scene graph, if any, is deleted.
* @param graph the scene to simulate
*/
void setScene( simulation::Node* graph );
/**
* @brief Print the scene graph on the standard output, for debugging.
*/
void printGraph();
/**
* @brief Integrate time by one step and update the Sofa scene.
*/
void step( SReal dt );
/**
* @brief restart from the beginning
*/
void reset();
/**
* @brief Compute the bounding box of the simulated objects
* @param xmin min coordinate in the X direction
* @param xmax max coordinate in the X direction
* @param ymin etc.
* @param ymax
* @param zmin
* @param zmax
*/
void getBoundingBox( SReal* xmin, SReal* xmax, SReal* ymin, SReal* ymax, SReal* zmin, SReal* zmax );
/// To do once before rendering a scene, typically at initialization time
void initVisual();
/// Update the visual models. To do after animating and before rendering.
void updateVisual();
/** @name Developer API
* To be used to create new functionalities.
*/
///@{
/// Root of the simulated scene.
simulation::Node* groot();
/// Root of the interactors, set as child of groot
simulation::Node* iroot(){ return _iroot; }
/// Do not use this directly. Use Interactor::attach, which calls this.
void insertInteractor( Interactor* );
///@}
protected:
simulation::Node::SPtr _groot; ///< root of the scene
simulation::Node* _iroot; ///< root of the interactors, child of _groot
};
}
}
#endif // SOFA_NEWGUI_SofaScene_H