2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* Do translation/rotation actions
|
|
|
|
*
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-25 13:35:59 +00:00
|
|
|
/** \file gameengine/Ketsji/KX_ObjectActuator.cpp
|
|
|
|
* \ingroup ketsji
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "KX_ObjectActuator.h"
|
|
|
|
#include "KX_GameObject.h"
|
2009-06-08 20:08:19 +00:00
|
|
|
#include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus?
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "KX_IPhysicsController.h"
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Native functions */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
KX_ObjectActuator::
|
|
|
|
KX_ObjectActuator(
|
|
|
|
SCA_IObject* gameobj,
|
2009-06-08 20:08:19 +00:00
|
|
|
KX_GameObject* refobj,
|
2002-10-12 11:37:38 +00:00
|
|
|
const MT_Vector3& force,
|
|
|
|
const MT_Vector3& torque,
|
|
|
|
const MT_Vector3& dloc,
|
|
|
|
const MT_Vector3& drot,
|
|
|
|
const MT_Vector3& linV,
|
|
|
|
const MT_Vector3& angV,
|
2008-06-24 19:37:43 +00:00
|
|
|
const short damping,
|
2009-06-28 11:22:26 +00:00
|
|
|
const KX_LocalFlags& flag
|
2002-10-12 11:37:38 +00:00
|
|
|
) :
|
2009-09-24 21:22:24 +00:00
|
|
|
SCA_IActuator(gameobj, KX_ACT_OBJECT),
|
2002-10-12 11:37:38 +00:00
|
|
|
m_force(force),
|
|
|
|
m_torque(torque),
|
|
|
|
m_dloc(dloc),
|
|
|
|
m_drot(drot),
|
|
|
|
m_linear_velocity(linV),
|
|
|
|
m_angular_velocity(angV),
|
2008-06-24 19:37:43 +00:00
|
|
|
m_linear_length2(0.0),
|
|
|
|
m_current_linear_factor(0.0),
|
|
|
|
m_current_angular_factor(0.0),
|
|
|
|
m_damping(damping),
|
2009-02-25 03:26:02 +00:00
|
|
|
m_previous_error(0.0,0.0,0.0),
|
|
|
|
m_error_accumulator(0.0,0.0,0.0),
|
2004-03-22 22:02:18 +00:00
|
|
|
m_bitLocalFlag (flag),
|
2009-06-08 20:08:19 +00:00
|
|
|
m_reference(refobj),
|
2008-06-24 19:37:43 +00:00
|
|
|
m_active_combined_velocity (false),
|
|
|
|
m_linear_damping_active(false),
|
2009-02-25 03:26:02 +00:00
|
|
|
m_angular_damping_active(false)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (m_bitLocalFlag.ServoControl)
|
|
|
|
{
|
|
|
|
// in servo motion, the force is local if the target velocity is local
|
|
|
|
m_bitLocalFlag.Force = m_bitLocalFlag.LinearVelocity;
|
2009-06-08 20:08:19 +00:00
|
|
|
|
|
|
|
m_pid = m_torque;
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
}
|
2009-06-08 20:08:19 +00:00
|
|
|
if (m_reference)
|
|
|
|
m_reference->RegisterActuator(this);
|
2008-06-24 19:37:43 +00:00
|
|
|
UpdateFuzzyFlags();
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
KX_ObjectActuator::~KX_ObjectActuator()
|
|
|
|
{
|
|
|
|
if (m_reference)
|
|
|
|
m_reference->UnregisterActuator(this);
|
|
|
|
}
|
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
bool KX_ObjectActuator::Update()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
bool bNegativeEvent = IsNegativeEvent();
|
|
|
|
RemoveAllEvents();
|
|
|
|
|
|
|
|
KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
|
|
|
|
|
|
|
|
if (bNegativeEvent) {
|
|
|
|
// If we previously set the linear velocity we now have to inform
|
|
|
|
// the physics controller that we no longer wish to apply it and that
|
|
|
|
// it should reconcile the externally set velocity with it's
|
|
|
|
// own velocity.
|
|
|
|
if (m_active_combined_velocity) {
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (parent)
|
|
|
|
parent->ResolveCombinedVelocities(
|
|
|
|
m_linear_velocity,
|
|
|
|
m_angular_velocity,
|
|
|
|
(m_bitLocalFlag.LinearVelocity) != 0,
|
|
|
|
(m_bitLocalFlag.AngularVelocity) != 0
|
|
|
|
);
|
2004-04-08 11:34:50 +00:00
|
|
|
m_active_combined_velocity = false;
|
2004-05-16 13:05:15 +00:00
|
|
|
}
|
2008-06-24 19:37:43 +00:00
|
|
|
m_linear_damping_active = false;
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
m_angular_damping_active = false;
|
|
|
|
m_error_accumulator.setValue(0.0,0.0,0.0);
|
|
|
|
m_previous_error.setValue(0.0,0.0,0.0);
|
2004-05-16 13:05:15 +00:00
|
|
|
return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
} else if (parent)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (m_bitLocalFlag.ServoControl)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
// In this mode, we try to reach a target speed using force
|
|
|
|
// As we don't know the friction, we must implement a generic
|
|
|
|
// servo control to achieve the speed in a configurable
|
|
|
|
// v = current velocity
|
|
|
|
// V = target velocity
|
|
|
|
// e = V-v = speed error
|
|
|
|
// dt = time interval since previous update
|
|
|
|
// I = sum(e(t)*dt)
|
|
|
|
// dv = e(t) - e(t-1)
|
|
|
|
// KP, KD, KI : coefficient
|
|
|
|
// F = KP*e+KI*I+KD*dv
|
|
|
|
MT_Scalar mass = parent->GetMass();
|
|
|
|
if (mass < MT_EPSILON)
|
|
|
|
return false;
|
|
|
|
MT_Vector3 v = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
|
2009-06-08 20:08:19 +00:00
|
|
|
if (m_reference)
|
|
|
|
{
|
|
|
|
const MT_Point3& mypos = parent->NodeGetWorldPosition();
|
|
|
|
const MT_Point3& refpos = m_reference->NodeGetWorldPosition();
|
|
|
|
MT_Point3 relpos;
|
|
|
|
relpos = (mypos-refpos);
|
|
|
|
MT_Vector3 vel= m_reference->GetVelocity(relpos);
|
|
|
|
if (m_bitLocalFlag.LinearVelocity)
|
|
|
|
// must convert in local space
|
|
|
|
vel = parent->NodeGetWorldOrientation().transposed()*vel;
|
|
|
|
v -= vel;
|
|
|
|
}
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
MT_Vector3 e = m_linear_velocity - v;
|
|
|
|
MT_Vector3 dv = e - m_previous_error;
|
|
|
|
MT_Vector3 I = m_error_accumulator + e;
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
m_force = m_pid.x()*e+m_pid.y()*I+m_pid.z()*dv;
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
// to automatically adapt the PID coefficient to mass;
|
|
|
|
m_force *= mass;
|
|
|
|
if (m_bitLocalFlag.Torque)
|
2008-06-24 19:37:43 +00:00
|
|
|
{
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (m_force[0] > m_dloc[0])
|
|
|
|
{
|
|
|
|
m_force[0] = m_dloc[0];
|
|
|
|
I[0] = m_error_accumulator[0];
|
|
|
|
} else if (m_force[0] < m_drot[0])
|
|
|
|
{
|
|
|
|
m_force[0] = m_drot[0];
|
|
|
|
I[0] = m_error_accumulator[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_bitLocalFlag.DLoc)
|
2008-06-24 19:37:43 +00:00
|
|
|
{
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (m_force[1] > m_dloc[1])
|
|
|
|
{
|
|
|
|
m_force[1] = m_dloc[1];
|
|
|
|
I[1] = m_error_accumulator[1];
|
|
|
|
} else if (m_force[1] < m_drot[1])
|
|
|
|
{
|
|
|
|
m_force[1] = m_drot[1];
|
|
|
|
I[1] = m_error_accumulator[1];
|
|
|
|
}
|
2008-06-24 19:37:43 +00:00
|
|
|
}
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (m_bitLocalFlag.DRot)
|
|
|
|
{
|
|
|
|
if (m_force[2] > m_dloc[2])
|
|
|
|
{
|
|
|
|
m_force[2] = m_dloc[2];
|
|
|
|
I[2] = m_error_accumulator[2];
|
|
|
|
} else if (m_force[2] < m_drot[2])
|
|
|
|
{
|
|
|
|
m_force[2] = m_drot[2];
|
|
|
|
I[2] = m_error_accumulator[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_previous_error = e;
|
|
|
|
m_error_accumulator = I;
|
|
|
|
parent->ApplyForce(m_force,(m_bitLocalFlag.LinearVelocity) != 0);
|
|
|
|
} else
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (!m_bitLocalFlag.ZeroForce)
|
2008-06-24 19:37:43 +00:00
|
|
|
{
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0);
|
|
|
|
}
|
|
|
|
if (!m_bitLocalFlag.ZeroTorque)
|
2008-06-24 19:37:43 +00:00
|
|
|
{
|
|
|
|
parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0);
|
|
|
|
}
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (!m_bitLocalFlag.ZeroDLoc)
|
|
|
|
{
|
|
|
|
parent->ApplyMovement(m_dloc,(m_bitLocalFlag.DLoc) != 0);
|
|
|
|
}
|
|
|
|
if (!m_bitLocalFlag.ZeroDRot)
|
|
|
|
{
|
|
|
|
parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0);
|
|
|
|
}
|
|
|
|
if (!m_bitLocalFlag.ZeroLinearVelocity)
|
|
|
|
{
|
|
|
|
if (m_bitLocalFlag.AddOrSetLinV) {
|
|
|
|
parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
|
|
|
|
} else {
|
|
|
|
m_active_combined_velocity = true;
|
|
|
|
if (m_damping > 0) {
|
|
|
|
MT_Vector3 linV;
|
|
|
|
if (!m_linear_damping_active) {
|
|
|
|
// delta and the start speed (depends on the existing speed in that direction)
|
|
|
|
linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
|
|
|
|
// keep only the projection along the desired direction
|
|
|
|
m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2;
|
|
|
|
m_linear_damping_active = true;
|
|
|
|
}
|
|
|
|
if (m_current_linear_factor < 1.0)
|
|
|
|
m_current_linear_factor += 1.0/m_damping;
|
|
|
|
if (m_current_linear_factor > 1.0)
|
|
|
|
m_current_linear_factor = 1.0;
|
|
|
|
linV = m_current_linear_factor * m_linear_velocity;
|
2011-09-03 02:15:49 +00:00
|
|
|
parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0);
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
} else {
|
2011-09-03 02:15:49 +00:00
|
|
|
parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!m_bitLocalFlag.ZeroAngularVelocity)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
m_active_combined_velocity = true;
|
2008-06-24 19:37:43 +00:00
|
|
|
if (m_damping > 0) {
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
MT_Vector3 angV;
|
|
|
|
if (!m_angular_damping_active) {
|
2008-06-24 19:37:43 +00:00
|
|
|
// delta and the start speed (depends on the existing speed in that direction)
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity);
|
2008-06-24 19:37:43 +00:00
|
|
|
// keep only the projection along the desired direction
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2;
|
|
|
|
m_angular_damping_active = true;
|
2008-06-24 19:37:43 +00:00
|
|
|
}
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
if (m_current_angular_factor < 1.0)
|
|
|
|
m_current_angular_factor += 1.0/m_damping;
|
|
|
|
if (m_current_angular_factor > 1.0)
|
|
|
|
m_current_angular_factor = 1.0;
|
|
|
|
angV = m_current_angular_factor * m_angular_velocity;
|
2011-09-03 02:15:49 +00:00
|
|
|
parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0);
|
2008-06-24 19:37:43 +00:00
|
|
|
} else {
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0);
|
2008-06-24 19:37:43 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CValue* KX_ObjectActuator::GetReplica()
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* replica = new KX_ObjectActuator(*this);//m_float,GetName());
|
|
|
|
replica->ProcessReplica();
|
|
|
|
|
|
|
|
return replica;
|
|
|
|
}
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
void KX_ObjectActuator::ProcessReplica()
|
|
|
|
{
|
|
|
|
SCA_IActuator::ProcessReplica();
|
|
|
|
if (m_reference)
|
|
|
|
m_reference->RegisterActuator(this);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
bool KX_ObjectActuator::UnlinkObject(SCA_IObject* clientobj)
|
|
|
|
{
|
|
|
|
if (clientobj == (SCA_IObject*)m_reference)
|
|
|
|
{
|
|
|
|
// this object is being deleted, we cannot continue to use it as reference.
|
|
|
|
m_reference = NULL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-06 20:18:42 +00:00
|
|
|
void KX_ObjectActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
|
2009-06-08 20:08:19 +00:00
|
|
|
{
|
|
|
|
void **h_obj = (*obj_map)[m_reference];
|
|
|
|
if (h_obj) {
|
|
|
|
if (m_reference)
|
|
|
|
m_reference->UnregisterActuator(this);
|
|
|
|
m_reference = (KX_GameObject*)(*h_obj);
|
|
|
|
m_reference->RegisterActuator(this);
|
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* some 'standard' utilities... */
|
|
|
|
bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type)
|
|
|
|
{
|
|
|
|
bool res = false;
|
|
|
|
res = (type > KX_OBJECT_ACT_NODEF) && (type < KX_OBJECT_ACT_MAX);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Python functions */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Integration hooks ------------------------------------------------------- */
|
|
|
|
PyTypeObject KX_ObjectActuator::Type = {
|
2009-06-08 20:08:19 +00:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2002-10-12 11:37:38 +00:00
|
|
|
"KX_ObjectActuator",
|
2009-04-20 15:06:46 +00:00
|
|
|
sizeof(PyObjectPlus_Proxy),
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_dealloc,
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_repr,
|
2009-06-29 12:06:46 +00:00
|
|
|
0,0,0,0,0,0,0,0,0,
|
2009-06-28 11:22:26 +00:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
|
|
0,0,0,0,0,0,0,
|
|
|
|
Methods,
|
|
|
|
0,
|
|
|
|
0,
|
2009-06-29 12:06:46 +00:00
|
|
|
&SCA_IActuator::Type,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_new
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PyMethodDef KX_ObjectActuator::Methods[] = {
|
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-02-26 09:04:06 +00:00
|
|
|
PyAttributeDef KX_ObjectActuator::Attributes[] = {
|
2009-06-08 20:08:19 +00:00
|
|
|
KX_PYATTRIBUTE_VECTOR_RW_CHECK("force", -1000, 1000, false, KX_ObjectActuator, m_force, PyUpdateFuzzyFlags),
|
|
|
|
KX_PYATTRIBUTE_BOOL_RW("useLocalForce", KX_ObjectActuator, m_bitLocalFlag.Force),
|
|
|
|
KX_PYATTRIBUTE_VECTOR_RW_CHECK("torque", -1000, 1000, false, KX_ObjectActuator, m_torque, PyUpdateFuzzyFlags),
|
|
|
|
KX_PYATTRIBUTE_BOOL_RW("useLocalTorque", KX_ObjectActuator, m_bitLocalFlag.Torque),
|
|
|
|
KX_PYATTRIBUTE_VECTOR_RW_CHECK("dLoc", -1000, 1000, false, KX_ObjectActuator, m_dloc, PyUpdateFuzzyFlags),
|
|
|
|
KX_PYATTRIBUTE_BOOL_RW("useLocalDLoc", KX_ObjectActuator, m_bitLocalFlag.DLoc),
|
|
|
|
KX_PYATTRIBUTE_VECTOR_RW_CHECK("dRot", -1000, 1000, false, KX_ObjectActuator, m_drot, PyUpdateFuzzyFlags),
|
|
|
|
KX_PYATTRIBUTE_BOOL_RW("useLocalDRot", KX_ObjectActuator, m_bitLocalFlag.DRot),
|
2009-06-25 10:11:37 +00:00
|
|
|
#ifdef USE_MATHUTILS
|
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("linV", KX_ObjectActuator, pyattr_get_linV, pyattr_set_linV),
|
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("angV", KX_ObjectActuator, pyattr_get_angV, pyattr_set_angV),
|
|
|
|
#else
|
2009-06-08 20:08:19 +00:00
|
|
|
KX_PYATTRIBUTE_VECTOR_RW_CHECK("linV", -1000, 1000, false, KX_ObjectActuator, m_linear_velocity, PyUpdateFuzzyFlags),
|
|
|
|
KX_PYATTRIBUTE_VECTOR_RW_CHECK("angV", -1000, 1000, false, KX_ObjectActuator, m_angular_velocity, PyUpdateFuzzyFlags),
|
2009-06-25 10:11:37 +00:00
|
|
|
#endif
|
|
|
|
KX_PYATTRIBUTE_BOOL_RW("useLocalLinV", KX_ObjectActuator, m_bitLocalFlag.LinearVelocity),
|
2009-06-08 20:08:19 +00:00
|
|
|
KX_PYATTRIBUTE_BOOL_RW("useLocalAngV", KX_ObjectActuator, m_bitLocalFlag.AngularVelocity),
|
|
|
|
KX_PYATTRIBUTE_SHORT_RW("damping", 0, 1000, false, KX_ObjectActuator, m_damping),
|
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("forceLimitX", KX_ObjectActuator, pyattr_get_forceLimitX, pyattr_set_forceLimitX),
|
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("forceLimitY", KX_ObjectActuator, pyattr_get_forceLimitY, pyattr_set_forceLimitY),
|
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("forceLimitZ", KX_ObjectActuator, pyattr_get_forceLimitZ, pyattr_set_forceLimitZ),
|
|
|
|
KX_PYATTRIBUTE_VECTOR_RW_CHECK("pid", -100, 200, true, KX_ObjectActuator, m_pid, PyCheckPid),
|
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("reference", KX_ObjectActuator,pyattr_get_reference,pyattr_set_reference),
|
2009-02-26 09:04:06 +00:00
|
|
|
{ NULL } //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
/* Attribute get/set functions */
|
|
|
|
|
2009-06-25 10:11:37 +00:00
|
|
|
#ifdef USE_MATHUTILS
|
|
|
|
|
|
|
|
/* These require an SGNode */
|
|
|
|
#define MATHUTILS_VEC_CB_LINV 1
|
|
|
|
#define MATHUTILS_VEC_CB_ANGV 2
|
|
|
|
|
|
|
|
static int mathutils_kxobactu_vector_cb_index= -1; /* index for our callbacks */
|
|
|
|
|
2010-04-26 21:04:42 +00:00
|
|
|
static int mathutils_obactu_generic_check(BaseMathObject *bmo)
|
2009-06-25 10:11:37 +00:00
|
|
|
{
|
2010-04-26 21:04:42 +00:00
|
|
|
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
|
2009-06-25 10:11:37 +00:00
|
|
|
if(self==NULL)
|
2011-02-28 18:42:41 +00:00
|
|
|
return -1;
|
2009-06-25 10:11:37 +00:00
|
|
|
|
2011-02-28 18:42:41 +00:00
|
|
|
return 0;
|
2009-06-25 10:11:37 +00:00
|
|
|
}
|
|
|
|
|
2010-04-27 19:21:36 +00:00
|
|
|
static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype)
|
2009-06-25 10:11:37 +00:00
|
|
|
{
|
2010-04-26 21:04:42 +00:00
|
|
|
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
|
2009-06-25 10:11:37 +00:00
|
|
|
if(self==NULL)
|
2011-02-28 18:42:41 +00:00
|
|
|
return -1;
|
2009-06-25 10:11:37 +00:00
|
|
|
|
|
|
|
switch(subtype) {
|
|
|
|
case MATHUTILS_VEC_CB_LINV:
|
2010-04-27 19:21:36 +00:00
|
|
|
self->m_linear_velocity.getValue(bmo->data);
|
2009-06-25 10:11:37 +00:00
|
|
|
break;
|
|
|
|
case MATHUTILS_VEC_CB_ANGV:
|
2010-04-27 19:21:36 +00:00
|
|
|
self->m_angular_velocity.getValue(bmo->data);
|
2009-06-25 10:11:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:42:41 +00:00
|
|
|
return 0;
|
2009-06-25 10:11:37 +00:00
|
|
|
}
|
|
|
|
|
2010-04-27 19:21:36 +00:00
|
|
|
static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype)
|
2009-06-25 10:11:37 +00:00
|
|
|
{
|
2010-04-26 21:04:42 +00:00
|
|
|
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
|
2009-06-25 10:11:37 +00:00
|
|
|
if(self==NULL)
|
2011-02-28 18:42:41 +00:00
|
|
|
return -1;
|
2009-06-25 10:11:37 +00:00
|
|
|
|
|
|
|
switch(subtype) {
|
|
|
|
case MATHUTILS_VEC_CB_LINV:
|
2010-04-27 19:21:36 +00:00
|
|
|
self->m_linear_velocity.setValue(bmo->data);
|
2009-06-25 10:11:37 +00:00
|
|
|
break;
|
|
|
|
case MATHUTILS_VEC_CB_ANGV:
|
2010-04-27 19:21:36 +00:00
|
|
|
self->m_angular_velocity.setValue(bmo->data);
|
2009-06-25 10:11:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:42:41 +00:00
|
|
|
return 0;
|
2009-06-25 10:11:37 +00:00
|
|
|
}
|
|
|
|
|
2010-04-27 19:21:36 +00:00
|
|
|
static int mathutils_obactu_vector_get_index(BaseMathObject *bmo, int subtype, int index)
|
2009-06-25 10:11:37 +00:00
|
|
|
{
|
|
|
|
/* lazy, avoid repeteing the case statement */
|
2011-03-03 08:01:11 +00:00
|
|
|
if(mathutils_obactu_vector_get(bmo, subtype) == -1)
|
2011-02-28 18:42:41 +00:00
|
|
|
return -1;
|
|
|
|
return 0;
|
2009-06-25 10:11:37 +00:00
|
|
|
}
|
|
|
|
|
2010-04-27 19:21:36 +00:00
|
|
|
static int mathutils_obactu_vector_set_index(BaseMathObject *bmo, int subtype, int index)
|
2009-06-25 10:11:37 +00:00
|
|
|
{
|
2010-04-27 19:21:36 +00:00
|
|
|
float f= bmo->data[index];
|
2009-06-25 10:11:37 +00:00
|
|
|
|
|
|
|
/* lazy, avoid repeteing the case statement */
|
2011-03-03 08:01:11 +00:00
|
|
|
if(mathutils_obactu_vector_get(bmo, subtype) == -1)
|
2011-02-28 18:42:41 +00:00
|
|
|
return -1;
|
2009-06-25 10:11:37 +00:00
|
|
|
|
2010-04-27 19:21:36 +00:00
|
|
|
bmo->data[index]= f;
|
2010-06-14 01:41:43 +00:00
|
|
|
return mathutils_obactu_vector_set(bmo, subtype);
|
2009-06-25 10:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Mathutils_Callback mathutils_obactu_vector_cb = {
|
|
|
|
mathutils_obactu_generic_check,
|
|
|
|
mathutils_obactu_vector_get,
|
|
|
|
mathutils_obactu_vector_set,
|
|
|
|
mathutils_obactu_vector_get_index,
|
|
|
|
mathutils_obactu_vector_set_index
|
|
|
|
};
|
|
|
|
|
|
|
|
PyObject* KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
|
|
{
|
2009-08-27 16:34:13 +00:00
|
|
|
return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV);
|
2009-06-25 10:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
if (!PyVecTo(value, self->m_linear_velocity))
|
|
|
|
return PY_SET_ATTR_FAIL;
|
|
|
|
|
2010-06-19 10:50:23 +00:00
|
|
|
self->UpdateFuzzyFlags();
|
|
|
|
|
2009-06-25 10:11:37 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject* KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
|
|
{
|
2009-08-27 16:34:13 +00:00
|
|
|
return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV);
|
2009-06-25 10:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
if (!PyVecTo(value, self->m_angular_velocity))
|
|
|
|
return PY_SET_ATTR_FAIL;
|
|
|
|
|
2010-06-19 10:50:23 +00:00
|
|
|
self->UpdateFuzzyFlags();
|
|
|
|
|
2009-06-25 10:11:37 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KX_ObjectActuator_Mathutils_Callback_Init(void)
|
|
|
|
{
|
|
|
|
// register mathutils callbacks, ok to run more then once.
|
|
|
|
mathutils_kxobactu_vector_cb_index= Mathutils_RegisterCallback(&mathutils_obactu_vector_cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // USE_MATHUTILS
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
PyObject* KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
PyObject *retVal = PyList_New(3);
|
|
|
|
|
|
|
|
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[0]));
|
|
|
|
PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[0]));
|
|
|
|
PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.Torque));
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
|
|
|
|
PyObject* seq = PySequence_Fast(value, "");
|
|
|
|
if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
|
|
|
|
{
|
|
|
|
self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
|
|
|
|
self->m_dloc[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
|
2009-06-29 02:25:54 +00:00
|
|
|
self->m_bitLocalFlag.Torque = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
|
2009-06-08 20:08:19 +00:00
|
|
|
|
|
|
|
if (!PyErr_Occurred())
|
|
|
|
{
|
|
|
|
Py_DECREF(seq);
|
|
|
|
return PY_SET_ATTR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_XDECREF(seq);
|
|
|
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
|
|
|
|
return PY_SET_ATTR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject* KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
PyObject *retVal = PyList_New(3);
|
|
|
|
|
|
|
|
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[1]));
|
|
|
|
PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[1]));
|
|
|
|
PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DLoc));
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
|
|
|
|
PyObject* seq = PySequence_Fast(value, "");
|
|
|
|
if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
|
|
|
|
{
|
|
|
|
self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
|
|
|
|
self->m_dloc[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
|
2009-06-29 02:25:54 +00:00
|
|
|
self->m_bitLocalFlag.DLoc = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
|
2009-06-08 20:08:19 +00:00
|
|
|
|
|
|
|
if (!PyErr_Occurred())
|
|
|
|
{
|
|
|
|
Py_DECREF(seq);
|
|
|
|
return PY_SET_ATTR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_XDECREF(seq);
|
|
|
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
|
|
|
|
return PY_SET_ATTR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject* KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
PyObject *retVal = PyList_New(3);
|
|
|
|
|
|
|
|
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[2]));
|
|
|
|
PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[2]));
|
|
|
|
PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DRot));
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
|
|
|
|
|
|
|
|
PyObject* seq = PySequence_Fast(value, "");
|
|
|
|
if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
|
|
|
|
{
|
|
|
|
self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
|
|
|
|
self->m_dloc[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
|
2009-06-29 02:25:54 +00:00
|
|
|
self->m_bitLocalFlag.DRot = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
|
2009-06-08 20:08:19 +00:00
|
|
|
|
|
|
|
if (!PyErr_Occurred())
|
|
|
|
{
|
|
|
|
Py_DECREF(seq);
|
|
|
|
return PY_SET_ATTR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_XDECREF(seq);
|
|
|
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
|
|
|
|
return PY_SET_ATTR_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject* KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self);
|
|
|
|
if (!actuator->m_reference)
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
|
|
return actuator->m_reference->GetProxy();
|
|
|
|
}
|
|
|
|
|
|
|
|
int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
|
|
|
KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self);
|
|
|
|
KX_GameObject *refOb;
|
|
|
|
|
|
|
|
if (!ConvertPythonToGameObject(value, &refOb, true, "actu.reference = value: KX_ObjectActuator"))
|
|
|
|
return PY_SET_ATTR_FAIL;
|
|
|
|
|
|
|
|
if (actuator->m_reference)
|
|
|
|
actuator->m_reference->UnregisterActuator(actuator);
|
|
|
|
|
|
|
|
if(refOb==NULL) {
|
|
|
|
actuator->m_reference= NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
actuator->m_reference = refOb;
|
|
|
|
actuator->m_reference->RegisterActuator(actuator);
|
|
|
|
}
|
|
|
|
|
|
|
|
return PY_SET_ATTR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#endif // WITH_PYTHON
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* eof */
|