[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15425] trunk/blender: BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.

Benoit Bolsee benoit.bolsee at online.be
Fri Jul 4 10:16:02 CEST 2008


Revision: 15425
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15425
Author:   ben2610
Date:     2008-07-04 10:14:50 +0200 (Fri, 04 Jul 2008)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/projectfiles_vc7/blender/render/BRE_render.vcproj
    trunk/blender/projectfiles_vc7/gameengine/gamelogic/SCA_GameLogic.vcproj
    trunk/blender/source/blender/blenkernel/intern/sca.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/makesdna/DNA_actuator_types.h
    trunk/blender/source/blender/makesdna/DNA_sensor_types.h
    trunk/blender/source/blender/render/intern/source/convertblender.c
    trunk/blender/source/blender/src/buttons_logic.c
    trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp
    trunk/blender/source/gameengine/Converter/KX_ConvertSensors.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_EventManager.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_EventManager.h
    trunk/blender/source/gameengine/GameLogic/SCA_IObject.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_ISensor.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_ISensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_LogicManager.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_MouseSensor.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_PropertySensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ConstraintActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
    trunk/blender/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_NearSensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_RaySensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp
    trunk/blender/source/gameengine/Ketsji/KX_TouchSensor.cpp

Added Paths:
-----------
    trunk/blender/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
    trunk/blender/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_ActuatorSensor.h

Modified: trunk/blender/projectfiles_vc7/blender/render/BRE_render.vcproj
===================================================================
--- trunk/blender/projectfiles_vc7/blender/render/BRE_render.vcproj	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/projectfiles_vc7/blender/render/BRE_render.vcproj	2008-07-04 08:14:50 UTC (rev 15425)
@@ -74,7 +74,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="..\..\..\..\lib\windows\sdl\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\yafray;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\python;..\..\..\source\blender\blenkernel;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\blender\render\intern\include;..\..\..\source\blender\render\extern\include;..\..\..\source\kernel;..\..\..\source\kernel\gen_messaging"
-				PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_QUICKTIME;WITH_OPENEXR"
+				PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_QUICKTIME;WITH_OPENEXR;_USE_MATH_DEFINES"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="1"
 				DefaultCharIsUnsigned="TRUE"
@@ -176,6 +176,9 @@
 				RelativePath="..\..\..\source\blender\render\intern\source\strand.c">
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\render\intern\source\sunsky.c">
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\render\intern\source\texture.c">
 			</File>
 			<File
@@ -246,6 +249,9 @@
 				RelativePath="..\..\..\source\blender\render\intern\include\strand.h">
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\render\intern\include\sunsky.h">
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\render\intern\include\texture.h">
 			</File>
 			<File

Modified: trunk/blender/projectfiles_vc7/gameengine/gamelogic/SCA_GameLogic.vcproj
===================================================================
--- trunk/blender/projectfiles_vc7/gameengine/gamelogic/SCA_GameLogic.vcproj	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/projectfiles_vc7/gameengine/gamelogic/SCA_GameLogic.vcproj	2008-07-04 08:14:50 UTC (rev 15425)
@@ -333,6 +333,12 @@
 				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_2DFilterActuator.cpp">
 			</File>
 			<File
+				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorEventManager.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorSensor.cpp">
+			</File>
+			<File
 				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_AlwaysEventManager.cpp">
 			</File>
 			<File
@@ -445,6 +451,12 @@
 				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_2DFilterActuator.h">
 			</File>
 			<File
+				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorEventManager.h">
+			</File>
+			<File
+				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ActuatorSensor.h">
+			</File>
+			<File
 				RelativePath="..\..\..\source\gameengine\GameLogic\SCA_AlwaysEventManager.h">
 			</File>
 			<File

Modified: trunk/blender/source/blender/blenkernel/intern/sca.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sca.c	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/source/blender/blenkernel/intern/sca.c	2008-07-04 08:14:50 UTC (rev 15425)
@@ -150,6 +150,9 @@
 	case SENS_PROPERTY:
 		sens->data= MEM_callocN(sizeof(bPropertySensor), "propsens");
 		break;
