My Project
Loading...
Searching...
No Matches
CODEWorld.h
Go to the documentation of this file.
1//===========================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 1.0.0
41*/
42//===========================================================================
43
44//---------------------------------------------------------------------------
45#ifndef CODEWorldH
46#define CODEWorldH
47//---------------------------------------------------------------------------
48#include "chai3d.h"
49#include "CODEGenericBody.h"
50//---------------------------------------------------------------------------
51
52//===========================================================================
59//===========================================================================
60
61
62//===========================================================================
74//===========================================================================
76{
77 //-----------------------------------------------------------------------
78 // CONSTRUCTOR & DESTRUCTOR:
79 //-----------------------------------------------------------------------
80
81public:
82
84 cODEWorld(chai3d::cWorld* a_parentWorld);
85
87 virtual ~cODEWorld();
88
89
90 //-----------------------------------------------------------------------
91 // PUBLIC MEMBERS:
92 //-----------------------------------------------------------------------
93
94public:
95
97 std::list<cODEGenericBody*> m_bodies;
98
99
100 //-----------------------------------------------------------------------
101 // PUBLIC METHODS:
102 //-----------------------------------------------------------------------
103
104public:
105
107 void setGravity(chai3d::cVector3d a_gravity);
108
111
113 void setLinearDamping(double a_value) { dWorldSetLinearDamping(m_ode_world, a_value); }
114
116 void setAngularDamping(double a_value) { dWorldSetAngularDamping(m_ode_world, a_value); }
117
119 void setMaxAngularSpeed(double a_value) { dWorldSetMaxAngularSpeed(m_ode_world, a_value); }
120
122 void updateDynamics(double a_interval);
123
125 void updateBodyPositions(void);
126
128 void updateGlobalPositions(const bool a_frameOnly);
129
131 virtual bool computeCollisionDetection(const chai3d::cVector3d& a_segmentPointA,
132 const chai3d::cVector3d& a_segmentPointB,
133 chai3d::cCollisionRecorder& a_recorder,
134 chai3d::cCollisionSettings& a_settings);
135
136
137 //-----------------------------------------------------------------------
138 // PUBLIC MEMBERS:
139 //-----------------------------------------------------------------------
140
141public:
142
144 dWorldID m_ode_world;
145
147 dSpaceID m_ode_space;
148
150 dJointGroupID m_ode_contactgroup;
151
152
153 //-----------------------------------------------------------------------
154 // PROTECTED MEMBERS:
155 //-----------------------------------------------------------------------
156
157protected:
158
161
164
165
166 //-----------------------------------------------------------------------
167 // PROTECTED METHODS:
168 //-----------------------------------------------------------------------
169
170protected:
171
173 static void nearCallback (void *data, dGeomID o1, dGeomID o2);
174
176 virtual void render(chai3d::cRenderOptions& a_options);
177};
178
179
180//---------------------------------------------------------------------------
181#endif
182//---------------------------------------------------------------------------
ODE Module ODE Generic Object.
This class implements an ODE dynamic world.
Definition CODEWorld.h:76
void setLinearDamping(double a_value)
This method sets a general linear damping term to the objects in the world.
Definition CODEWorld.h:113
virtual ~cODEWorld()
Destructor of cODEWorld.
Definition CODEWorld.cpp:97
void updateDynamics(double a_interval)
This method updates the simulation over a time interval.
Definition CODEWorld.cpp:196
std::list< cODEGenericBody * > m_bodies
List of all ODE dynamic bodies in world.
Definition CODEWorld.h:97
void updateGlobalPositions(const bool a_frameOnly)
This method updates all global position frames.
Definition CODEWorld.cpp:174
void setAngularDamping(double a_value)
This method sets a general angular damping term to the objects in the world.
Definition CODEWorld.h:116
chai3d::cVector3d getGravity()
This method returns the gravity field vector.
Definition CODEWorld.cpp:130
dJointGroupID m_ode_contactgroup
ODE contact group.
Definition CODEWorld.h:150
virtual bool computeCollisionDetection(const chai3d::cVector3d &a_segmentPointA, const chai3d::cVector3d &a_segmentPointB, chai3d::cCollisionRecorder &a_recorder, chai3d::cCollisionSettings &a_settings)
This method computes any collision between a segment and all objects in this world.
Definition CODEWorld.cpp:313
double m_simulationTime
Current time of simulation.
Definition CODEWorld.h:160
void setMaxAngularSpeed(double a_value)
This method sets a maximum angular speed for objects in the world.
Definition CODEWorld.h:119
static void nearCallback(void *data, dGeomID o1, dGeomID o2)
This method is an ODE callback that reports collisions.
Definition CODEWorld.cpp:247
chai3d::cWorld * m_parentWorld
Parent CHAI3D world.
Definition CODEWorld.h:163
dWorldID m_ode_world
ODE dynamics world.
Definition CODEWorld.h:144
dSpaceID m_ode_space
ODE collision space.
Definition CODEWorld.h:147
void setGravity(chai3d::cVector3d a_gravity)
This method sets the gravity field vector.
Definition CODEWorld.cpp:116
void updateBodyPositions(void)
This method updates the position and orientation from ODE models to CHAI3D models.
Definition CODEWorld.cpp:226
virtual void render(chai3d::cRenderOptions &a_options)
This method render graphically all objects in the world.
Definition CODEWorld.cpp:150