+	case SENS_ACTUATOR:
+		sens->data= MEM_callocN(sizeof(bActuatorSensor), "actsens");
+		break;
 	case SENS_MOUSE:
 		ms=sens->data= MEM_callocN(sizeof(bMouseSensor), "mousesens");
 		ms->type= LEFTMOUSE;

Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2008-07-04 08:14:50 UTC (rev 15425)
@@ -603,6 +603,9 @@
 		case SENS_PROPERTY:
 			writestruct(wd, DATA, "bPropertySensor", 1, sens->data);
 			break;
+		case SENS_ACTUATOR:
+			writestruct(wd, DATA, "bActuatorSensor", 1, sens->data);
+			break;
 		case SENS_COLLISION:
 			writestruct(wd, DATA, "bCollisionSensor", 1, sens->data);
 			break;

Modified: trunk/blender/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_actuator_types.h	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/source/blender/makesdna/DNA_actuator_types.h	2008-07-04 08:14:50 UTC (rev 15425)
@@ -98,8 +98,8 @@
 } bPropertyActuator;
 
 typedef struct bObjectActuator {
-	short flag, type;
-	int   damping;
+	short flag, type, otype;
+	short damping;
 	float forceloc[3], forcerot[3];
 	float loc[3], rot[3];
 	float dloc[3], drot[3];
@@ -124,10 +124,13 @@
 } bCameraActuator ;
 
 typedef struct bConstraintActuator {
+	short type, mode;
 	short flag, damp;
-	float slow;
+	short time, rotdamp;
+	int pad;
 	float minloc[3], maxloc[3];
 	float minrot[3], maxrot[3];
+	char matprop[32];
 } bConstraintActuator;
 
 typedef struct bGroupActuator {
@@ -249,20 +252,19 @@
 /* objectactuator->flag */
 #define ACT_FORCE_LOCAL			1
 #define ACT_TORQUE_LOCAL		2
+#define ACT_SERVO_LIMIT_X		2
 #define ACT_DLOC_LOCAL			4
+#define ACT_SERVO_LIMIT_Y		4
 #define ACT_DROT_LOCAL			8
+#define ACT_SERVO_LIMIT_Z		8
 #define ACT_LIN_VEL_LOCAL		16
 #define ACT_ANG_VEL_LOCAL		32
 //#define ACT_ADD_LIN_VEL_LOCAL	64
 #define ACT_ADD_LIN_VEL			64
-#define ACT_CLAMP_VEL			128
 
-#define ACT_OBJECT_FORCE	0
-#define ACT_OBJECT_TORQUE	1
-#define ACT_OBJECT_DLOC		2
-#define ACT_OBJECT_DROT		3
-#define ACT_OBJECT_LINV		4
-#define ACT_OBJECT_ANGV		5
+/* objectactuator->type */
+#define ACT_OBJECT_NORMAL	0
+#define ACT_OBJECT_SERVO	1
 
 /* actuator->type */
 #define ACT_OBJECT		0
@@ -358,7 +360,23 @@
 #define ACT_CONST_ROTX		8
 #define ACT_CONST_ROTY		16
 #define ACT_CONST_ROTZ		32
+#define ACT_CONST_NORMAL	64
+#define ACT_CONST_MATERIAL	128
+#define ACT_CONST_PERMANENT 256
+#define ACT_CONST_DISTANCE	512
+/* constraint mode */
+#define ACT_CONST_DIRPX		1
+#define ACT_CONST_DIRPY		2
+#define ACT_CONST_DIRPZ		4
+#define ACT_CONST_DIRMX		8
+#define ACT_CONST_DIRMY		16
+#define ACT_CONST_DIRMZ		32
 
+/* constraint type */
+#define ACT_CONST_TYPE_LOC	0
+#define ACT_CONST_TYPE_DIST	1
+#define ACT_CONST_TYPE_ORI	2
+
 /* editObjectActuator->type */
 #define ACT_EDOB_ADD_OBJECT		0
 #define ACT_EDOB_END_OBJECT		1

Modified: trunk/blender/source/blender/makesdna/DNA_sensor_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sensor_types.h	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/source/blender/makesdna/DNA_sensor_types.h	2008-07-04 08:14:50 UTC (rev 15425)
@@ -82,6 +82,12 @@
     char maxvalue[32];
 } bPropertySensor;
 
+typedef struct bActuatorSensor {
+    int type;
+    int pad;
+	char name[32];
+} bActuatorSensor;
+
 typedef struct bCollisionSensor {
 	char name[32];          /* property name */
 	char materialName[32];  /* material      */
@@ -197,6 +203,7 @@
 #define SENS_RAY        9
 #define SENS_MESSAGE   10
 #define SENS_JOYSTICK  11
+#define SENS_ACTUATOR  12
 /* sensor->flag */
 #define SENS_SHOW		1
 #define SENS_DEL		2

Modified: trunk/blender/source/blender/render/intern/source/convertblender.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/convertblender.c	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/source/blender/render/intern/source/convertblender.c	2008-07-04 08:14:50 UTC (rev 15425)
@@ -114,6 +114,7 @@
 #include "sss.h"
 #include "strand.h"
 #include "zbuf.h"
+#include "sunsky.h"
 
 #ifndef DISABLE_YAFRAY /* disable yafray */
 

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2008-07-04 07:59:19 UTC (rev 15424)
+++ trunk/blender/source/blender/src/buttons_logic.c	2008-07-04 08:14:50 UTC (rev 15425)
@@ -681,6 +681,8 @@
 		return "Keyboard";
 	case SENS_PROPERTY:
 		return "Property";
+	case SENS_ACTUATOR:
+		return "Actuator";
 	case SENS_MOUSE:
 		return "Mouse";
 	case SENS_COLLISION:
@@ -704,7 +706,7 @@
 	/* the number needs to match defines in game.h */
 	return "Sensors %t|Always %x0|Keyboard %x3|Mouse %x5|"
 		"Touch %x1|Collision %x6|Near %x2|Radar %x7|"
-		"Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11";
+		"Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12";
 }
 
 static char *controller_name(int type)
@@ -1003,6 +1005,7 @@
 	case SENS_NEAR:			return TH_BUT_SETTING1; 
 	case SENS_KEYBOARD:		return TH_BUT_SETTING2;
 	case SENS_PROPERTY:		return TH_BUT_NUM;
+	case SENS_ACTUATOR:		return TH_BUT_NUM;
 	case SENS_MOUSE:		return TH_BUT_TEXTFIELD;
 	case SENS_RADAR:		return TH_BUT_POPUP;
 	case SENS_RANDOM:		return TH_BUT_NEUTRAL;
@@ -1067,6 +1070,7 @@
 	bRaySensor       *raySens      = NULL;
 	bMessageSensor   *mes          = NULL;
 	bJoystickSensor	 *joy		   = NULL;
+	bActuatorSensor  *as          = NULL;
 
 	short ysize;
 	char *str;
@@ -1277,6 +1281,22 @@
 			yco-= ysize;
 			break;
 		}
+	case SENS_ACTUATOR:
+		{
+			ysize= 48;
+			
+			glRects(xco, yco-ysize, xco+width, yco);
+			uiEmboss((float)xco, (float)yco-ysize,
+				(float)xco+width, (float)yco, 1);
+			
+			draw_default_sensor_header(sens, block, xco, yco, width);
+			as= sens->data;
+			
+			uiDefBut(block, TEX, 1, "Act: ",			xco+30,yco-44,width-60, 19,
+					as->name, 0, 31, 0, 0,  "Actuator name, actuator active state modifications will be detected");
+			yco-= ysize;
+			break;
+		}
 	case SENS_MOUSE:
 		{
 			ms= sens->data;
@@ -1537,6 +1557,37 @@
 	
 }
 
+static void change_object_actuator(void *act, void *arg)
+{
+	bObjectActuator *oa = act;
+	int i;
+
+	if (oa->type != oa->otype) {
+		switch (oa->type) {
+		case ACT_OBJECT_NORMAL:
+			memset(oa, 0, sizeof(bObjectActuator));
+			oa->flag = ACT_FORCE_LOCAL|ACT_TORQUE_LOCAL|ACT_DLOC_LOCAL|ACT_DROT_LOCAL;
+			oa->type = ACT_OBJECT_NORMAL;
+			break;
+
+		case ACT_OBJECT_SERVO:
+			memset(oa, 0, sizeof(bObjectActuator));

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list