2002-10-12 11:37:38 +00:00
/**
2005-09-19 13:26:17 +00:00
* $ Id $
2002-10-12 11:37:38 +00:00
*
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 ,
* Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* 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
*/
# include <stdlib.h>
# include <math.h>
2003-10-07 18:24:02 +00:00
# include <string.h>
2002-10-12 11:37:38 +00:00
# ifndef WIN32
# include <unistd.h>
# else
# include <io.h>
# endif
# include "MEM_guardedalloc.h"
# include "BLI_blenlib.h"
# include "BLI_arithb.h"
# include "DNA_action_types.h"
# include "DNA_material_types.h"
# include "DNA_sensor_types.h"
# include "DNA_actuator_types.h"
# include "DNA_controller_types.h"
# include "DNA_property_types.h"
# include "DNA_object_types.h"
2008-09-25 16:48:25 +00:00
# include "DNA_object_force.h"
2002-10-12 11:37:38 +00:00
# include "DNA_screen_types.h"
# include "DNA_space_types.h"
# include "DNA_scene_types.h"
# include "DNA_sound_types.h"
# include "DNA_text_types.h"
2004-06-02 13:17:39 +00:00
# include "DNA_userdef_types.h"
2002-10-12 11:37:38 +00:00
# include "DNA_view3d_types.h"
2004-03-22 22:02:18 +00:00
# include "DNA_mesh_types.h"
# include "DNA_world_types.h"
2002-10-12 11:37:38 +00:00
# include "BKE_library.h"
# include "BKE_global.h"
# include "BKE_main.h"
# include "BKE_sca.h"
# include "BKE_property.h"
2008-04-18 00:21:40 +00:00
# include "BKE_property.h"
# include "BKE_utildefines.h"
2002-10-12 11:37:38 +00:00
# include "BIF_gl.h"
# include "BIF_resources.h"
# include "BIF_space.h"
# include "BIF_interface.h"
2003-10-07 18:24:02 +00:00
# include "BIF_butspace.h"
2002-10-12 11:37:38 +00:00
# include "BIF_screen.h"
# include "BIF_keyval.h"
# include "BIF_editsound.h"
2005-03-09 19:45:59 +00:00
# include "BIF_editsca.h"
2002-10-12 11:37:38 +00:00
# include "BDR_editcurve.h"
2007-04-24 17:28:40 +00:00
# include "BDR_editobject.h"
2004-06-02 13:17:39 +00:00
# include "BSE_headerbuttons.h"
2004-06-02 13:34:58 +00:00
# include "BSE_filesel.h"
2002-10-12 11:37:38 +00:00
# include "blendef.h"
# include "mydevice.h"
# include "nla.h" /* For __NLA : Important, do not remove */
Another huge commit!!!
First, check on the new files, which are listed below.
The new butspace.h is a local include, only to be used for the buttons
drawn in the buttonswindow.
- editbuts, animbuts, gamebuts, displaybuts, paintbuts, work now
- i quite completely reorganized it, it's now nicely telling you what
context it is in
- sorting error in panel align fixed (tabs were flipping)
- align works correctly automatic when you click around in Blender
- editsca.c renamed to buttons_logic.h
- button names are truncated from the right for allmost all buttons
(except text buttons and number buttons)
- while dragging panels, you cannot move them outside window anymore
And of course fixed loads of little bugs I encountered while testing
it all. This is a version I really need good test & feedback for.
Next step: restoring material/lamp/texture/world
2003-10-10 17:29:01 +00:00
# include "butspace.h" // own module
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
# include "interface.h"
2002-10-12 11:37:38 +00:00
/* internals */
2005-03-09 19:45:59 +00:00
void buttons_enji ( uiBlock * , Object * ) ;
void buttons_ketsji ( uiBlock * , Object * ) ;
2007-04-09 10:52:22 +00:00
void buttons_bullet ( uiBlock * , Object * ) ;
2002-10-12 11:37:38 +00:00
/****/
static ID * * get_selected_and_linked_obs ( short * count , short scavisflag ) ;
static char * actuator_pup ( Object * owner ) ;
/****/
2003-10-07 18:24:02 +00:00
2002-10-12 11:37:38 +00:00
static void del_property ( void * selpropv , void * data2_unused )
{
bProperty * prop , * selprop = selpropv ;
Object * ob ;
int a = 0 ;
ob = OBACT ;
if ( ob = = NULL ) return ;
prop = ob - > prop . first ;
while ( prop ) {
if ( prop = = selprop ) {
if ( strcmp ( prop - > name , " Text " ) = = 0 ) {
allqueue ( REDRAWVIEW3D , 0 ) ;
}
BLI_remlink ( & ob - > prop , prop ) ;
free_property ( prop ) ;
break ;
}
a + + ;
prop = prop - > next ;
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Delete property " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
}
static int vergname ( const void * v1 , const void * v2 )
{
char * * x1 , * * x2 ;
x1 = ( char * * ) v1 ;
x2 = ( char * * ) v2 ;
return strcmp ( * x1 , * x2 ) ;
}
void make_unique_prop_names ( char * str )
{
Object * ob ;
bProperty * prop ;
bSensor * sens ;
bController * cont ;
bActuator * act ;
ID * * idar ;
short a , obcount , propcount = 0 , nr ;
char * * names ;
/* this function is called by a Button, and gives the current
* stringpointer as an argument , this is the one that can change
*/
idar = get_selected_and_linked_obs ( & obcount , BUTS_SENS_SEL | BUTS_SENS_ACT | BUTS_ACT_SEL | BUTS_ACT_ACT | BUTS_CONT_SEL | BUTS_CONT_ACT ) ;
/* for each object, make properties and sca names unique */
/* count total names */
for ( a = 0 ; a < obcount ; a + + ) {
ob = ( Object * ) idar [ a ] ;
propcount + = BLI_countlist ( & ob - > prop ) ;
propcount + = BLI_countlist ( & ob - > sensors ) ;
propcount + = BLI_countlist ( & ob - > controllers ) ;
propcount + = BLI_countlist ( & ob - > actuators ) ;
}
if ( propcount = = 0 ) {
if ( idar ) MEM_freeN ( idar ) ;
return ;
}
/* make names array for sorting */
names = MEM_callocN ( propcount * sizeof ( void * ) , " names " ) ;
/* count total names */
nr = 0 ;
for ( a = 0 ; a < obcount ; a + + ) {
ob = ( Object * ) idar [ a ] ;
prop = ob - > prop . first ;
while ( prop ) {
names [ nr + + ] = prop - > name ;
prop = prop - > next ;
}
sens = ob - > sensors . first ;
while ( sens ) {
names [ nr + + ] = sens - > name ;
sens = sens - > next ;
}
cont = ob - > controllers . first ;
while ( cont ) {
names [ nr + + ] = cont - > name ;
cont = cont - > next ;
}
act = ob - > actuators . first ;
while ( act ) {
names [ nr + + ] = act - > name ;
act = act - > next ;
}
}
qsort ( names , propcount , sizeof ( void * ) , vergname ) ;
/* now we check for double names, and change them */
for ( nr = 0 ; nr < propcount ; nr + + ) {
if ( names [ nr ] ! = str & & strcmp ( names [ nr ] , str ) = = 0 ) {
BLI_newname ( str , + 1 ) ;
}
}
MEM_freeN ( idar ) ;
MEM_freeN ( names ) ;
}
static void make_unique_prop_names_cb ( void * strv , void * redraw_view3d_flagv )
{
char * str = strv ;
2008-04-18 00:21:40 +00:00
int redraw_view3d_flag = GET_INT_FROM_POINTER ( redraw_view3d_flagv ) ;
2002-10-12 11:37:38 +00:00
make_unique_prop_names ( str ) ;
if ( redraw_view3d_flag ) allqueue ( REDRAWVIEW3D , 0 ) ;
}
static void sca_move_sensor ( void * datav , void * data2_unused )
{
bSensor * sens_to_delete = datav ;
int val ;
Base * base ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
bSensor * sens , * tmp ;
2002-10-12 11:37:38 +00:00
val = pupmenu ( " Move up%x1|Move down %x2 " ) ;
if ( val > 0 ) {
/* now find out which object has this ... */
base = FIRSTBASE ;
while ( base ) {
sens = base - > object - > sensors . first ;
while ( sens ) {
if ( sens = = sens_to_delete ) break ;
sens = sens - > next ;
}
if ( sens ) {
if ( val = = 1 & & sens - > prev ) {
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
for ( tmp = sens - > prev ; tmp ; tmp = tmp - > prev ) {
if ( tmp - > flag & SENS_VISIBLE )
break ;
}
if ( tmp ) {
BLI_remlink ( & base - > object - > sensors , sens ) ;
BLI_insertlinkbefore ( & base - > object - > sensors , tmp , sens ) ;
}
2002-10-12 11:37:38 +00:00
}
else if ( val = = 2 & & sens - > next ) {
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
for ( tmp = sens - > next ; tmp ; tmp = tmp - > next ) {
if ( tmp - > flag & SENS_VISIBLE )
break ;
}
if ( tmp ) {
BLI_remlink ( & base - > object - > sensors , sens ) ;
BLI_insertlink ( & base - > object - > sensors , tmp , sens ) ;
}
2002-10-12 11:37:38 +00:00
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Move sensor " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
}
base = base - > next ;
}
}
}
static void sca_move_controller ( void * datav , void * data2_unused )
{
bController * controller_to_del = datav ;
int val ;
Base * base ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
bController * cont , * tmp ;
2002-10-12 11:37:38 +00:00
val = pupmenu ( " Move up%x1|Move down %x2 " ) ;
if ( val > 0 ) {
/* now find out which object has this ... */
base = FIRSTBASE ;
while ( base ) {
cont = base - > object - > controllers . first ;
while ( cont ) {
if ( cont = = controller_to_del ) break ;
cont = cont - > next ;
}
if ( cont ) {
if ( val = = 1 & & cont - > prev ) {
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
/* locate the controller that has the same state mask but is earlier in the list */
tmp = cont - > prev ;
while ( tmp ) {
if ( tmp - > state_mask & cont - > state_mask )
break ;
tmp = tmp - > prev ;
}
if ( tmp ) {
BLI_remlink ( & base - > object - > controllers , cont ) ;
BLI_insertlinkbefore ( & base - > object - > controllers , tmp , cont ) ;
}
2002-10-12 11:37:38 +00:00
}
else if ( val = = 2 & & cont - > next ) {
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
tmp = cont - > next ;
while ( tmp ) {
if ( tmp - > state_mask & cont - > state_mask )
break ;
tmp = tmp - > next ;
}
2002-10-12 11:37:38 +00:00
BLI_remlink ( & base - > object - > controllers , cont ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
BLI_insertlink ( & base - > object - > controllers , tmp , cont ) ;
2002-10-12 11:37:38 +00:00
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Move controller " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
}
base = base - > next ;
}
}
}
static void sca_move_actuator ( void * datav , void * data2_unused )
{
bActuator * actuator_to_move = datav ;
int val ;
Base * base ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
bActuator * act , * tmp ;
2002-10-12 11:37:38 +00:00
val = pupmenu ( " Move up%x1|Move down %x2 " ) ;
if ( val > 0 ) {
/* now find out which object has this ... */
base = FIRSTBASE ;
while ( base ) {
act = base - > object - > actuators . first ;
while ( act ) {
if ( act = = actuator_to_move ) break ;
act = act - > next ;
}
if ( act ) {
if ( val = = 1 & & act - > prev ) {
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
/* locate the first visible actuators before this one */
for ( tmp = act - > prev ; tmp ; tmp = tmp - > prev ) {
if ( tmp - > flag & ACT_VISIBLE )
break ;
}
if ( tmp ) {
BLI_remlink ( & base - > object - > actuators , act ) ;
BLI_insertlinkbefore ( & base - > object - > actuators , tmp , act ) ;
}
2002-10-12 11:37:38 +00:00
}
else if ( val = = 2 & & act - > next ) {
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
for ( tmp = act - > next ; tmp ; tmp = tmp - > next ) {
if ( tmp - > flag & ACT_VISIBLE )
break ;
}
if ( tmp ) {
BLI_remlink ( & base - > object - > actuators , act ) ;
BLI_insertlink ( & base - > object - > actuators , tmp , act ) ;
}
2002-10-12 11:37:38 +00:00
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Move actuator " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
}
base = base - > next ;
}
}
}
Another huge commit!!!
First, check on the new files, which are listed below.
The new butspace.h is a local include, only to be used for the buttons
drawn in the buttonswindow.
- editbuts, animbuts, gamebuts, displaybuts, paintbuts, work now
- i quite completely reorganized it, it's now nicely telling you what
context it is in
- sorting error in panel align fixed (tabs were flipping)
- align works correctly automatic when you click around in Blender
- editsca.c renamed to buttons_logic.h
- button names are truncated from the right for allmost all buttons
(except text buttons and number buttons)
- while dragging panels, you cannot move them outside window anymore
And of course fixed loads of little bugs I encountered while testing
it all. This is a version I really need good test & feedback for.
Next step: restoring material/lamp/texture/world
2003-10-10 17:29:01 +00:00
void do_logic_buts ( unsigned short event )
2002-10-12 11:37:38 +00:00
{
bProperty * prop ;
bSensor * sens ;
bController * cont ;
bActuator * act ;
Object * ob ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
int didit , bit ;
2002-10-12 11:37:38 +00:00
ob = OBACT ;
if ( ob = = 0 ) return ;
switch ( event ) {
2004-03-22 22:02:18 +00:00
case B_SETSECTOR :
/* check for inconsistant types */
ob - > gameflag & = ~ ( OB_PROP | OB_MAINACTOR | OB_DYNAMIC | OB_ACTOR ) ;
ob - > dtx | = OB_BOUNDBOX ;
allqueue ( REDRAWBUTSGAME , 0 ) ;
allqueue ( REDRAWVIEW3D , 0 ) ;
break ;
2002-10-12 11:37:38 +00:00
2004-03-22 22:02:18 +00:00
case B_SETPROP :
/* check for inconsistant types */
ob - > gameflag & = ~ ( OB_SECTOR | OB_MAINACTOR | OB_DYNAMIC | OB_ACTOR ) ;
allqueue ( REDRAWBUTSGAME , 0 ) ;
allqueue ( REDRAWVIEW3D , 0 ) ;
break ;
case B_SETACTOR :
case B_SETDYNA :
case B_SETMAINACTOR :
ob - > gameflag & = ~ ( OB_SECTOR | OB_PROP ) ;
allqueue ( REDRAWBUTSGAME , 0 ) ;
allqueue ( REDRAWVIEW3D , 0 ) ;
break ;
2002-10-12 11:37:38 +00:00
case B_ADD_PROP :
prop = new_property ( PROP_FLOAT ) ;
make_unique_prop_names ( prop - > name ) ;
BLI_addtail ( & ob - > prop , prop ) ;
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Add property " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_CHANGE_PROP :
prop = ob - > prop . first ;
while ( prop ) {
if ( prop - > type ! = prop - > otype ) {
init_property ( prop ) ;
if ( strcmp ( prop - > name , " Text " ) = = 0 ) {
allqueue ( REDRAWVIEW3D , 0 ) ;
}
}
prop = prop - > next ;
}
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_ADD_SENS :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_ADDSENS ) {
ob - > scaflag & = ~ OB_ADDSENS ;
2002-10-12 11:37:38 +00:00
sens = new_sensor ( SENS_ALWAYS ) ;
2008-07-01 06:44:34 +00:00
BLI_addtail ( & ( ob - > sensors ) , sens ) ;
2002-10-12 11:37:38 +00:00
make_unique_prop_names ( sens - > name ) ;
2008-07-01 06:44:34 +00:00
ob - > scaflag | = OB_SHOWSENS ;
2002-10-12 11:37:38 +00:00
}
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Add sensor " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_CHANGE_SENS :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
sens = ob - > sensors . first ;
2002-10-12 11:37:38 +00:00
while ( sens ) {
if ( sens - > type ! = sens - > otype ) {
init_sensor ( sens ) ;
sens - > otype = sens - > type ;
break ;
}
sens = sens - > next ;
}
}
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_DEL_SENS :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
sens = ob - > sensors . first ;
2002-10-12 11:37:38 +00:00
while ( sens ) {
if ( sens - > flag & SENS_DEL ) {
2008-07-01 06:44:34 +00:00
BLI_remlink ( & ( ob - > sensors ) , sens ) ;
2002-10-12 11:37:38 +00:00
free_sensor ( sens ) ;
break ;
}
sens = sens - > next ;
}
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Delete sensor " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_ADD_CONT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_ADDCONT ) {
ob - > scaflag & = ~ OB_ADDCONT ;
2002-10-12 11:37:38 +00:00
cont = new_controller ( CONT_LOGIC_AND ) ;
make_unique_prop_names ( cont - > name ) ;
2008-07-01 06:44:34 +00:00
ob - > scaflag | = OB_SHOWCONT ;
BLI_addtail ( & ( ob - > controllers ) , cont ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
/* set the controller state mask from the current object state.
A controller is always in a single state , so select the lowest bit set
from the object state */
for ( bit = 0 ; bit < 32 ; bit + + ) {
2008-07-01 06:44:34 +00:00
if ( ob - > state & ( 1 < < bit ) )
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
break ;
}
cont - > state_mask = ( 1 < < bit ) ;
if ( cont - > state_mask = = 0 ) {
/* shouldn't happen, object state is never 0 */
cont - > state_mask = 1 ;
}
2002-10-12 11:37:38 +00:00
}
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Add controller " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
case B_SET_STATE_BIT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_SETSTBIT ) {
ob - > scaflag & = ~ OB_SETSTBIT ;
ob - > state = 0x3FFFFFFF ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
}
}
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
break ;
case B_INIT_STATE_BIT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_INITSTBIT ) {
ob - > scaflag & = ~ OB_INITSTBIT ;
ob - > state = ob - > init_state ;
if ( ! ob - > state )
ob - > state = 1 ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
}
}
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
break ;
2002-10-12 11:37:38 +00:00
case B_CHANGE_CONT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
cont = ob - > controllers . first ;
2002-10-12 11:37:38 +00:00
while ( cont ) {
if ( cont - > type ! = cont - > otype ) {
init_controller ( cont ) ;
cont - > otype = cont - > type ;
break ;
}
cont = cont - > next ;
}
}
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_DEL_CONT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
cont = ob - > controllers . first ;
2002-10-12 11:37:38 +00:00
while ( cont ) {
if ( cont - > flag & CONT_DEL ) {
2008-07-01 06:44:34 +00:00
BLI_remlink ( & ( ob - > controllers ) , cont ) ;
2002-10-12 11:37:38 +00:00
unlink_controller ( cont ) ;
free_controller ( cont ) ;
break ;
}
cont = cont - > next ;
}
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Delete controller " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
2002-10-12 11:37:38 +00:00
case B_ADD_ACT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_ADDACT ) {
ob - > scaflag & = ~ OB_ADDACT ;
2002-10-12 11:37:38 +00:00
act = new_actuator ( ACT_OBJECT ) ;
make_unique_prop_names ( act - > name ) ;
2008-07-01 06:44:34 +00:00
BLI_addtail ( & ( ob - > actuators ) , act ) ;
ob - > scaflag | = OB_SHOWACT ;
2002-10-12 11:37:38 +00:00
}
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Add actuator " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_CHANGE_ACT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
act = ob - > actuators . first ;
2002-10-12 11:37:38 +00:00
while ( act ) {
if ( act - > type ! = act - > otype ) {
init_actuator ( act ) ;
act - > otype = act - > type ;
break ;
}
act = act - > next ;
}
}
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_DEL_ACT :
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
act = ob - > actuators . first ;
2002-10-12 11:37:38 +00:00
while ( act ) {
if ( act - > flag & ACT_DEL ) {
2008-07-01 06:44:34 +00:00
BLI_remlink ( & ( ob - > actuators ) , act ) ;
2002-10-12 11:37:38 +00:00
unlink_actuator ( act ) ;
free_actuator ( act ) ;
break ;
}
act = act - > next ;
}
}
2004-11-07 16:49:46 +00:00
BIF_undo_push ( " Delete actuator " ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
break ;
case B_SOUNDACT_BROWSE :
/* since we don't know which... */
didit = 0 ;
2008-07-01 06:44:34 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
act = ob - > actuators . first ;
2002-10-12 11:37:38 +00:00
while ( act )
{
if ( act - > type = = ACT_SOUND )
{
bSoundActuator * sa = act - > data ;
if ( sa - > sndnr )
{
2004-06-02 13:34:58 +00:00
bSound * sound = G . main - > sound . first ;
int nr = 1 ;
2004-06-02 13:17:39 +00:00
if ( sa - > sndnr = = - 2 ) {
activate_databrowse ( ( ID * ) G . main - > sound . first , ID_SO , 0 , B_SOUNDACT_BROWSE ,
& sa - > sndnr , do_logic_buts ) ;
break ;
}
2002-10-12 11:37:38 +00:00
while ( sound )
{
if ( nr = = sa - > sndnr )
break ;
nr + + ;
sound = sound - > id . next ;
}
if ( sa - > sound )
sa - > sound - > id . us - - ;
sa - > sound = sound ;
if ( sound )
sound - > id . us + + ;
sa - > sndnr = 0 ;
didit = 1 ;
}
}
act = act - > next ;
}
if ( didit )
break ;
}
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
allqueue ( REDRAWSOUND , 0 ) ;
break ;
}
}
static char * sensor_name ( int type )
{
switch ( type ) {
case SENS_ALWAYS :
return " Always " ;
case SENS_TOUCH :
return " Touch " ;
case SENS_NEAR :
return " Near " ;
case SENS_KEYBOARD :
return " Keyboard " ;
case SENS_PROPERTY :
return " Property " ;
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
case SENS_ACTUATOR :
return " Actuator " ;
2008-08-16 20:45:37 +00:00
case SENS_DELAY :
return " Delay " ;
2002-10-12 11:37:38 +00:00
case SENS_MOUSE :
return " Mouse " ;
case SENS_COLLISION :
return " Collision " ;
case SENS_RADAR :
return " Radar " ;
case SENS_RANDOM :
return " Random " ;
case SENS_RAY :
return " Ray " ;
case SENS_MESSAGE :
return " Message " ;
2005-01-23 01:36:29 +00:00
case SENS_JOYSTICK :
return " Joystick " ;
2002-10-12 11:37:38 +00:00
}
return " unknown " ;
}
static char * sensor_pup ( void )
{
/* the number needs to match defines in game.h */
2008-08-16 20:45:37 +00:00
return " Sensors %t|Always %x0|Delay %x13|Keyboard %x3|Mouse %x5| "
2002-10-12 11:37:38 +00:00
" Touch %x1|Collision %x6|Near %x2|Radar %x7| "
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
" Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12 " ;
2002-10-12 11:37:38 +00:00
}
static char * controller_name ( int type )
{
switch ( type ) {
case CONT_LOGIC_AND :
return " AND " ;
case CONT_LOGIC_OR :
return " OR " ;
2008-06-23 20:41:18 +00:00
case CONT_LOGIC_NAND :
return " NAND " ;
case CONT_LOGIC_NOR :
return " NOR " ;
case CONT_LOGIC_XOR :
return " XOR " ;
case CONT_LOGIC_XNOR :
return " XNOR " ;
2002-10-12 11:37:38 +00:00
case CONT_EXPRESSION :
return " Expression " ;
case CONT_PYTHON :
return " Python " ;
}
return " unknown " ;
}
static char * controller_pup ( void )
{
2008-06-23 20:41:18 +00:00
return " Controllers %t|AND %x0|OR %x1|XOR %x6|NAND %x4|NOR %x5|XNOR %x7|Expression %x2|Python %x3 " ;
2002-10-12 11:37:38 +00:00
}
static char * actuator_name ( int type )
{
switch ( type ) {
2008-06-18 06:46:49 +00:00
case ACT_SHAPEACTION :
return " Shape Action " ;
2002-10-12 11:37:38 +00:00
case ACT_ACTION :
return " Action " ;
case ACT_OBJECT :
return " Motion " ;
case ACT_IPO :
return " Ipo " ;
case ACT_LAMP :
return " Lamp " ;
case ACT_CAMERA :
return " Camera " ;
case ACT_MATERIAL :
return " Material " ;
case ACT_SOUND :
return " Sound " ;
case ACT_CD :
return " CD " ;
case ACT_PROPERTY :
return " Property " ;
case ACT_EDIT_OBJECT :
return " Edit Object " ;
case ACT_CONSTRAINT :
return " Constraint " ;
case ACT_SCENE :
return " Scene " ;
case ACT_GROUP :
return " Group " ;
case ACT_RANDOM :
return " Random " ;
case ACT_MESSAGE :
return " Message " ;
case ACT_GAME :
return " Game " ;
case ACT_VISIBILITY :
2005-12-06 18:52:55 +00:00
return " Visibility " ;
2007-10-22 20:24:26 +00:00
case ACT_2DFILTER :
return " 2D Filter " ;
2008-04-06 18:30:52 +00:00
case ACT_PARENT :
return " Parent " ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
case ACT_STATE :
return " State " ;
2002-10-12 11:37:38 +00:00
}
return " unknown " ;
}
static char * actuator_pup ( Object * owner )
{
2002-12-06 19:48:37 +00:00
switch ( owner - > type )
2002-10-12 11:37:38 +00:00
{
2002-12-06 19:48:37 +00:00
case OB_ARMATURE :
return " Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1 "
" |Camera %x3|Sound %x5|Property %x6|Edit Object %x10 "
" |Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17 "
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
" |Visibility %x18|2D Filter %x19|Parent %x20|State %x22 " ;
2002-12-06 19:48:37 +00:00
break ;
2008-06-18 06:46:49 +00:00
case OB_MESH :
return " Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1 "
" |Camera %x3|Sound %x5|Property %x6|Edit Object %x10 "
" |Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17 "
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
" |Visibility %x18|2D Filter %x19|Parent %x20|State %x22 " ;
2008-06-18 06:46:49 +00:00
break ;
2002-12-06 19:48:37 +00:00
default :
return " Actuators %t|Motion %x0|Constraint %x9|Ipo %x1 "
" |Camera %x3|Sound %x5|Property %x6|Edit Object %x10 "
" |Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17 "
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
" |Visibility %x18|2D Filter %x19|Parent %x20|State %x22 " ;
2002-10-12 11:37:38 +00:00
}
}
static void set_sca_ob ( Object * ob )
{
bController * cont ;
bActuator * act ;
cont = ob - > controllers . first ;
while ( cont ) {
cont - > mynew = ( bController * ) ob ;
cont = cont - > next ;
}
act = ob - > actuators . first ;
while ( act ) {
act - > mynew = ( bActuator * ) ob ;
act = act - > next ;
}
}
static ID * * get_selected_and_linked_obs ( short * count , short scavisflag )
{
Base * base ;
Object * ob , * obt ;
ID * * idar ;
bSensor * sens ;
bController * cont ;
unsigned int lay ;
int a , nr , doit ;
/* we need a sorted object list */
/* set scavisflags flags in Objects to indicate these should be evaluated */
/* also hide ob pointers in ->new entries of controllerss/actuators */
* count = 0 ;
if ( G . scene = = NULL ) return NULL ;
ob = G . main - > object . first ;
while ( ob ) {
ob - > scavisflag = 0 ;
set_sca_ob ( ob ) ;
ob = ob - > id . next ;
}
if ( G . vd ) lay = G . vd - > lay ;
else lay = G . scene - > lay ;
base = FIRSTBASE ;
while ( base ) {
if ( base - > lay & lay ) {
if ( base - > flag & SELECT ) {
if ( scavisflag & BUTS_SENS_SEL ) base - > object - > scavisflag | = OB_VIS_SENS ;
if ( scavisflag & BUTS_CONT_SEL ) base - > object - > scavisflag | = OB_VIS_CONT ;
if ( scavisflag & BUTS_ACT_SEL ) base - > object - > scavisflag | = OB_VIS_ACT ;
}
}
base = base - > next ;
}
if ( OBACT ) {
if ( scavisflag & BUTS_SENS_ACT ) OBACT - > scavisflag | = OB_VIS_SENS ;
if ( scavisflag & BUTS_CONT_ACT ) OBACT - > scavisflag | = OB_VIS_CONT ;
if ( scavisflag & BUTS_ACT_ACT ) OBACT - > scavisflag | = OB_VIS_ACT ;
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
/* BUTS_XXX_STATE are similar to BUTS_XXX_LINK for selecting the object */
if ( scavisflag & ( BUTS_SENS_LINK | BUTS_CONT_LINK | BUTS_ACT_LINK | BUTS_SENS_STATE | BUTS_ACT_STATE ) ) {
2002-10-12 11:37:38 +00:00
doit = 1 ;
while ( doit ) {
doit = 0 ;
ob = G . main - > object . first ;
while ( ob ) {
/* 1st case: select sensor when controller selected */
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ( scavisflag & ( BUTS_SENS_LINK | BUTS_SENS_STATE ) ) & & ( ob - > scavisflag & OB_VIS_SENS ) = = 0 ) {
2002-10-12 11:37:38 +00:00
sens = ob - > sensors . first ;
while ( sens ) {
for ( a = 0 ; a < sens - > totlinks ; a + + ) {
if ( sens - > links [ a ] ) {
obt = ( Object * ) sens - > links [ a ] - > mynew ;
if ( obt & & ( obt - > scavisflag & OB_VIS_CONT ) ) {
doit = 1 ;
ob - > scavisflag | = OB_VIS_SENS ;
break ;
}
}
}
if ( doit ) break ;
sens = sens - > next ;
}
}
/* 2nd case: select cont when act selected */
if ( ( scavisflag & BUTS_CONT_LINK ) & & ( ob - > scavisflag & OB_VIS_CONT ) = = 0 ) {
cont = ob - > controllers . first ;
while ( cont ) {
for ( a = 0 ; a < cont - > totlinks ; a + + ) {
if ( cont - > links [ a ] ) {
obt = ( Object * ) cont - > links [ a ] - > mynew ;
if ( obt & & ( obt - > scavisflag & OB_VIS_ACT ) ) {
doit = 1 ;
ob - > scavisflag | = OB_VIS_CONT ;
break ;
}
}
}
if ( doit ) break ;
cont = cont - > next ;
}
}
/* 3rd case: select controller when sensor selected */
if ( ( scavisflag & BUTS_CONT_LINK ) & & ( ob - > scavisflag & OB_VIS_SENS ) ) {
sens = ob - > sensors . first ;
while ( sens ) {
for ( a = 0 ; a < sens - > totlinks ; a + + ) {
if ( sens - > links [ a ] ) {
obt = ( Object * ) sens - > links [ a ] - > mynew ;
if ( obt & & ( obt - > scavisflag & OB_VIS_CONT ) = = 0 ) {
doit = 1 ;
obt - > scavisflag | = OB_VIS_CONT ;
}
}
}
sens = sens - > next ;
}
}
/* 4th case: select actuator when controller selected */
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ( scavisflag & ( BUTS_ACT_LINK | BUTS_ACT_STATE ) ) & & ( ob - > scavisflag & OB_VIS_CONT ) ) {
2002-10-12 11:37:38 +00:00
cont = ob - > controllers . first ;
while ( cont ) {
for ( a = 0 ; a < cont - > totlinks ; a + + ) {
if ( cont - > links [ a ] ) {
obt = ( Object * ) cont - > links [ a ] - > mynew ;
if ( obt & & ( obt - > scavisflag & OB_VIS_ACT ) = = 0 ) {
doit = 1 ;
obt - > scavisflag | = OB_VIS_ACT ;
}
}
}
cont = cont - > next ;
}
}
ob = ob - > id . next ;
}
}
}
/* now we count */
ob = G . main - > object . first ;
while ( ob ) {
if ( ob - > scavisflag ) ( * count ) + + ;
ob = ob - > id . next ;
}
if ( * count = = 0 ) return NULL ;
if ( * count > 24 ) * count = 24 ; /* temporal */
idar = MEM_callocN ( ( * count ) * sizeof ( void * ) , " idar " ) ;
ob = G . main - > object . first ;
nr = 0 ;
while ( ob ) {
if ( ob - > scavisflag ) {
idar [ nr ] = ( ID * ) ob ;
nr + + ;
}
if ( nr > = 24 ) break ;
ob = ob - > id . next ;
}
/* just to be sure... these were set in set_sca_done_ob() */
clear_sca_new_poins ( ) ;
return idar ;
}
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
static int get_col_sensor ( int type )
2002-10-12 11:37:38 +00:00
{
switch ( type ) {
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
case SENS_ALWAYS : return TH_BUT_ACTION ;
2008-08-16 20:45:37 +00:00
case SENS_DELAY : return TH_BUT_ACTION ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
case SENS_TOUCH : return TH_BUT_NEUTRAL ;
case SENS_COLLISION : return TH_BUT_SETTING ;
case SENS_NEAR : return TH_BUT_SETTING1 ;
case SENS_KEYBOARD : return TH_BUT_SETTING2 ;
case SENS_PROPERTY : return TH_BUT_NUM ;
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
case SENS_ACTUATOR : return TH_BUT_NUM ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
case SENS_MOUSE : return TH_BUT_TEXTFIELD ;
case SENS_RADAR : return TH_BUT_POPUP ;
case SENS_RANDOM : return TH_BUT_NEUTRAL ;
case SENS_RAY : return TH_BUT_SETTING1 ;
case SENS_MESSAGE : return TH_BUT_SETTING2 ;
2005-01-23 01:36:29 +00:00
case SENS_JOYSTICK : return TH_BUT_NEUTRAL ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
default : return TH_BUT_NEUTRAL ;
2002-10-12 11:37:38 +00:00
}
}
static void set_col_sensor ( int type , int medium )
{
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
int col = get_col_sensor ( type ) ;
BIF_ThemeColorShade ( col , medium ? 30 : 0 ) ;
2002-10-12 11:37:38 +00:00
}
/**
2005-08-03 18:48:22 +00:00
* Draws a toggle for pulse mode , a frequency field and a toggle to invert
2002-10-12 11:37:38 +00:00
* the value of this sensor . Operates on the shared data block of sensors .
*/
static void draw_default_sensor_header ( bSensor * sens ,
uiBlock * block ,
short x ,
short y ,
short w )
{
/* Pulsing and frequency */
2005-08-08 11:03:16 +00:00
uiDefIconButBitS ( block , TOG , SENS_PULSE_REPEAT , 1 , ICON_DOTSUP ,
2008-09-22 07:17:39 +00:00
( short ) ( x + 10 + 0. * ( w - 20 ) ) , ( short ) ( y - 21 ) , ( short ) ( 0.15 * ( w - 20 ) ) , 19 ,
2002-10-12 11:37:38 +00:00
& sens - > pulse , 0.0 , 0.0 , 0 , 0 ,
2005-08-08 11:03:16 +00:00
" Activate TRUE level triggering (pulse mode) " ) ;
2005-08-03 18:48:22 +00:00
uiDefIconButBitS ( block , TOG , SENS_NEG_PULSE_MODE , 1 , ICON_DOTSDOWN ,
2008-09-22 07:17:39 +00:00
( short ) ( x + 10 + 0.15 * ( w - 20 ) ) , ( short ) ( y - 21 ) , ( short ) ( 0.15 * ( w - 20 ) ) , 19 ,
2002-10-12 11:37:38 +00:00
& sens - > pulse , 0.0 , 0.0 , 0 , 0 ,
2005-08-08 11:03:16 +00:00
" Activate FALSE level triggering (pulse mode) " ) ;
2002-10-12 11:37:38 +00:00
uiDefButS ( block , NUM , 1 , " f: " ,
2008-09-22 07:17:39 +00:00
( short ) ( x + 10 + 0.3 * ( w - 20 ) ) , ( short ) ( y - 21 ) , ( short ) ( 0.275 * ( w - 20 ) ) , 19 ,
2002-10-12 11:37:38 +00:00
& sens - > freq , 0.0 , 10000.0 , 0 , 0 ,
2005-08-08 11:03:16 +00:00
" Delay between repeated pulses (in logic tics, 0 = no delay) " ) ;
2002-10-12 11:37:38 +00:00
/* value or shift? */
uiDefButS ( block , TOG , 1 , " Inv " ,
2008-09-22 07:17:39 +00:00
( short ) ( x + 10 + 0.85 * ( w - 20 ) ) , ( short ) ( y - 21 ) , ( short ) ( 0.15 * ( w - 20 ) ) , 19 ,
2004-04-23 15:27:40 +00:00
& sens - > invert , 0.0 , 0.0 , 0 , 0 ,
2005-08-08 11:03:16 +00:00
" Invert the level (output) of this sensor " ) ;
2008-09-15 09:08:36 +00:00
uiDefButS ( block , TOG , 1 , " Level " ,
2008-09-22 07:17:39 +00:00
( short ) ( x + 10 + 0.65 * ( w - 20 ) ) , ( short ) ( y - 21 ) , ( short ) ( 0.20 * ( w - 20 ) ) , 19 ,
2008-06-23 20:41:18 +00:00
& sens - > level , 0.0 , 0.0 , 0 , 0 ,
2008-09-15 09:08:36 +00:00
" Level detector, trigger controllers of new states (only applicable upon logic state transition) " ) ;
2002-10-12 11:37:38 +00:00
}
static short draw_sensorbuttons ( bSensor * sens , uiBlock * block , short xco , short yco , short width , char * objectname )
{
bNearSensor * ns = NULL ;
bTouchSensor * ts = NULL ;
bKeyboardSensor * ks = NULL ;
bPropertySensor * ps = NULL ;
bMouseSensor * ms = NULL ;
bCollisionSensor * cs = NULL ;
bRadarSensor * rs = NULL ;
bRandomSensor * randomSensor = NULL ;
bRaySensor * raySens = NULL ;
bMessageSensor * mes = NULL ;
2005-01-23 01:36:29 +00:00
bJoystickSensor * joy = NULL ;
2008-08-16 20:45:37 +00:00
bActuatorSensor * as = NULL ;
bDelaySensor * ds = NULL ;
2002-10-12 11:37:38 +00:00
short ysize ;
char * str ;
/* yco is at the top of the rect, draw downwards */
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
2002-10-12 11:37:38 +00:00
set_col_sensor ( sens - > type , 0 ) ;
switch ( sens - > type )
{
case SENS_ALWAYS :
{
ysize = 24 ;
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 ) ;
yco - = ysize ;
break ;
}
case SENS_TOUCH :
{
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 ) ;
ts = sens - > data ;
/* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, 31, 0, 0, "Only look for Objects with this property"); */
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_matpoin_but , ID_MA , 1 , " MA: " , ( short ) ( xco + 10 ) , ( short ) ( yco - 44 ) , ( short ) ( width - 20 ) , 19 , & ts - > ma , " Only look for floors with this Material " ) ;
2002-10-12 11:37:38 +00:00
///* uiDefButF(block, NUM, 1, "Margin:", xco+width/2,yco-44,width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity");
yco - = ysize ;
break ;
}
case SENS_COLLISION :
{
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 ) ;
cs = sens - > data ;
/* The collision sensor will become a generic collision (i.e. it */
/* absorb the old touch sensor). */
2005-08-03 18:48:22 +00:00
uiDefButBitS ( block , TOG , SENS_COLLISION_MATERIAL , B_REDR , " M/P " , ( short ) ( xco + 10 ) , ( short ) ( yco - 44 ) ,
2002-10-12 11:37:38 +00:00
( short ) ( 0.20 * ( width - 20 ) ) , 19 , & cs - > mode , 0.0 , 0.0 , 0 , 0 ,
" Toggle collision on material or property. " ) ;
if ( cs - > mode & SENS_COLLISION_MATERIAL ) {
uiDefBut ( block , TEX , 1 , " Material: " , ( short ) ( xco + 10 + 0.20 * ( width - 20 ) ) ,
( short ) ( yco - 44 ) , ( short ) ( 0.8 * ( width - 20 ) ) , 19 , & cs - > materialName , 0 , 31 , 0 , 0 ,
" Only look for Objects with this material " ) ;
} else {
uiDefBut ( block , TEX , 1 , " Property: " , ( short ) ( xco + 10 + 0.20 * ( width - 20 ) ) , ( short ) ( yco - 44 ) ,
( short ) ( 0.8 * ( width - 20 ) ) , 19 , & cs - > name , 0 , 31 , 0 , 0 ,
" Only look for Objects with this property " ) ;
}
/* uiDefButS(block, NUM, 1, "Damp:", xco+10+width-90,yco-24, 70, 19, &cs->damp, 0, 250, 0, 0, "For 'damp' time don't detect another collision"); */
yco - = ysize ;
break ;
}
case SENS_NEAR :
{
ysize = 72 ;
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 ) ;
ns = sens - > data ;
uiDefBut ( block , TEX , 1 , " Property: " , ( short ) ( 10 + xco ) , ( short ) ( yco - 44 ) , ( short ) ( width - 20 ) , 19 ,
& ns - > name , 0 , 31 , 0 , 0 , " Only look for Objects with this property " ) ;
uiDefButF ( block , NUM , 1 , " Dist " , ( short ) ( 10 + xco ) , ( short ) ( yco - 68 ) , ( short ) ( ( width - 22 ) / 2 ) , 19 ,
& ns - > dist , 0.0 , 1000.0 , 1000 , 0 , " Trigger distance " ) ;
uiDefButF ( block , NUM , 1 , " Reset " , ( short ) ( 10 + xco + ( width - 22 ) / 2 ) , ( short ) ( yco - 68 ) , ( short ) ( ( width - 22 ) / 2 ) , 19 ,
& ns - > resetdist , 0.0 , 1000.0 , 1000 , 0 , " Reset distance " ) ;
yco - = ysize ;
break ;
}
case SENS_RADAR :
{
ysize = 72 ;
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 ) ;
rs = sens - > data ;
uiDefBut ( block , TEX , 1 , " Prop: " ,
( short ) ( 10 + xco ) , ( short ) ( yco - 44 ) , ( short ) ( 0.7 * ( width - 20 ) ) , 19 ,
& rs - > name , 0 , 31 , 0 , 0 ,
" Only look for Objects with this property " ) ;
2008-04-05 22:08:15 +00:00
str = " Type %t|+X axis %x0|+Y axis %x1|+Z axis %x2|-X axis %x3|-Y axis %x4|-Z axis %x5 " ;
uiDefButS ( block , MENU , B_REDR , str ,
( short ) ( 10 + xco + 0.7 * ( width - 20 ) ) , ( short ) ( yco - 44 ) , ( short ) ( 0.3 * ( width - 22 ) ) , 19 ,
& rs - > axis , 2.0 , 31 , 0 , 0 ,
" Specify along which axis the radar cone is cast. " ) ;
2002-10-12 11:37:38 +00:00
uiDefButF ( block , NUM , 1 , " Ang: " ,
( short ) ( 10 + xco ) , ( short ) ( yco - 68 ) , ( short ) ( ( width - 20 ) / 2 ) , 19 ,
& rs - > angle , 0.0 , 179.9 , 10 , 0 ,
" Opening angle of the radar cone. " ) ;
uiDefButF ( block , NUM , 1 , " Dist: " ,
( short ) ( xco + 10 + ( width - 20 ) / 2 ) , ( short ) ( yco - 68 ) , ( short ) ( ( width - 20 ) / 2 ) , 19 ,
& rs - > range , 0.01 , 10000.0 , 100 , 0 ,
" Depth of the radar cone " ) ;
yco - = ysize ;
break ;
}
case SENS_KEYBOARD :
{
/* 5 lines: 120 height */
ysize = 120 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
/* header line */
draw_default_sensor_header ( sens , block , xco , yco , width ) ;
ks = sens - > data ;
/* line 2: hotkey and allkeys toggle */
uiDefKeyevtButS ( block , B_DIFF , " " , xco + 40 , yco - 44 , ( width ) / 2 , 19 , & ks - > key , " Key code " ) ;
/* line 3: two key modifyers (qual1, qual2) */
uiDefKeyevtButS ( block , B_DIFF , " " , xco + 40 , yco - 68 , ( width - 50 ) / 2 , 19 , & ks - > qual , " Modifier key code " ) ;
uiDefKeyevtButS ( block , B_DIFF , " " , xco + 40 + ( width - 50 ) / 2 , yco - 68 , ( width - 50 ) / 2 , 19 , & ks - > qual2 , " Second Modifier key code " ) ;
/* labels for line 1 and 2 */
uiDefBut ( block , LABEL , 0 , " Key " , xco , yco - 44 , 40 , 19 , NULL , 0 , 0 , 0 , 0 , " " ) ;
uiDefBut ( block , LABEL , 0 , " Hold " , xco , yco - 68 , 40 , 19 , NULL , 0 , 0 , 0 , 0 , " " ) ;
/* part of line 1 */
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetCol ( block , TH_BUT_SETTING2 ) ;
2005-08-03 18:48:22 +00:00
uiDefButBitS ( block , TOG , 1 , 0 , " All keys " , xco + 40 + ( width / 2 ) , yco - 44 , ( width / 2 ) - 50 , 19 ,
2002-10-12 11:37:38 +00:00
& ks - > type , 0 , 0 , 0 , 0 , " " ) ;
/* line 4: toggle property for string logging mode */
uiDefBut ( block , TEX , 1 , " LogToggle: " ,
xco + 10 , yco - 92 , ( width - 20 ) , 19 ,
ks - > toggleName , 0 , 31 , 0 , 0 ,
" Property that indicates whether to log "
" keystrokes as a string. " ) ;
/* line 5: target property for string logging mode */
uiDefBut ( block , TEX , 1 , " Target: " ,
xco + 10 , yco - 116 , ( width - 20 ) , 19 ,
ks - > targetName , 0 , 31 , 0 , 0 ,
" Property that receives the keystrokes in case "
" a string is logged. " ) ;
yco - = ysize ;
break ;
}
case SENS_PROPERTY :
{
ysize = 96 ;
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 ) ;
ps = sens - > data ;
str = " Type %t|Equal %x0|Not Equal %x1|Interval %x2|Changed %x3 " ;
/* str= "Type %t|Equal %x0|Not Equal %x1"; */
uiDefButI ( block , MENU , B_REDR , str , xco + 30 , yco - 44 , width - 60 , 19 ,
& ps - > type , 0 , 31 , 0 , 0 , " Type " ) ;
if ( ps - > type ! = SENS_PROP_EXPRESSION )
{
uiDefBut ( block , TEX , 1 , " Prop: " , xco + 30 , yco - 68 , width - 60 , 19 ,
ps - > name , 0 , 31 , 0 , 0 , " Property name " ) ;
}
if ( ps - > type = = SENS_PROP_INTERVAL )
{
uiDefBut ( block , TEX , 1 , " Min: " , xco , yco - 92 , width / 2 , 19 ,
2008-09-15 09:08:36 +00:00
ps - > value , 0 , 31 , 0 , 0 , " check for min value " ) ;
2002-10-12 11:37:38 +00:00
uiDefBut ( block , TEX , 1 , " Max: " , xco + width / 2 , yco - 92 , width / 2 , 19 ,
2008-09-15 09:08:36 +00:00
ps - > maxvalue , 0 , 31 , 0 , 0 , " check for max value " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( ps - > type = = SENS_PROP_CHANGED ) ;
else
{
uiDefBut ( block , TEX , 1 , " Value: " , xco + 30 , yco - 92 , width - 60 , 19 ,
2008-09-15 09:08:36 +00:00
ps - > value , 0 , 31 , 0 , 0 , " check for value " ) ;
2002-10-12 11:37:38 +00:00
}
yco - = ysize ;
break ;
}
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
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 ;
}
2008-08-16 20:45:37 +00:00
case SENS_DELAY :
{
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 ) ;
ds = sens - > data ;
uiDefButS ( block , NUM , 0 , " Delay " , ( short ) ( 10 + xco ) , ( short ) ( yco - 44 ) , ( short ) ( ( width - 22 ) * 0.4 + 10 ) , 19 ,
& ds - > delay , 0.0 , 5000.0 , 0 , 0 , " Delay in number of frames before the positive trigger " ) ;
uiDefButS ( block , NUM , 0 , " Dur " , ( short ) ( 10 + xco + ( width - 22 ) * 0.4 + 10 ) , ( short ) ( yco - 44 ) , ( short ) ( ( width - 22 ) * 0.4 - 10 ) , 19 ,
& ds - > duration , 0.0 , 5000.0 , 0 , 0 , " If >0, delay in number of frames before the negative trigger following the positive trigger " ) ;
uiDefButBitS ( block , TOG , SENS_DELAY_REPEAT , 0 , " REP " , ( short ) ( xco + 10 + ( width - 22 ) * 0.8 ) , ( short ) ( yco - 44 ) ,
( short ) ( 0.20 * ( width - 22 ) ) , 19 , & ds - > flag , 0.0 , 0.0 , 0 , 0 ,
" Toggle repeat option. If selected, the sensor restarts after Delay+Dur frames " ) ;
yco - = ysize ;
break ;
}
2002-10-12 11:37:38 +00:00
case SENS_MOUSE :
{
ms = sens - > data ;
/* Two lines: 48 pixels high. */
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
/* line 1: header */
draw_default_sensor_header ( sens , block , xco , yco , width ) ;
/* Line 2: type selection. The number are a bit mangled to get
* proper compatibility with older . blend files . */
str = " Type %t|Left button %x1|Middle button %x2| "
2005-08-17 14:29:58 +00:00
" Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32 " ;
2002-10-12 11:37:38 +00:00
uiDefButS ( block , MENU , B_REDR , str , xco + 10 , yco - 44 , width - 20 , 19 ,
& ms - > type , 0 , 31 , 0 , 0 ,
" Specify the type of event this mouse sensor should trigger on. " ) ;
yco - = ysize ;
break ;
}
case SENS_RANDOM :
{
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 ) ;
randomSensor = sens - > data ;
/* some files were wrongly written, avoid crash now */
if ( randomSensor )
{
uiDefButI ( block , NUM , 1 , " Seed: " , xco + 10 , yco - 44 , ( width - 20 ) , 19 ,
& randomSensor - > seed , 0 , 1000 , 0 , 0 ,
" Initial seed of the generator. (Choose 0 for not random) " ) ;
}
yco - = ysize ;
break ;
}
case SENS_RAY :
{
ysize = 72 ;
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 ) ;
raySens = sens - > data ;
/* 1. property or material */
2005-08-03 18:48:22 +00:00
uiDefButBitS ( block , TOG , SENS_COLLISION_MATERIAL , B_REDR , " M/P " ,
2002-10-12 11:37:38 +00:00
xco + 10 , yco - 44 , 0.20 * ( width - 20 ) , 19 ,
& raySens - > mode , 0.0 , 0.0 , 0 , 0 ,
" Toggle collision on material or property. " ) ;
if ( raySens - > mode & SENS_COLLISION_MATERIAL )
{
uiDefBut ( block , TEX , 1 , " Material: " , xco + 10 + 0.20 * ( width - 20 ) , yco - 44 , 0.8 * ( width - 20 ) , 19 ,
& raySens - > matname , 0 , 31 , 0 , 0 ,
" Only look for Objects with this material " ) ;
}
else
{
uiDefBut ( block , TEX , 1 , " Property: " , xco + 10 + 0.20 * ( width - 20 ) , yco - 44 , 0.8 * ( width - 20 ) , 19 ,
& raySens - > propname , 0 , 31 , 0 , 0 ,
" Only look for Objects with this property " ) ;
}
2008-08-28 19:37:49 +00:00
/* X-Ray option */
uiDefButBitS ( block , TOG , SENS_RAY_XRAY , 1 , " X " ,
xco + 10 , yco - 68 , 0.10 * ( width - 20 ) , 19 ,
& raySens - > mode , 0.0 , 0.0 , 0 , 0 ,
" Toggle X-Ray option (see through objects that don't have the property) " ) ;
2002-10-12 11:37:38 +00:00
/* 2. sensing range */
2008-08-28 19:37:49 +00:00
uiDefButF ( block , NUM , 1 , " Range " , xco + 10 + 0.10 * ( width - 20 ) , yco - 68 , 0.5 * ( width - 20 ) , 19 ,
2002-10-12 11:37:38 +00:00
& raySens - > range , 0.01 , 10000.0 , 100 , 0 ,
" Sense objects no farther than this distance " ) ;
/* 3. axis choice */
str = " Type %t|+ X axis %x1|+ Y axis %x0|+ Z axis %x2|- X axis %x3|- Y axis %x4|- Z axis %x5 " ;
uiDefButI ( block , MENU , B_REDR , str , xco + 10 + 0.6 * ( width - 20 ) , yco - 68 , 0.4 * ( width - 20 ) , 19 ,
& raySens - > axisflag , 2.0 , 31 , 0 , 0 ,
" Specify along which axis the ray is cast. " ) ;
yco - = ysize ;
break ;
}
case SENS_MESSAGE :
{
mes = sens - > data ;
ysize = 2 * 24 ; /* total number of lines * 24 pixels/line */
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize ,
( float ) xco + width , ( float ) yco , 1 ) ;
/* line 1: header line */
draw_default_sensor_header ( sens , block , xco , yco , width ) ;
/* line 2: Subject filter */
uiDefBut ( block , TEX , 1 , " Subject: " ,
( xco + 10 ) , ( yco - 44 ) , ( width - 20 ) , 19 ,
mes - > subject , 0 , 31 , 0 , 0 ,
" Optional subject filter: only accept messages with this subject "
" , or empty for all " ) ;
yco - = ysize ;
break ;
}
2005-01-23 01:36:29 +00:00
case SENS_JOYSTICK :
{
ysize = 72 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
/* line 1: header */
draw_default_sensor_header ( sens , block , xco , yco , width ) ;
joy = sens - > data ;
2008-08-31 18:42:58 +00:00
uiDefButS ( block , NUM , 1 , " Index: " , xco + 10 , yco - 44 , 0.6 * ( width - 120 ) , 19 ,
& joy - > joyindex , 0 , SENS_JOY_MAXINDEX - 1 , 100 , 0 ,
2008-09-15 09:08:36 +00:00
" Specify which joystick to use " ) ;
2005-01-23 01:36:29 +00:00
str = " Type %t|Button %x0|Axis %x1|Hat%x2 " ;
2008-08-31 18:42:58 +00:00
uiDefButS ( block , MENU , B_REDR , str , xco + 87 , yco - 44 , 0.6 * ( width - 150 ) , 19 ,
2005-01-23 01:36:29 +00:00
& joy - > type , 0 , 31 , 0 , 0 ,
" The type of event this joystick sensor is triggered on. " ) ;
if ( joy - > type = = SENS_JOY_BUTTON )
{
uiDefButI ( block , NUM , 1 , " Number: " , xco + 10 , yco - 68 , 0.6 * ( width - 20 ) , 19 ,
& joy - > button , 0 , 18 , 100 , 0 ,
" Specify which button to use " ) ;
str = " Type %t|Pressed %x0|Released %x1 " ;
uiDefButI ( block , MENU , B_REDR , str , xco + 10 + 0.6 * ( width - 20 ) , yco - 68 , 0.4 * ( width - 20 ) , 19 ,
& joy - > buttonf , 2.0 , 31 , 0 , 0 ,
" Button pressed or released. " ) ;
}
else if ( joy - > type = = SENS_JOY_AXIS )
{
uiDefButI ( block , NUM , 1 , " Number: " , xco + 10 , yco - 68 , 0.6 * ( width - 20 ) , 19 ,
& joy - > axis , 1 , 2.0 , 100 , 0 ,
" Specify which axis to use " ) ;
uiDefButI ( block , NUM , 1 , " Threshold: " , xco + 10 + 0.6 * ( width - 20 ) , yco - 44 , 0.4 * ( width - 20 ) , 19 ,
& joy - > precision , 0 , 32768.0 , 100 , 0 ,
" Specify the precision of the axis " ) ;
str = " Type %t|Up Axis %x1 |Down Axis %x3|Left Axis %x2|Right Axis %x0 " ;
uiDefButI ( block , MENU , B_REDR , str , xco + 10 + 0.6 * ( width - 20 ) , yco - 68 , 0.4 * ( width - 20 ) , 19 ,
& joy - > axisf , 2.0 , 31 , 0 , 0 ,
" The direction of the axis " ) ;
}
else
{
uiDefButI ( block , NUM , 1 , " Number: " , xco + 10 , yco - 68 , 0.6 * ( width - 20 ) , 19 ,
& joy - > hat , 1 , 2.0 , 100 , 0 ,
" Specify which hat to use " ) ;
uiDefButI ( block , NUM , 1 , " Direction: " , xco + 10 + 0.6 * ( width - 20 ) , yco - 68 , 0.4 * ( width - 20 ) , 19 ,
& joy - > hatf , 0 , 12 , 100 , 0 ,
" Specify hat direction " ) ;
}
yco - = ysize ;
break ;
}
2002-10-12 11:37:38 +00:00
}
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetCol ( block , TH_AUTO ) ;
2002-10-12 11:37:38 +00:00
return yco - 4 ;
}
static short draw_controllerbuttons ( bController * cont , uiBlock * block , short xco , short yco , short width )
{
bExpressionCont * ec ;
bPythonCont * pc ;
short ysize ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
2002-10-12 11:37:38 +00:00
switch ( cont - > type ) {
case CONT_EXPRESSION :
ysize = 28 ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
BIF_ThemeColor ( TH_BUT_SETTING ) ;
2002-10-12 11:37:38 +00:00
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
/* uiDefBut(block, LABEL, 1, "Not yet...", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, ""); */
ec = cont - > data ;
/* uiDefBut(block, BUT, 1, "Variables", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */
uiDefBut ( block , TEX , 1 , " Exp: " , xco + 10 , yco - 21 , width - 20 , 19 ,
ec - > str , 0 , 127 , 0 , 0 ,
" Expression " ) ;
yco - = ysize ;
break ;
case CONT_PYTHON :
ysize = 28 ;
if ( cont - > data = = NULL ) init_controller ( cont ) ;
pc = cont - > data ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
BIF_ThemeColor ( TH_BUT_SETTING1 ) ;
2002-10-12 11:37:38 +00:00
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_scriptpoin_but , ID_SCRIPT , 1 , " Script: " , xco + 45 , yco - 24 , width - 90 , 19 , & pc - > text , " " ) ;
2002-10-12 11:37:38 +00:00
yco - = ysize ;
break ;
default :
ysize = 4 ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
BIF_ThemeColor ( TH_BUT_NEUTRAL ) ;
2002-10-12 11:37:38 +00:00
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
yco - = ysize ;
}
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetCol ( block , TH_AUTO ) ;
2002-10-12 11:37:38 +00:00
return yco ;
}
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
static int get_col_actuator ( int type )
2002-10-12 11:37:38 +00:00
{
switch ( type ) {
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
case ACT_ACTION : return TH_BUT_ACTION ;
2008-06-18 06:46:49 +00:00
case ACT_SHAPEACTION : return TH_BUT_ACTION ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
case ACT_OBJECT : return TH_BUT_NEUTRAL ;
case ACT_IPO : return TH_BUT_SETTING ;
case ACT_PROPERTY : return TH_BUT_SETTING1 ;
case ACT_SOUND : return TH_BUT_SETTING2 ;
case ACT_CD : return TH_BUT_NUM ;
case ACT_CAMERA : return TH_BUT_TEXTFIELD ;
2005-12-06 18:52:55 +00:00
case ACT_EDIT_OBJECT : return TH_BUT_POPUP ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
case ACT_GROUP : return TH_BUT_ACTION ;
case ACT_RANDOM : return TH_BUT_NEUTRAL ;
case ACT_SCENE : return TH_BUT_SETTING ;
case ACT_MESSAGE : return TH_BUT_SETTING1 ;
case ACT_GAME : return TH_BUT_SETTING2 ;
2005-12-06 18:52:55 +00:00
case ACT_VISIBILITY : return TH_BUT_NUM ;
case ACT_CONSTRAINT : return TH_BUT_ACTION ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
case ACT_STATE : return TH_BUT_SETTING2 ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
default : return TH_BUT_NEUTRAL ;
2002-10-12 11:37:38 +00:00
}
}
static void set_col_actuator ( int item , int medium )
{
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
int col = get_col_actuator ( item ) ;
BIF_ThemeColorShade ( col , medium ? 30 : 10 ) ;
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
static void change_object_actuator ( void * act , void * arg )
{
bObjectActuator * oa = act ;
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 ) ) ;
oa - > flag = ACT_LIN_VEL_LOCAL ;
oa - > type = ACT_OBJECT_SERVO ;
oa - > forcerot [ 0 ] = 30.0f ;
oa - > forcerot [ 1 ] = 0.5f ;
oa - > forcerot [ 2 ] = 0.0f ;
break ;
}
}
}
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
static void change_ipo_actuator ( void * arg1_but , void * arg2_ia )
{
bIpoActuator * ia = arg2_ia ;
uiBut * but = arg1_but ;
if ( but - > retval & ACT_IPOFORCE )
ia - > flag & = ~ ACT_IPOADD ;
else if ( but - > retval & ACT_IPOADD )
ia - > flag & = ~ ACT_IPOFORCE ;
but - > retval = B_REDR ;
}
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
void update_object_actuator_PID ( void * act , void * arg )
{
bObjectActuator * oa = act ;
oa - > forcerot [ 0 ] = 60.0f * oa - > forcerot [ 1 ] ;
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
char * get_state_name ( Object * ob , short bit )
{
bController * cont ;
unsigned int mask ;
mask = ( 1 < < bit ) ;
cont = ob - > controllers . first ;
while ( cont ) {
if ( cont - > state_mask & mask ) {
return cont - > name ;
}
cont = cont - > next ;
}
return ( char * ) " " ;
}
2008-09-15 21:10:51 +00:00
static void check_state_mask ( void * arg1_but , void * arg2_mask )
{
unsigned int * cont_mask = arg2_mask ;
uiBut * but = arg1_but ;
if ( * cont_mask = = 0 | | ! ( G . qual & LR_SHIFTKEY ) )
* cont_mask = ( 1 < < but - > retval ) ;
but - > retval = B_REDR ;
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
static short draw_actuatorbuttons ( Object * ob , bActuator * act , uiBlock * block , short xco , short yco , short width )
2002-10-12 11:37:38 +00:00
{
bSoundActuator * sa = NULL ;
bCDActuator * cda = NULL ;
bObjectActuator * oa = NULL ;
bIpoActuator * ia = NULL ;
bPropertyActuator * pa = NULL ;
bCameraActuator * ca = NULL ;
bEditObjectActuator * eoa = NULL ;
bConstraintActuator * coa = NULL ;
bSceneActuator * sca = NULL ;
bGroupActuator * ga = NULL ;
bRandomActuator * randAct = NULL ;
bMessageActuator * ma = NULL ;
bActionActuator * aa = NULL ;
bGameActuator * gma = NULL ;
bVisibilityActuator * visAct = NULL ;
2007-10-22 20:24:26 +00:00
bTwoDFilterActuator * tdfa = NULL ;
2008-04-06 18:30:52 +00:00
bParentActuator * parAct = NULL ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
bStateActuator * staAct = NULL ;
2002-10-12 11:37:38 +00:00
float * fp ;
short ysize = 0 , wval ;
2008-06-25 16:15:57 +00:00
char * str ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
int myline , stbit ;
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
uiBut * but ;
2002-10-12 11:37:38 +00:00
2008-09-15 21:10:51 +00:00
2002-10-12 11:37:38 +00:00
/* yco is at the top of the rect, draw downwards */
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
2002-10-12 11:37:38 +00:00
set_col_actuator ( act - > type , 0 ) ;
switch ( act - > type )
{
case ACT_OBJECT :
{
oa = act - > data ;
wval = ( width - 100 ) / 3 ;
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 ( oa - > type = = ACT_OBJECT_NORMAL )
{
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
if ( ob - > gameflag & OB_DYNAMIC )
{
ysize = 175 ;
}
else
{
ysize = 72 ;
}
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
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
uiDefBut ( block , LABEL , 0 , " Loc " , xco , yco - 45 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Sets the location " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 45 , wval , 19 , oa - > dloc , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 45 , wval , 19 , oa - > dloc + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 45 , wval , 19 , oa - > dloc + 2 , - 10000.0 , 10000.0 , 10 , 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
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
uiDefBut ( block , LABEL , 0 , " Rot " , xco , yco - 64 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Sets the rotation " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 64 , wval , 19 , oa - > drot , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 64 , wval , 19 , oa - > drot + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 64 , wval , 19 , oa - > drot + 2 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButBitS ( block , TOG , ACT_DLOC_LOCAL , 0 , " L " , xco + 45 + 3 * wval , yco - 45 , 15 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Local transformation " ) ;
uiDefButBitS ( block , TOG , ACT_DROT_LOCAL , 0 , " L " , xco + 45 + 3 * wval , yco - 64 , 15 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Local transformation " ) ;
if ( ob - > gameflag & OB_DYNAMIC )
{
uiDefBut ( block , LABEL , 0 , " Force " , xco , yco - 87 , 55 , 19 , NULL , 0 , 0 , 0 , 0 , " Sets the force " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 87 , wval , 19 , oa - > forceloc , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 87 , wval , 19 , oa - > forceloc + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 87 , wval , 19 , oa - > forceloc + 2 , - 10000.0 , 10000.0 , 10 , 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
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
uiDefBut ( block , LABEL , 0 , " Torque " , xco , yco - 106 , 55 , 19 , NULL , 0 , 0 , 0 , 0 , " Sets the torque " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 106 , wval , 19 , oa - > forcerot , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 106 , wval , 19 , oa - > forcerot + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
2008-08-14 19:16:55 +00:00
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 106 , wval , 19 , oa - > forcerot + 2 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44: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
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
if ( ob - > gameflag & OB_DYNAMIC )
{
uiDefBut ( block , LABEL , 0 , " LinV " , xco , yco - 129 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Sets the linear velocity " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 129 , wval , 19 , oa - > linearvelocity , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 129 , wval , 19 , oa - > linearvelocity + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 129 , wval , 19 , oa - > linearvelocity + 2 , - 10000.0 , 10000.0 , 10 , 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
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
uiDefBut ( block , LABEL , 0 , " AngV " , xco , yco - 148 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Sets the angular velocity " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 148 , wval , 19 , oa - > angularvelocity , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 148 , wval , 19 , oa - > angularvelocity + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 148 , wval , 19 , oa - > angularvelocity + 2 , - 10000.0 , 10000.0 , 10 , 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
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
uiDefBut ( block , LABEL , 0 , " Damp " , xco , yco - 171 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Number of frames to reach the target velocity " ) ;
uiDefButS ( block , NUM , 0 , " " , xco + 45 , yco - 171 , wval , 19 , & oa - > damping , 0.0 , 1000.0 , 100 , 0 , " " ) ;
uiDefButBitS ( block , TOG , ACT_FORCE_LOCAL , 0 , " L " , xco + 45 + 3 * wval , yco - 87 , 15 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Local transformation " ) ;
uiDefButBitS ( block , TOG , ACT_TORQUE_LOCAL , 0 , " L " , xco + 45 + 3 * wval , yco - 106 , 15 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Local transformation " ) ;
uiDefButBitS ( block , TOG , ACT_LIN_VEL_LOCAL , 0 , " L " , xco + 45 + 3 * wval , yco - 129 , 15 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Local transformation " ) ;
uiDefButBitS ( block , TOG , ACT_ANG_VEL_LOCAL , 0 , " L " , xco + 45 + 3 * wval , yco - 148 , 15 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Local transformation " ) ;
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
Simple changes to Motion Actuator UI.
This includes...
- Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms.
- Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together.
I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ).
These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE.
--------------------------------------
Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )...
Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo
...or...
Just show X,Y and Z labels above all of the values.
Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes.
2008-07-29 22:44:43 +00:00
uiDefButBitS ( block , TOG , ACT_ADD_LIN_VEL , 0 , " add " , xco + 45 + 3 * wval + 15 , yco - 129 , 35 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Toggles between ADD and SET linV " ) ;
}
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 ( oa - > type = = ACT_OBJECT_SERVO )
{
ysize = 172 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
uiDefBut ( block , LABEL , 0 , " linV " , xco , yco - 45 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Sets the target linear velocity, it will be achieve by automatic application of force. Null velocity is a valid target " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 45 , wval , 19 , oa - > linearvelocity , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 45 , wval , 19 , oa - > linearvelocity + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 45 , wval , 19 , oa - > linearvelocity + 2 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButBitS ( block , TOG , ACT_LIN_VEL_LOCAL , 0 , " L " , xco + 45 + 3 * wval , yco - 45 , 15 , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Velocity is defined in local coordinates " ) ;
uiDefBut ( block , LABEL , 0 , " Limit " , xco , yco - 68 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Select if the force need to be limited along certain axis (local or global depending on LinV Local flag) " ) ;
uiDefButBitS ( block , TOG , ACT_SERVO_LIMIT_X , B_REDR , " X " , xco + 45 , yco - 68 , wval , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Set limit to force along the X axis " ) ;
uiDefButBitS ( block , TOG , ACT_SERVO_LIMIT_Y , B_REDR , " Y " , xco + 45 + wval , yco - 68 , wval , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Set limit to force along the Y axis " ) ;
uiDefButBitS ( block , TOG , ACT_SERVO_LIMIT_Z , B_REDR , " Z " , xco + 45 + 2 * wval , yco - 68 , wval , 19 , & oa - > flag , 0.0 , 0.0 , 0 , 0 , " Set limit to force along the Z axis " ) ;
uiDefBut ( block , LABEL , 0 , " Max " , xco , yco - 87 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Set the upper limit for force " ) ;
uiDefBut ( block , LABEL , 0 , " Min " , xco , yco - 106 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Set the lower limit for force " ) ;
if ( oa - > flag & ACT_SERVO_LIMIT_X ) {
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 87 , wval , 19 , oa - > dloc , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 106 , wval , 19 , oa - > drot , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
}
if ( oa - > flag & ACT_SERVO_LIMIT_Y ) {
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 87 , wval , 19 , oa - > dloc + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 106 , wval , 19 , oa - > drot + 1 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
}
if ( oa - > flag & ACT_SERVO_LIMIT_Z ) {
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 87 , wval , 19 , oa - > dloc + 2 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 106 , wval , 19 , oa - > drot + 2 , - 10000.0 , 10000.0 , 10 , 0 , " " ) ;
}
uiDefBut ( block , LABEL , 0 , " Servo " , xco , yco - 129 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Coefficients of the PID servo controller " ) ;
uiDefButF ( block , NUMSLI , B_REDR , " P: " , xco + 45 , yco - 129 , wval * 3 , 19 , oa - > forcerot , 0.00 , 200.0 , 100 , 0 , " Proportional coefficient, typical value is 60x Integral coefficient " ) ;
uiDefBut ( block , LABEL , 0 , " Slow " , xco , yco - 148 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " Low value of I coefficient correspond to slow response " ) ;
but = uiDefButF ( block , NUMSLI , B_REDR , " I : " , xco + 45 , yco - 148 , wval * 3 , 19 , oa - > forcerot + 1 , 0.0 , 3.0 , 1 , 0 , " Integral coefficient, low value (0.01) for slow response, high value (0.5) for fast response " ) ;
uiButSetFunc ( but , update_object_actuator_PID , oa , NULL ) ;
uiDefBut ( block , LABEL , 0 , " Fast " , xco + 45 + 3 * wval , yco - 148 , 45 , 19 , NULL , 0 , 0 , 0 , 0 , " High value of I coefficient correspond to fast response " ) ;
uiDefButF ( block , NUMSLI , B_REDR , " D: " , xco + 45 , yco - 167 , wval * 3 , 19 , oa - > forcerot + 2 , - 100.0 , 100.0 , 100 , 0 , " Derivate coefficient, not required, high values can cause instability " ) ;
}
str = " Motion Type %t|Simple motion %x0|Servo Control %x1 " ;
but = uiDefButS ( block , MENU , B_REDR , str , xco + 40 , yco - 23 , ( width - 80 ) , 19 , & oa - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
oa - > otype = oa - > type ;
uiButSetFunc ( but , change_object_actuator , oa , NULL ) ;
2002-10-12 11:37:38 +00:00
yco - = ysize ;
break ;
}
case ACT_ACTION :
2008-06-18 06:46:49 +00:00
case ACT_SHAPEACTION :
2002-10-12 11:37:38 +00:00
{
/* DrawAct */
# ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
ysize = 112 ;
# else
ysize = 92 ;
# endif
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
aa = act - > data ;
wval = ( width - 60 ) / 3 ;
// str= "Action types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
# ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
str = " Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6|Displacement %x7 " ;
# else
str = " Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6 " ;
# endif
2008-07-10 14:23:19 +00:00
uiDefButS ( block , MENU , B_REDR , str , xco + 10 , yco - 24 , width / 3 , 19 , & aa - > type , 0.0 , 0.0 , 0.0 , 0.0 , " Action playback type " ) ;
uiDefIDPoinBut ( block , test_actionpoin_but , ID_AC , 1 , " AC: " , xco + 10 + ( width / 3 ) , yco - 24 , ( ( width / 3 ) * 2 ) - ( 20 + 60 ) , 19 , & aa - > act , " Action name " ) ;
uiDefButBitS ( block , TOGN , 1 , 0 , " Continue " , xco + ( ( width / 3 ) * 2 ) + 20 , yco - 24 , 60 , 19 ,
& aa - > end_reset , 0.0 , 0.0 , 0 , 0 , " Restore last frame when switching on/off, otherwise play from the start each time " ) ;
2002-10-12 11:37:38 +00:00
if ( aa - > type = = ACT_ACTION_FROM_PROP )
{
2008-07-10 14:23:19 +00:00
uiDefBut ( block , TEX , 0 , " Prop: " , xco + 10 , yco - 44 , width - 20 , 19 , aa - > name , 0.0 , 31.0 , 0 , 0 , " Use this property to define the Action position " ) ;
2002-10-12 11:37:38 +00:00
}
else
{
2008-07-10 14:23:19 +00:00
uiDefButI ( block , NUM , 0 , " Sta: " , xco + 10 , yco - 44 , ( width - 20 ) / 2 , 19 , & aa - > sta , 0.0 , MAXFRAMEF , 0 , 0 , " Start frame " ) ;
uiDefButI ( block , NUM , 0 , " End: " , xco + 10 + ( width - 20 ) / 2 , yco - 44 , ( width - 20 ) / 2 , 19 , & aa - > end , 0.0 , MAXFRAMEF , 0 , 0 , " End frame " ) ;
2002-10-12 11:37:38 +00:00
}
2008-06-23 15:32:44 +00:00
2008-07-10 14:23:19 +00:00
uiDefButS ( block , NUM , 0 , " Blendin: " , xco + 10 , yco - 64 , ( width - 20 ) / 2 , 19 , & aa - > blendin , 0.0 , 32767 , 0.0 , 0.0 , " Number of frames of motion blending " ) ;
uiDefButS ( block , NUM , 0 , " Priority: " , xco + 10 + ( width - 20 ) / 2 , yco - 64 , ( width - 20 ) / 2 , 19 , & aa - > priority , 0.0 , 100.0 , 0.0 , 0.0 , " Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack " ) ;
2002-10-12 11:37:38 +00:00
2008-07-10 14:23:19 +00:00
uiDefBut ( block , TEX , 0 , " FrameProp: " , xco + 10 , yco - 84 , width - 20 , 19 , aa - > frameProp , 0.0 , 31.0 , 0 , 0 , " Assign this property this actions current frame number " ) ;
2008-06-23 15:32:44 +00:00
2002-10-12 11:37:38 +00:00
# ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
if ( aa - > type = = ACT_ACTION_MOTION )
{
2008-06-23 15:32:44 +00:00
uiDefButF ( block , NUM , 0 , " Cycle: " , xco + 30 , yco - 84 , ( width - 60 ) / 2 , 19 , & aa - > stridelength , 0.0 , 2500.0 , 0 , 0 , " Distance covered by a single cycle of the action " ) ;
2002-10-12 11:37:38 +00:00
}
# endif
2008-06-23 15:32:44 +00:00
2002-10-12 11:37:38 +00:00
yco - = ysize ;
break ;
}
case ACT_IPO :
{
ia = act - > data ;
2005-08-03 18:48:22 +00:00
ysize = 52 ;
2002-10-12 11:37:38 +00:00
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
str = " Ipo types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6 " ;
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
uiDefButS ( block , MENU , B_REDR , str , xco + 10 , yco - 24 , ( width - 20 ) / 2 , 19 , & ia - > type , 0 , 0 , 0 , 0 , " " ) ;
but = uiDefButBitS ( block , TOG , ACT_IPOFORCE , ACT_IPOFORCE ,
" Force " , xco + 10 + ( width - 20 ) / 2 , yco - 24 , ( width - 20 ) / 4 - 10 , 19 ,
2002-10-12 11:37:38 +00:00
& ia - > flag , 0 , 0 , 0 , 0 ,
2008-08-27 06:02:10 +00:00
" Apply Ipo as a global or local force depending on the local option (dynamic objects only) " ) ;
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
uiButSetFunc ( but , change_ipo_actuator , but , ia ) ;
but = uiDefButBitS ( block , TOG , ACT_IPOADD , ACT_IPOADD ,
" Add " , xco + 3 * ( width - 20 ) / 4 , yco - 24 , ( width - 20 ) / 4 - 10 , 19 ,
& ia - > flag , 0 , 0 , 0 , 0 ,
" Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag " ) ;
uiButSetFunc ( but , change_ipo_actuator , but , ia ) ;
/* Only show the do-force-local toggle if force is requested */
if ( ia - > flag & ( ACT_IPOFORCE | ACT_IPOADD ) ) {
uiDefButBitS ( block , TOG , ACT_IPOLOCAL , 0 ,
" L " , xco + width - 30 , yco - 24 , 20 , 19 ,
& ia - > flag , 0 , 0 , 0 , 0 ,
" Let the ipo acts in local coordinates, used in Force and Add mode. " ) ;
}
2005-08-03 18:48:22 +00:00
2002-10-12 11:37:38 +00:00
if ( ia - > type = = ACT_IPO_FROM_PROP ) {
uiDefBut ( block , TEX , 0 ,
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
" Prop: " , xco + 10 , yco - 44 , width - 80 , 19 ,
2002-10-12 11:37:38 +00:00
ia - > name , 0.0 , 31.0 , 0 , 0 ,
" Use this property to define the Ipo position " ) ;
}
else {
2006-05-06 15:26:53 +00:00
uiDefButI ( block , NUM , 0 ,
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
" Sta " , xco + 10 , yco - 44 , ( width - 80 ) / 2 , 19 ,
2008-09-15 09:08:36 +00:00
& ia - > sta , 1.0 , MAXFRAMEF , 0 , 0 ,
" Start frame " ) ;
2006-05-06 15:26:53 +00:00
uiDefButI ( block , NUM , 0 ,
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
" End " , xco + 10 + ( width - 80 ) / 2 , yco - 44 , ( width - 80 ) / 2 , 19 ,
2008-09-15 09:08:36 +00:00
& ia - > end , 1.0 , MAXFRAMEF , 0 , 0 ,
" End frame " ) ;
2002-10-12 11:37:38 +00:00
}
BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in
the object's local coordinates.
Delta Ipo curves are handled identically to normal Ipo curve and there
is no need to work with Delta Ipo curves provided that you make sure
that the Ipo curve starts from origin. Origin means location 0 for
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for
Scale Ipo curve.
The "current object situation" means the object's location, rotation
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo
curve is restarted (later or immediately in case of Loop mode), the
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
Local=false: newLoc = oLoc+iLoc
Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
Local=false: newMat = iMat*oMat
Local=true : newMat = oMat*iMat
Scale
Local=false: newScale = oScale*iScale
Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource,
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
different from one.
2008-07-08 12:18:43 +00:00
uiDefButBitS ( block , TOG , ACT_IPOCHILD , B_REDR ,
" Child " , xco + 10 + ( width - 80 ) , yco - 44 , 60 , 19 ,
& ia - > flag , 0 , 0 , 0 , 0 ,
" Update IPO on all children Objects as well " ) ;
2002-10-12 11:37:38 +00:00
yco - = ysize ;
break ;
}
case ACT_PROPERTY :
{
ysize = 68 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
pa = act - > data ;
str = " Type %t|Assign %x0|Add %x1|Copy %x2 " ;
uiDefButI ( block , MENU , B_REDR , str , xco + 30 , yco - 24 , width - 60 , 19 , & pa - > type , 0 , 31 , 0 , 0 , " Type " ) ;
uiDefBut ( block , TEX , 1 , " Prop: " , xco + 30 , yco - 44 , width - 60 , 19 , pa - > name , 0 , 31 , 0 , 0 , " Property name " ) ;
if ( pa - > type = = ACT_PROP_COPY ) {
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_obpoin_but , ID_OB , 1 , " OB: " , xco + 10 , yco - 64 , ( width - 20 ) / 2 , 19 , & ( pa - > ob ) , " Copy from this Object " ) ;
2002-10-12 11:37:38 +00:00
uiDefBut ( block , TEX , 1 , " Prop: " , xco + 10 + ( width - 20 ) / 2 , yco - 64 , ( width - 20 ) / 2 , 19 , pa - > value , 0 , 31 , 0 , 0 , " Copy this property " ) ;
}
else {
2008-09-15 09:08:36 +00:00
uiDefBut ( block , TEX , 1 , " Value: " , xco + 30 , yco - 64 , width - 60 , 19 , pa - > value , 0 , 31 , 0 , 0 , " change with this value, use \" \" around strings " ) ;
2002-10-12 11:37:38 +00:00
}
yco - = ysize ;
break ;
}
case ACT_SOUND :
{
ysize = 70 ;
sa = act - > data ;
sa - > sndnr = 0 ;
wval = ( width - 20 ) / 2 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2004-07-28 10:01:22 +00:00
if ( G . main - > sound . first ) {
2004-06-02 13:17:39 +00:00
IDnames_to_pupstring ( & str , " Sound files " , NULL , & ( G . main - > sound ) , ( ID * ) sa - > sound , & ( sa - > sndnr ) ) ;
2002-10-12 11:37:38 +00:00
/* reset this value, it is for handling the event */
sa - > sndnr = 0 ;
uiDefButS ( block , MENU , B_SOUNDACT_BROWSE , str , xco + 10 , yco - 22 , 20 , 19 , & ( sa - > sndnr ) , 0 , 0 , 0 , 0 , " " ) ;
2004-07-28 10:01:22 +00:00
if ( sa - > sound ) {
2002-10-12 11:37:38 +00:00
char dummy_str [ ] = " Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4 " ;
2007-04-11 17:10:57 +00:00
uiDefBut ( block , TEX , B_IDNAME , " SO: " , xco + 30 , yco - 22 , width - 40 , 19 , sa - > sound - > id . name + 2 , 0.0 , 21.0 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
uiDefButS ( block , MENU , 1 , dummy_str , xco + 10 , yco - 44 , width - 20 , 19 , & sa - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " Volume: " , xco + 10 , yco - 66 , wval , 19 , & sa - > sound - > volume , 0.0 , 1.0 , 0 , 0 , " Sets the volume of this sound " ) ;
uiDefButF ( block , NUM , 0 , " Pitch: " , xco + wval + 10 , yco - 66 , wval , 19 , & sa - > sound - > pitch , - 12.0 , 12.0 , 0 , 0 , " Sets the pitch of this sound " ) ;
}
2004-07-28 10:01:22 +00:00
MEM_freeN ( str ) ;
2004-06-02 13:17:39 +00:00
}
2004-07-28 10:01:22 +00:00
else {
2004-06-02 13:17:39 +00:00
uiDefBut ( block , LABEL , 0 , " Use Sound window (F10) to load samples " , xco , yco - 24 , width , 19 , NULL , 0 , 0 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
}
2004-07-28 10:01:22 +00:00
2002-10-12 11:37:38 +00:00
yco - = ysize ;
break ;
}
case ACT_CD :
{
char cd_type_str [ ] = " Sound mode %t|Play all tracks %x0|Play one track %x1| "
" Volume %x3|Stop %x4|Pause %x5|Resume %x6 " ;
cda = act - > data ;
2004-07-28 10:01:22 +00:00
if ( cda ) {
if ( cda - > track = = 0 ) {
2002-10-12 11:37:38 +00:00
cda - > track = 1 ;
cda - > volume = 1 ;
cda - > type = ACT_CD_PLAY_ALL ;
}
2004-07-28 10:01:22 +00:00
if ( cda - > type = = ACT_CD_PLAY_TRACK | | cda - > type = = ACT_CD_LOOP_TRACK ) {
2002-10-12 11:37:38 +00:00
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
uiDefButS ( block , NUM , 0 , " Track: " , xco + 10 , yco - 44 , width - 20 , 19 , & cda - > track , 1 , 99 , 0 , 0 , " Select the track to be played " ) ;
}
2004-07-28 10:01:22 +00:00
else if ( cda - > type = = ACT_CD_VOLUME ) {
2002-10-12 11:37:38 +00:00
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
uiDefButF ( block , NUM , 0 , " Volume: " , xco + 10 , yco - 44 , width - 20 , 19 , & cda - > volume , 0 , 1 , 0 , 0 , " Set the volume for CD playback " ) ;
}
2004-07-28 10:01:22 +00:00
else {
2002-10-12 11:37:38 +00:00
ysize = 28 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
}
uiDefButS ( block , MENU , B_REDR , cd_type_str , xco + 10 , yco - 22 , width - 20 , 19 , & cda - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
}
yco - = ysize ;
break ;
}
case ACT_CAMERA :
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
ca = act - > data ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_obpoin_but , ID_OB , 1 , " OB: " , xco + 10 , yco - 24 , ( width - 20 ) / 2 , 19 , & ( ca - > ob ) , " Look at this Object " ) ;
2002-10-12 11:37:38 +00:00
uiDefButF ( block , NUM , 0 , " Height: " , xco + 10 + ( width - 20 ) / 2 , yco - 24 , ( width - 20 ) / 2 , 19 , & ca - > height , 0.0 , 20.0 , 0 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " Min: " , xco + 10 , yco - 44 , ( width - 60 ) / 2 , 19 , & ca - > min , 0.0 , 20.0 , 0 , 0 , " " ) ;
if ( ca - > axis = = 0 ) ca - > axis = ' x ' ;
uiDefButS ( block , ROW , 0 , " X " , xco + 10 + ( width - 60 ) / 2 , yco - 44 , 20 , 19 , & ca - > axis , 4.0 , ( float ) ' x ' , 0 , 0 , " Camera tries to get behind the X axis " ) ;
uiDefButS ( block , ROW , 0 , " Y " , xco + 30 + ( width - 60 ) / 2 , yco - 44 , 20 , 19 , & ca - > axis , 4.0 , ( float ) ' y ' , 0 , 0 , " Camera tries to get behind the Y axis " ) ;
uiDefButF ( block , NUM , 0 , " Max: " , xco + 20 + ( width ) / 2 , yco - 44 , ( width - 60 ) / 2 , 19 , & ca - > max , 0.0 , 20.0 , 0 , 0 , " " ) ;
yco - = ysize ;
break ;
case ACT_EDIT_OBJECT :
eoa = act - > data ;
if ( eoa - > type = = ACT_EDOB_ADD_OBJECT ) {
int wval ; /* just a temp width */
2008-08-27 03:34:53 +00:00
ysize = 92 ;
2002-10-12 11:37:38 +00:00
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2008-07-07 21:04:30 +00:00
uiDefIDPoinBut ( block , test_obpoin_but , ID_OB , 1 , " OB: " , xco + 10 , yco - 44 , ( width - 20 ) / 2 , 19 , & ( eoa - > ob ) , " Add this Object and all its children (cant be on an visible layer) " ) ;
2002-10-12 11:37:38 +00:00
uiDefButI ( block , NUM , 0 , " Time: " , xco + 10 + ( width - 20 ) / 2 , yco - 44 , ( width - 20 ) / 2 , 19 , & eoa - > time , 0.0 , 2000.0 , 0 , 0 , " Duration the new Object lives " ) ;
wval = ( width - 60 ) / 3 ;
uiDefBut ( block , LABEL , 0 , " linV " , xco , yco - 68 , 45 , 19 ,
NULL , 0 , 0 , 0 , 0 ,
" Velocity upon creation. " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 68 , wval , 19 ,
eoa - > linVelocity , - 100.0 , 100.0 , 10 , 0 ,
" Velocity upon creation, x component. " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 68 , wval , 19 ,
eoa - > linVelocity + 1 , - 100.0 , 100.0 , 10 , 0 ,
" Velocity upon creation, y component. " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 68 , wval , 19 ,
eoa - > linVelocity + 2 , - 100.0 , 100.0 , 10 , 0 ,
" Velocity upon creation, z component. " ) ;
2008-08-27 03:34:53 +00:00
uiDefButBitS ( block , TOG , ACT_EDOB_LOCAL_LINV , 0 , " L " , xco + 45 + 3 * wval , yco - 68 , 15 , 19 ,
2002-10-12 11:37:38 +00:00
& eoa - > localflag , 0.0 , 0.0 , 0 , 0 ,
" Apply the transformation locally " ) ;
2008-08-27 03:34:53 +00:00
uiDefBut ( block , LABEL , 0 , " AngV " , xco , yco - 90 , 45 , 19 ,
NULL , 0 , 0 , 0 , 0 ,
" Angular velocity upon creation. " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 , yco - 90 , wval , 19 ,
eoa - > angVelocity , - 10000.0 , 10000.0 , 10 , 0 ,
" Angular velocity upon creation, x component. " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + wval , yco - 90 , wval , 19 ,
eoa - > angVelocity + 1 , - 10000.0 , 10000.0 , 10 , 0 ,
" Angular velocity upon creation, y component. " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 45 + 2 * wval , yco - 90 , wval , 19 ,
eoa - > angVelocity + 2 , - 10000.0 , 10000.0 , 10 , 0 ,
" Angular velocity upon creation, z component. " ) ;
uiDefButBitS ( block , TOG , ACT_EDOB_LOCAL_ANGV , 0 , " L " , xco + 45 + 3 * wval , yco - 90 , 15 , 19 ,
& eoa - > localflag , 0.0 , 0.0 , 0 , 0 ,
" Apply the rotation locally " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( eoa - > type = = ACT_EDOB_END_OBJECT ) {
ysize = 28 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
}
else if ( eoa - > type = = ACT_EDOB_REPLACE_MESH ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2007-02-06 07:11:44 +00:00
uiDefIDPoinBut ( block , test_meshpoin_but , ID_ME , 1 , " ME: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( eoa - > me ) , " replace the existing mesh with this one " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( eoa - > type = = ACT_EDOB_TRACK_TO ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_obpoin_but , ID_OB , 1 , " OB: " , xco + 10 , yco - 44 , ( width - 20 ) / 2 , 19 , & ( eoa - > ob ) , " Track to this Object " ) ;
2002-10-12 11:37:38 +00:00
uiDefButI ( block , NUM , 0 , " Time: " , xco + 10 + ( width - 20 ) / 2 , yco - 44 , ( width - 20 ) / 2 - 40 , 19 , & eoa - > time , 0.0 , 2000.0 , 0 , 0 , " Duration the tracking takes " ) ;
uiDefButS ( block , TOG , 0 , " 3D " , xco + width - 50 , yco - 44 , 40 , 19 , & eoa - > flag , 0.0 , 0.0 , 0 , 0 , " Enable 3D tracking " ) ;
}
2008-06-25 14:09:15 +00:00
else if ( eoa - > type = = ACT_EDOB_DYNAMICS ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
str = " Dynamic Operation %t|Restore Dynamics %x0|Suspend Dynamics %x1|Enable Rigid Body %x2|Disable Rigid Body %x3 " ;
uiDefButS ( block , MENU , B_REDR , str , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( eoa - > dyn_operation ) , 0.0 , 0.0 , 0 , 0 , " " ) ;
}
str = " Edit Object %t|Add Object %x0|End Object %x1|Replace Mesh %x2|Track to %x3|Dynamics %x4 " ;
2002-10-12 11:37:38 +00:00
uiDefButS ( block , MENU , B_REDR , str , xco + 40 , yco - 24 , ( width - 80 ) , 19 , & eoa - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
yco - = ysize ;
break ;
case ACT_CONSTRAINT :
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
coa = act - > data ;
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 ( coa - > type = = ACT_CONST_TYPE_LOC ) {
ysize = 69 ;
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
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
/* str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4|Rot X %x8|Rot Y %x16|Rot Z %x32"; */
/* coa->flag &= ~(63); */
str = " Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4 " ;
2008-09-15 21:37:27 +00:00
coa - > flag & = 7 ;
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
coa - > time = 0 ;
uiDefButS ( block , MENU , 1 , str , xco + 10 , yco - 65 , 70 , 19 , & coa - > flag , 0.0 , 0.0 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
2008-07-22 23:05:06 +00:00
uiDefButS ( block , NUM , 0 , " damp " , xco + 10 , yco - 45 , 70 , 19 , & coa - > damp , 0.0 , 100.0 , 0 , 0 , " Damping factor: time constant (in frame) of low pass filter " ) ;
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
uiDefBut ( block , LABEL , 0 , " Min " , xco + 80 , yco - 45 , ( width - 90 ) / 2 , 19 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , LABEL , 0 , " Max " , xco + 80 + ( width - 90 ) / 2 , yco - 45 , ( width - 90 ) / 2 , 19 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
if ( coa - > flag & ACT_CONST_LOCX ) fp = coa - > minloc ;
else if ( coa - > flag & ACT_CONST_LOCY ) fp = coa - > minloc + 1 ;
else if ( coa - > flag & ACT_CONST_LOCZ ) fp = coa - > minloc + 2 ;
else if ( coa - > flag & ACT_CONST_ROTX ) fp = coa - > minrot ;
else if ( coa - > flag & ACT_CONST_ROTY ) fp = coa - > minrot + 1 ;
else fp = coa - > minrot + 2 ;
uiDefButF ( block , NUM , 0 , " " , xco + 80 , yco - 65 , ( width - 90 ) / 2 , 19 , fp , - 2000.0 , 2000.0 , 10 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 80 + ( width - 90 ) / 2 , yco - 65 , ( width - 90 ) / 2 , 19 , fp + 3 , - 2000.0 , 2000.0 , 10 , 0 , " " ) ;
} else if ( coa - > type = = ACT_CONST_TYPE_DIST ) {
ysize = 106 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
str = " Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32 " ;
uiDefButS ( block , MENU , B_REDR , str , xco + 10 , yco - 65 , 70 , 19 , & coa - > mode , 0.0 , 0.0 , 0 , 0 , " Set the direction of the ray " ) ;
2002-10-12 11:37:38 +00:00
2008-07-22 23:05:06 +00:00
uiDefButS ( block , NUM , 0 , " damp " , xco + 10 , yco - 45 , 70 , 19 , & coa - > damp , 0.0 , 100.0 , 0 , 0 , " Damping factor: time constant (in frame) of low pass filter " ) ;
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
uiDefBut ( block , LABEL , 0 , " Range " , xco + 80 , yco - 45 , ( width - 115 ) / 2 , 19 , NULL , 0.0 , 0.0 , 0 , 0 , " Set the maximum length of ray " ) ;
uiDefButBitS ( block , TOG , ACT_CONST_DISTANCE , B_REDR , " Dist " , xco + 80 + ( width - 115 ) / 2 , yco - 45 , ( width - 115 ) / 2 , 19 , & coa - > flag , 0.0 , 0.0 , 0 , 0 , " Force distance of object to point of impact of ray " ) ;
2008-09-26 18:03:14 +00:00
uiDefButBitS ( block , TOG , ACT_CONST_LOCAL , 0 , " L " , xco + 80 + ( width - 115 ) , yco - 45 , 25 , 19 ,
& coa - > flag , 0.0 , 0.0 , 0 , 0 , " Set ray along object's axis or global axis " ) ;
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
2008-07-23 21:37:37 +00:00
if ( coa - > mode & ( ACT_CONST_DIRPX | ACT_CONST_DIRNX ) ) fp = coa - > minloc ;
else if ( coa - > mode & ( ACT_CONST_DIRPY | ACT_CONST_DIRNY ) ) fp = coa - > minloc + 1 ;
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 fp = coa - > minloc + 2 ;
uiDefButF ( block , NUM , 0 , " " , xco + 80 , yco - 65 , ( width - 115 ) / 2 , 19 , fp + 3 , 0.0 , 2000.0 , 10 , 0 , " Maximum length of ray " ) ;
if ( coa - > flag & ACT_CONST_DISTANCE )
uiDefButF ( block , NUM , 0 , " " , xco + 80 + ( width - 115 ) / 2 , yco - 65 , ( width - 115 ) / 2 , 19 , fp , - 2000.0 , 2000.0 , 10 , 0 , " Keep this distance to target " ) ;
uiDefButBitS ( block , TOG , ACT_CONST_NORMAL , 0 , " N " , xco + 80 + ( width - 115 ) , yco - 65 , 25 , 19 ,
2008-09-26 18:03:14 +00:00
& coa - > flag , 0.0 , 0.0 , 0 , 0 , " Set object axis along (local axis) or parallel (global axis) to the normal at hit position " ) ;
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
uiDefButBitS ( block , TOG , ACT_CONST_MATERIAL , B_REDR , " M/P " , xco + 10 , yco - 84 , 40 , 19 ,
& coa - > flag , 0.0 , 0.0 , 0 , 0 , " Detect material instead of property " ) ;
if ( coa - > flag & ACT_CONST_MATERIAL )
{
uiDefBut ( block , TEX , 1 , " Material: " , xco + 50 , yco - 84 , ( width - 60 ) , 19 ,
coa - > matprop , 0 , 31 , 0 , 0 ,
" Ray detects only Objects with this material " ) ;
}
else
{
uiDefBut ( block , TEX , 1 , " Property: " , xco + 50 , yco - 84 , ( width - 60 ) , 19 ,
coa - > matprop , 0 , 31 , 0 , 0 ,
" Ray detect only Objects with this property " ) ;
}
uiDefButBitS ( block , TOG , ACT_CONST_PERMANENT , 0 , " PER " , xco + 10 , yco - 103 , 40 , 19 ,
& coa - > flag , 0.0 , 0.0 , 0 , 0 , " Persistent actuator: stays active even if ray does not reach target " ) ;
uiDefButS ( block , NUM , 0 , " time " , xco + 50 , yco - 103 , ( width - 60 ) / 2 , 19 , & ( coa - > time ) , 0.0 , 1000.0 , 0 , 0 , " Maximum activation time in frame, 0 for unlimited " ) ;
uiDefButS ( block , NUM , 0 , " rotDamp " , xco + 50 + ( width - 60 ) / 2 , yco - 103 , ( width - 60 ) / 2 , 19 , & ( coa - > rotdamp ) , 0.0 , 100.0 , 0 , 0 , " Use a different damping for orientation " ) ;
} else if ( coa - > type = = ACT_CONST_TYPE_ORI ) {
ysize = 87 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
str = " Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4 " ;
uiDefButS ( block , MENU , B_REDR , str , xco + 10 , yco - 65 , 70 , 19 , & coa - > mode , 0.0 , 0.0 , 0 , 0 , " Select the axis to be aligned along the reference direction " ) ;
2002-10-12 11:37:38 +00:00
2008-07-22 23:05:06 +00:00
uiDefButS ( block , NUM , 0 , " damp " , xco + 10 , yco - 45 , 70 , 19 , & coa - > damp , 0.0 , 100.0 , 0 , 0 , " Damping factor: time constant (in frame) of low pass filter " ) ;
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
uiDefBut ( block , LABEL , 0 , " X " , xco + 80 , yco - 45 , ( width - 115 ) / 3 , 19 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , LABEL , 0 , " Y " , xco + 80 + ( width - 115 ) / 3 , yco - 45 , ( width - 115 ) / 3 , 19 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , LABEL , 0 , " Z " , xco + 80 + 2 * ( width - 115 ) / 3 , yco - 45 , ( width - 115 ) / 3 , 19 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 80 , yco - 65 , ( width - 115 ) / 3 , 19 , & coa - > maxrot [ 0 ] , - 2000.0 , 2000.0 , 10 , 0 , " X component of reference direction " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 80 + ( width - 115 ) / 3 , yco - 65 , ( width - 115 ) / 3 , 19 , & coa - > maxrot [ 1 ] , - 2000.0 , 2000.0 , 10 , 0 , " Y component of reference direction " ) ;
uiDefButF ( block , NUM , 0 , " " , xco + 80 + 2 * ( width - 115 ) / 3 , yco - 65 , ( width - 115 ) / 3 , 19 , & coa - > maxrot [ 2 ] , - 2000.0 , 2000.0 , 10 , 0 , " Z component of reference direction " ) ;
2002-10-12 11:37:38 +00:00
2008-07-22 23:05:06 +00:00
uiDefButS ( block , NUM , 0 , " time " , xco + 10 , yco - 84 , 70 , 19 , & ( coa - > time ) , 0.0 , 1000.0 , 0 , 0 , " Maximum activation time in frame, 0 for unlimited " ) ;
uiDefButF ( block , NUM , 0 , " min " , xco + 80 , yco - 84 , ( width - 115 ) / 2 , 19 , & ( coa - > minloc [ 0 ] ) , 0.0 , 180.0 , 10 , 1 , " Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max " ) ;
uiDefButF ( block , NUM , 0 , " max " , xco + 80 + ( width - 115 ) / 2 , yco - 84 , ( width - 115 ) / 2 , 19 , & ( coa - > maxloc [ 0 ] ) , 0.0 , 180.0 , 10 , 1 , " Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max " ) ;
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
}
str = " Constraint Type %t|Location %x0|Distance %x1|Orientation %x2 " ;
but = uiDefButS ( block , MENU , B_REDR , str , xco + 40 , yco - 23 , ( width - 80 ) , 19 , & coa - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
yco - = ysize ;
break ;
case ACT_SCENE :
sca = act - > data ;
if ( sca - > type = = ACT_SCENE_RESTART ) {
ysize = 28 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
}
else if ( sca - > type = = ACT_SCENE_CAMERA ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2008-04-16 18:58:11 +00:00
uiDefIDPoinBut ( block , test_obpoin_but , ID_OB , 1 , " OB: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( sca - > camera ) , " Set this Camera. Leave empty to refer to self object " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( sca - > type = = ACT_SCENE_SET ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_scenepoin_but , ID_SCE , 1 , " SCE: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( sca - > scene ) , " Set this Scene " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( sca - > type = = ACT_SCENE_ADD_FRONT ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_scenepoin_but , ID_SCE , 1 , " SCE: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( sca - > scene ) , " Add an Overlay Scene " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( sca - > type = = ACT_SCENE_ADD_BACK ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_scenepoin_but , ID_SCE , 1 , " SCE: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( sca - > scene ) , " Add a Background Scene " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( sca - > type = = ACT_SCENE_REMOVE ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_scenepoin_but , ID_SCE , 1 , " SCE: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( sca - > scene ) , " Remove a Scene " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( sca - > type = = ACT_SCENE_SUSPEND ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_scenepoin_but , ID_SCE , 1 , " SCE: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( sca - > scene ) , " Pause a Scene " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( sca - > type = = ACT_SCENE_RESUME ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
2005-10-28 16:49:48 +00:00
uiDefIDPoinBut ( block , test_scenepoin_but , ID_SCE , 1 , " SCE: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( sca - > scene ) , " Unpause a Scene " ) ;
2002-10-12 11:37:38 +00:00
}
str = " Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7 " ;
uiDefButS ( block , MENU , B_REDR , str , xco + 40 , yco - 24 , ( width - 80 ) , 19 , & sca - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
yco - = ysize ;
break ;
case ACT_GAME :
{
gma = act - > data ;
if ( gma - > type = = ACT_GAME_LOAD )
{
//ysize = 68;
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
uiDefBut ( block , TEX , 1 , " File: " , xco + 10 , yco - 44 , width - 20 , 19 , & ( gma - > filename ) , 0 , 63 , 0 , 0 , " Load this file " ) ;
// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation");
}
/* else if (gma->type == ACT_GAME_START)
{
ysize = 68 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
uiDefBut ( block , TEX , 1 , " File: " , xco + 10 , yco - 44 , width - 20 , 19 , & ( gma - > filename ) , 0 , 63 , 0 , 0 , " Load this file " ) ;
uiDefBut ( block , TEX , 1 , " Anim: " , xco + 10 , yco - 64 , width - 20 , 19 , & ( gma - > loadaniname ) , 0 , 63 , 0 , 0 , " Use this loadinganimation " ) ;
}
2008-09-12 02:15:16 +00:00
*/ else if ( ELEM4 ( gma - > type , ACT_GAME_RESTART , ACT_GAME_QUIT , ACT_GAME_SAVECFG , ACT_GAME_LOADCFG ) )
2002-10-12 11:37:38 +00:00
{
ysize = 28 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
}
//str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3";
2008-09-12 02:15:16 +00:00
str = " Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save GameLogic.globalDict %x4|Load GameLogic.globalDict %x5 " ;
2002-10-12 11:37:38 +00:00
uiDefButS ( block , MENU , B_REDR , str , xco + 40 , yco - 24 , ( width - 80 ) , 19 , & gma - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
yco - = ysize ;
break ;
}
case ACT_GROUP :
ga = act - > data ;
ysize = 52 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
str = " GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5 " ;
uiDefButS ( block , MENU , 1 , str , xco + 20 , yco - 24 , width - 40 , 19 , & ga - > type , 0 , 0 , 0 , 0 , " " ) ;
if ( ga - > type = = ACT_GROUP_SET ) {
uiDefBut ( block , TEX , 0 , " Key: " , xco + 20 , yco - 44 , ( width - 10 ) / 2 , 19 , ga - > name , 0.0 , 31.0 , 0 , 0 , " This name defines groupkey to be set " ) ;
2006-05-06 15:26:53 +00:00
uiDefButI ( block , NUM , 0 , " Frame: " , xco + 20 + ( width - 10 ) / 2 , yco - 44 , ( width - 70 ) / 2 , 19 , & ga - > sta , 0.0 , 2500.0 , 0 , 0 , " Set this frame " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( ga - > type = = ACT_GROUP_FROM_PROP ) {
uiDefBut ( block , TEX , 0 , " Prop: " , xco + 20 , yco - 44 , width - 40 , 19 , ga - > name , 0.0 , 31.0 , 0 , 0 , " Use this property to define the Group position " ) ;
}
else {
2008-07-07 21:04:30 +00:00
uiDefButI ( block , NUM , 0 , " State " , xco + 20 , yco - 44 , ( width - 40 ) / 2 , 19 , & ga - > sta , 0.0 , 2500.0 , 0 , 0 , " Start frame " ) ;
2006-05-06 15:26:53 +00:00
uiDefButI ( block , NUM , 0 , " End " , xco + 20 + ( width - 40 ) / 2 , yco - 44 , ( width - 40 ) / 2 , 19 , & ga - > end , 0.0 , 2500.0 , 0 , 0 , " End frame " ) ;
2002-10-12 11:37:38 +00:00
}
yco - = ysize ;
break ;
case ACT_VISIBILITY :
ysize = 24 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco ,
( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
visAct = act - > data ;
2008-09-22 07:17:39 +00:00
uiBlockBeginAlign ( block ) ;
uiDefButBitI ( block , TOGN , ACT_VISIBILITY_INVISIBLE , B_REDR ,
" Visible " ,
xco + 10 , yco - 20 , ( width - 20 ) / 3 , 19 , & visAct - > flag ,
2002-10-12 11:37:38 +00:00
0.0 , 0.0 , 0 , 0 ,
2008-09-22 07:17:39 +00:00
" Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner) " ) ;
uiDefButBitI ( block , TOG , ACT_VISIBILITY_INVISIBLE , B_REDR ,
2002-10-12 11:37:38 +00:00
" Invisible " ,
2008-09-22 07:17:39 +00:00
xco + 10 + ( ( width - 20 ) / 3 ) , yco - 20 , ( width - 20 ) / 3 , 19 , & visAct - > flag ,
2002-10-12 11:37:38 +00:00
0.0 , 0.0 , 0 , 0 ,
2008-09-22 07:17:39 +00:00
" Set the object invisible. Initialized from the objects render restriction toggle (access in the outliner) " ) ;
uiBlockEndAlign ( block ) ;
uiDefButBitI ( block , TOG , ACT_VISIBILITY_RECURSIVE , B_NOP ,
" Children " ,
xco + 10 + ( ( ( width - 20 ) / 3 ) * 2 ) + 10 , yco - 20 , ( ( width - 20 ) / 3 ) - 10 , 19 , & visAct - > flag ,
0.0 , 0.0 , 0 , 0 ,
" Sets all the children of this object to the same visibility recursively " ) ;
2002-10-12 11:37:38 +00:00
yco - = ysize ;
break ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
case ACT_STATE :
ysize = 34 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco ,
( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
staAct = act - > data ;
str = " Operation %t|Cpy %x0|Add %x1|Sub %x2|Inv %x3 " ;
uiDefButI ( block , MENU , B_REDR , str ,
xco + 10 , yco - 24 , 65 , 19 , & staAct - > type ,
0.0 , 0.0 , 0 , 0 ,
" Select the bit operation on object state mask " ) ;
for ( wval = 0 ; wval < 15 ; wval + = 5 ) {
uiBlockBeginAlign ( block ) ;
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
2008-09-15 21:10:51 +00:00
but = uiDefButBitI ( block , TOG , 1 < < ( stbit + wval ) , stbit + wval , " " , ( short ) ( xco + 85 + 12 * stbit + 13 * wval ) , yco - 17 , 12 , 12 , ( int * ) & ( staAct - > mask ) , 0 , 0 , 0 , 0 , get_state_name ( ob , ( short ) ( stbit + wval ) ) ) ;
uiButSetFunc ( but , check_state_mask , but , & ( staAct - > mask ) ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
}
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
2008-09-15 21:10:51 +00:00
but = uiDefButBitI ( block , TOG , 1 < < ( stbit + wval + 15 ) , stbit + wval + 15 , " " , ( short ) ( xco + 85 + 12 * stbit + 13 * wval ) , yco - 29 , 12 , 12 , ( int * ) & ( staAct - > mask ) , 0 , 0 , 0 , 0 , get_state_name ( ob , ( short ) ( stbit + wval + 15 ) ) ) ;
uiButSetFunc ( but , check_state_mask , but , & ( staAct - > mask ) ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
}
}
uiBlockEndAlign ( block ) ;
yco - = ysize ;
break ;
2002-10-12 11:37:38 +00:00
case ACT_RANDOM :
ysize = 69 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco ,
( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
randAct = act - > data ;
/* 1. seed */
uiDefButI ( block , NUM , 1 , " Seed: " , ( xco + 10 ) , yco - 24 , 0.4 * ( width - 20 ) , 19 ,
& randAct - > seed , 0 , 1000 , 0 , 0 ,
" Initial seed of the random generator. Use Python for more freedom. "
" (Choose 0 for not random) " ) ;
/* 2. distribution type */
/* One pick per distribution. These numbers MUST match the #defines */
/* in game.h !!! */
str = " Distribution %t|Bool Constant %x0|Bool Uniform %x1 "
" |Bool Bernoulli %x2|Int Constant %x3|Int Uniform %x4 "
" |Int Poisson %x5|Float Constant %x6|Float Uniform %x7 "
" |Float Normal %x8|Float Neg. Exp. %x9 " ;
uiDefButI ( block , MENU , B_REDR , str , ( xco + 10 ) + 0.4 * ( width - 20 ) , yco - 24 , 0.6 * ( width - 20 ) , 19 ,
& randAct - > distribution , 0.0 , 0.0 , 0 , 0 ,
" Choose the type of distribution " ) ;
/* 3. property */
uiDefBut ( block , TEX , 1 , " Property: " , ( xco + 10 ) , yco - 44 , ( width - 20 ) , 19 ,
& randAct - > propname , 0 , 31 , 0 , 0 ,
" Assign the random value to this property " ) ;
/*4. and 5. arguments for the distribution*/
switch ( randAct - > distribution ) {
case ACT_RANDOM_BOOL_CONST :
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , 1 , 1 , " Always true " , ( xco + 10 ) , yco - 64 , ( width - 20 ) , 19 ,
2002-10-12 11:37:38 +00:00
& randAct - > int_arg_1 , 2.0 , 1 , 0 , 0 ,
" Always false or always true " ) ;
break ;
case ACT_RANDOM_BOOL_UNIFORM :
uiDefBut ( block , LABEL , 0 , " Do a 50-50 pick. " , ( xco + 10 ) , yco - 64 , ( width - 20 ) , 19 ,
NULL , 0 , 0 , 0 , 0 ,
2004-04-29 15:52:11 +00:00
" Choose between true and false, 50% chance each. " ) ;
2002-10-12 11:37:38 +00:00
break ;
case ACT_RANDOM_BOOL_BERNOUILLI :
uiDefButF ( block , NUM , 1 , " Chance " , ( xco + 10 ) , yco - 64 , ( width - 20 ) , 19 ,
& randAct - > float_arg_1 , 0.0 , 1.0 , 0 , 0 ,
" Pick a number between 0 and 1. Success if you stay "
" below this value " ) ;
break ;
case ACT_RANDOM_INT_CONST :
uiDefButI ( block , NUM , 1 , " Value: " , ( xco + 10 ) , yco - 64 , ( width - 20 ) , 19 ,
& randAct - > int_arg_1 , - 1000 , 1000 , 0 , 0 ,
" Always return this number " ) ;
break ;
case ACT_RANDOM_INT_UNIFORM :
uiDefButI ( block , NUM , 1 , " Min: " , ( xco + 10 ) , yco - 64 , ( width - 20 ) / 2 , 19 ,
& randAct - > int_arg_1 , - 1000 , 1000 , 0 , 0 ,
" Choose a number from a range. "
" Lower boundary of the range. " ) ;
uiDefButI ( block , NUM , 1 , " Max: " , ( xco + 10 ) + ( width - 20 ) / 2 , yco - 64 , ( width - 20 ) / 2 , 19 ,
& randAct - > int_arg_2 , - 1000 , 1000 , 0 , 0 ,
" Choose a number from a range. "
" Upper boundary of the range. " ) ;
break ;
case ACT_RANDOM_INT_POISSON :
uiDefButF ( block , NUM , 1 , " Mean: " , ( xco + 10 ) , yco - 64 , ( width - 20 ) , 19 ,
& randAct - > float_arg_1 , 0.01 , 100.0 , 0 , 0 ,
" Expected mean value of the distribution. " ) ;
break ;
case ACT_RANDOM_FLOAT_CONST :
uiDefButF ( block , NUM , 1 , " Value: " , ( xco + 10 ) , yco - 64 , ( width - 20 ) , 19 ,
& randAct - > float_arg_1 , 0.0 , 1.0 , 0 , 0 ,
" Always return this number " ) ;
break ;
case ACT_RANDOM_FLOAT_UNIFORM :
uiDefButF ( block , NUM , 1 , " Min: " , ( xco + 10 ) , yco - 64 , ( width - 20 ) / 2 , 19 ,
& randAct - > float_arg_1 , - 10000.0 , 10000.0 , 0 , 0 ,
" Choose a number from a range. "
" Lower boundary of the range. " ) ;
uiDefButF ( block , NUM , 1 , " Max: " , ( xco + 10 ) + ( width - 20 ) / 2 , yco - 64 , ( width - 20 ) / 2 , 19 ,
& randAct - > float_arg_2 , - 10000.0 , 10000.0 , 0 , 0 ,
" Choose a number from a range. "
" Upper boundary of the range. " ) ;
break ;
case ACT_RANDOM_FLOAT_NORMAL :
uiDefButF ( block , NUM , 1 , " Mean: " , ( xco + 10 ) , yco - 64 , ( width - 20 ) / 2 , 19 ,
& randAct - > float_arg_1 , - 10000.0 , 10000.0 , 0 , 0 ,
" A normal distribution. Mean of the distribution. " ) ;
uiDefButF ( block , NUM , 1 , " SD: " , ( xco + 10 ) + ( width - 20 ) / 2 , yco - 64 , ( width - 20 ) / 2 , 19 ,
& randAct - > float_arg_2 , 0.0 , 10000.0 , 0 , 0 ,
" A normal distribution. Standard deviation of the "
" distribution. " ) ;
break ;
case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL :
uiDefButF ( block , NUM , 1 , " Half-life time: " , ( xco + 10 ) , yco - 64 , ( width - 20 ) , 19 ,
& randAct - > float_arg_1 , 0.001 , 10000.0 , 0 , 0 ,
" Negative exponential dropoff. " ) ;
break ;
default :
; /* don't know what this distro is... can be useful for testing */
/* though :) */
}
yco - = ysize ;
break ;
case ACT_MESSAGE :
ma = act - > data ;
# define MESSAGE_SENSOR_TO_FIELD_WORKS /* Really? Not really. Don't remove this ifdef yet */
# ifdef MESSAGE_SENSOR_TO_FIELD_WORKS
ysize = 4 + ( 3 * 24 ) ; /* footer + number of lines * 24 pixels/line */
# else
ysize = 4 + ( 2 * 24 ) ; /* footer + number of lines * 24 pixels/line */
# endif
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize ,
( float ) xco + width , ( float ) yco , 1 ) ;
myline = 1 ;
# ifdef MESSAGE_SENSOR_TO_FIELD_WORKS
/* line 1: To */
uiDefBut ( block , TEX , 1 , " To: " ,
( xco + 10 ) , ( yco - ( myline + + * 24 ) ) , ( width - 20 ) , 19 ,
& ma - > toPropName , 0 , 31 , 0 , 0 ,
2008-06-20 20:54:29 +00:00
" Optional send message to objects with this name only (Prefix name with OB) "
2002-10-12 11:37:38 +00:00
" , or empty to broadcast " ) ;
# endif
/* line 2: Message Subject */
uiDefBut ( block , TEX , 1 , " Subject: " ,
( xco + 10 ) , ( yco - ( myline + + * 24 ) ) , ( width - 20 ) , 19 ,
& ma - > subject , 0 , 31 , 0 , 0 ,
" Optional message subject. This is what can be filtered on. " ) ;
/* line 3: Text/Property */
2005-08-03 18:48:22 +00:00
uiDefButBitS ( block , TOG , 1 , B_REDR , " T/P " ,
2002-10-12 11:37:38 +00:00
( xco + 10 ) , ( yco - ( myline * 24 ) ) , ( 0.20 * ( width - 20 ) ) , 19 ,
& ma - > bodyType , 0.0 , 0.0 , 0 , 0 ,
" Toggle message type: either Text or a PropertyName. " ) ;
if ( ma - > bodyType = = ACT_MESG_MESG )
{
/* line 3: Message Body */
uiDefBut ( block , TEX , 1 , " Body: " ,
( xco + 10 + ( 0.20 * ( width - 20 ) ) ) , ( yco - ( myline + + * 24 ) ) , ( 0.8 * ( width - 20 ) ) , 19 ,
& ma - > body , 0 , 31 , 0 , 0 ,
" Optional message body Text " ) ;
} else
{
/* line 3: Property body (set by property) */
uiDefBut ( block , TEX , 1 , " Propname: " ,
( xco + 10 + ( 0.20 * ( width - 20 ) ) ) , ( yco - ( myline + + * 24 ) ) , ( 0.8 * ( width - 20 ) ) , 19 ,
& ma - > body , 0 , 31 , 0 , 0 ,
" The message body will be set by the Property Value " ) ;
}
yco - = ysize ;
break ;
2007-10-22 20:24:26 +00:00
case ACT_2DFILTER :
tdfa = act - > data ;
2007-11-06 12:16:12 +00:00
ysize = 50 ;
if ( tdfa - > type = = ACT_2DFILTER_CUSTOMFILTER )
{
ysize + = 20 ;
}
2007-10-22 20:24:26 +00:00
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
switch ( tdfa - > type )
{
case ACT_2DFILTER_MOTIONBLUR :
if ( ! tdfa - > flag )
{
uiDefButS ( block , TOG , B_REDR , " D " , xco + 30 , yco - 44 , 19 , 19 , & tdfa - > flag , 0.0 , 0.0 , 0.0 , 0.0 , " Disable Motion Blur " ) ;
uiDefButF ( block , NUM , B_REDR , " Value: " , xco + 52 , yco - 44 , width - 82 , 19 , & tdfa - > float_arg , 0.0 , 1.0 , 0.0 , 0.0 , " Set motion blur value " ) ;
}
else
{
uiDefButS ( block , TOG , B_REDR , " Disabled " , xco + 30 , yco - 44 , width - 60 , 19 , & tdfa - > flag , 0.0 , 0.0 , 0.0 , 0.0 , " Enable Motion Blur " ) ;
}
break ;
case ACT_2DFILTER_BLUR :
case ACT_2DFILTER_SHARPEN :
case ACT_2DFILTER_DILATION :
case ACT_2DFILTER_EROSION :
case ACT_2DFILTER_LAPLACIAN :
case ACT_2DFILTER_SOBEL :
case ACT_2DFILTER_PREWITT :
case ACT_2DFILTER_GRAYSCALE :
case ACT_2DFILTER_SEPIA :
case ACT_2DFILTER_INVERT :
case ACT_2DFILTER_NOFILTER :
2007-11-06 12:16:12 +00:00
case ACT_2DFILTER_DISABLED :
case ACT_2DFILTER_ENABLED :
uiDefButI ( block , NUM , B_REDR , " Pass Number: " , xco + 30 , yco - 44 , width - 60 , 19 , & tdfa - > int_arg , 0.0 , MAX_RENDER_PASS - 1 , 0.0 , 0.0 , " Set motion blur value " ) ;
break ;
case ACT_2DFILTER_CUSTOMFILTER :
uiDefButI ( block , NUM , B_REDR , " Pass Number: " , xco + 30 , yco - 44 , width - 60 , 19 , & tdfa - > int_arg , 0.0 , MAX_RENDER_PASS - 1 , 0.0 , 0.0 , " Set motion blur value " ) ;
2008-07-12 10:21:37 +00:00
uiDefIDPoinBut ( block , test_scriptpoin_but , ID_SCRIPT , 1 , " Script: " , xco + 30 , yco - 64 , width - 60 , 19 , & tdfa - > text , " " ) ;
2007-10-22 20:24:26 +00:00
break ;
}
2007-11-06 12:16:12 +00:00
str = " 2D Filter %t|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5| "
" Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12| "
" Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0| " ;
2007-10-22 20:24:26 +00:00
uiDefButS ( block , MENU , B_REDR , str , xco + 30 , yco - 24 , width - 60 , 19 , & tdfa - > type , 0.0 , 0.0 , 0.0 , 0.0 , " 2D filter type " ) ;
yco - = ysize ;
break ;
2008-04-06 18:30:52 +00:00
case ACT_PARENT :
parAct = act - > data ;
if ( parAct - > type = = ACT_PARENT_SET ) {
ysize = 48 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
uiDefIDPoinBut ( block , test_obpoin_but , ID_OB , 1 , " OB: " , xco + 40 , yco - 44 , ( width - 80 ) , 19 , & ( parAct - > ob ) , " Set this object as parent " ) ;
}
else if ( parAct - > type = = ACT_PARENT_REMOVE ) {
ysize = 28 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
}
str = " Parent %t|Set Parent %x0|Remove Parent %x1 " ;
uiDefButI ( block , MENU , B_REDR , str , xco + 40 , yco - 24 , ( width - 80 ) , 19 , & parAct - > type , 0.0 , 0.0 , 0 , 0 , " " ) ;
yco - = ysize ;
break ;
2002-10-12 11:37:38 +00:00
default :
ysize = 4 ;
glRects ( xco , yco - ysize , xco + width , yco ) ;
uiEmboss ( ( float ) xco , ( float ) yco - ysize , ( float ) xco + width , ( float ) yco , 1 ) ;
yco - = ysize ;
break ;
}
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
return yco - 4 ;
}
static void do_sensor_menu ( void * arg , int event )
{
ID * * idar ;
Object * ob ;
bSensor * sens ;
short count , a ;
idar = get_selected_and_linked_obs ( & count , G . buts - > scaflag ) ;
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
if ( event = = 0 | | event = = 2 ) ob - > scaflag | = OB_SHOWSENS ;
else if ( event = = 1 ) ob - > scaflag & = ~ OB_SHOWSENS ;
}
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
sens = ob - > sensors . first ;
while ( sens ) {
if ( event = = 2 ) sens - > flag | = SENS_SHOW ;
else if ( event = = 3 ) sens - > flag & = ~ SENS_SHOW ;
sens = sens - > next ;
}
}
if ( idar ) MEM_freeN ( idar ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
}
static uiBlock * sensor_menu ( void * arg_unused )
{
uiBlock * block ;
int yco = 0 ;
block = uiNewBlock ( & curarea - > uiblocks , " filemenu " , UI_EMBOSSP , UI_HELV , curarea - > win ) ;
uiBlockSetButmFunc ( block , do_sensor_menu , NULL ) ;
uiDefBut ( block , BUTM , 1 , " Show Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , ( short ) ( yco - = 6 ) , 160 , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Show Sensors " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Sensors " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 3 , " " ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
return block ;
}
static void do_controller_menu ( void * arg , int event )
{
ID * * idar ;
Object * ob ;
bController * cont ;
short count , a ;
idar = get_selected_and_linked_obs ( & count , G . buts - > scaflag ) ;
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
if ( event = = 0 | | event = = 2 ) ob - > scaflag | = OB_SHOWCONT ;
else if ( event = = 1 ) ob - > scaflag & = ~ OB_SHOWCONT ;
}
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
cont = ob - > controllers . first ;
while ( cont ) {
if ( event = = 2 ) cont - > flag | = CONT_SHOW ;
else if ( event = = 3 ) cont - > flag & = ~ CONT_SHOW ;
cont = cont - > next ;
}
}
if ( idar ) MEM_freeN ( idar ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
}
static uiBlock * controller_menu ( void * arg_unused )
{
uiBlock * block ;
int yco = 0 ;
block = uiNewBlock ( & curarea - > uiblocks , " filemenu " , UI_EMBOSSP , UI_HELV , curarea - > win ) ;
uiBlockSetButmFunc ( block , do_controller_menu , NULL ) ;
uiDefBut ( block , BUTM , 1 , " Show Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , ( short ) ( yco - = 6 ) , 160 , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Show Controllers " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 2 , 2 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Controllers " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 3 , 3 , " " ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
return block ;
}
static void do_actuator_menu ( void * arg , int event )
{
ID * * idar ;
Object * ob ;
bActuator * act ;
short count , a ;
idar = get_selected_and_linked_obs ( & count , G . buts - > scaflag ) ;
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
if ( event = = 0 | | event = = 2 ) ob - > scaflag | = OB_SHOWACT ;
else if ( event = = 1 ) ob - > scaflag & = ~ OB_SHOWACT ;
}
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
act = ob - > actuators . first ;
while ( act ) {
if ( event = = 2 ) act - > flag | = ACT_SHOW ;
else if ( event = = 3 ) act - > flag & = ~ ACT_SHOW ;
act = act - > next ;
}
}
if ( idar ) MEM_freeN ( idar ) ;
2003-10-07 18:24:02 +00:00
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
2002-10-12 11:37:38 +00:00
}
static uiBlock * actuator_menu ( void * arg_unused )
{
uiBlock * block ;
int xco = 0 ;
block = uiNewBlock ( & curarea - > uiblocks , " filemenu " , UI_EMBOSSP , UI_HELV , curarea - > win ) ;
uiBlockSetButmFunc ( block , do_actuator_menu , NULL ) ;
uiDefBut ( block , BUTM , 1 , " Show Objects " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Objects " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , ( short ) ( xco - = 6 ) , 160 , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Show Actuators " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Actuators " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 3 , " " ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
return block ;
}
2004-03-22 22:02:18 +00:00
void buttons_enji ( uiBlock * block , Object * ob )
{
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , OB_SECTOR , B_SETSECTOR , " Sector " ,
2004-03-22 22:02:18 +00:00
10 , 205 , 65 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" All game elements should be in the Sector boundbox " ) ;
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , OB_PROP , B_SETPROP , " Prop " ,
2004-03-22 22:02:18 +00:00
75 , 205 , 65 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" An Object fixed within a sector " ) ;
uiBlockSetCol ( block , BUTPURPLE ) ;
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , OB_ACTOR , B_SETACTOR , " Actor " ,
2004-03-22 22:02:18 +00:00
140 , 205 , 65 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Objects that are evaluated by the engine " ) ;
if ( ob - > gameflag & OB_ACTOR ) {
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , OB_DYNAMIC , B_SETDYNA , " Dynamic " ,
2004-03-22 22:02:18 +00:00
205 , 205 , 75 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Motion defined by laws of physics " ) ;
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , OB_MAINACTOR , B_SETMAINACTOR , " MainActor " ,
2004-03-22 22:02:18 +00:00
280 , 205 , 70 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 , " " ) ;
if ( ob - > gameflag & OB_DYNAMIC ) {
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , OB_DO_FH , B_DIFF , " Do Fh " ,
2004-03-22 22:02:18 +00:00
10 , 185 , 50 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Use Fh settings in Materials " ) ;
2005-08-03 18:48:22 +00:00
uiDefButBitI ( block , TOG , OB_ROT_FH , B_DIFF , " Rot Fh " ,
2004-03-22 22:02:18 +00:00
60 , 185 , 50 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Use face normal to rotate Object " ) ;
uiBlockSetCol ( block , BUTGREY ) ;
2005-08-03 18:48:22 +00:00
uiDefButF ( block , NUM , B_DIFF , " Mass: " ,
2004-03-22 22:02:18 +00:00
110 , 185 , 120 , 19 , & ob - > mass , 0.01 , 100.0 , 10 , 0 ,
" The mass of the Object " ) ;
2005-08-03 18:48:22 +00:00
uiDefButF ( block , NUM , REDRAWVIEW3D , " Size: " ,
2004-03-22 22:02:18 +00:00
230 , 185 , 120 , 19 , & ob - > inertia , 0.01 , 10.0 , 10 , 0 ,
" Bounding sphere size " ) ;
2005-08-03 18:48:22 +00:00
uiDefButF ( block , NUM , B_DIFF , " Damp: " ,
2004-03-22 22:02:18 +00:00
10 , 165 , 100 , 19 , & ob - > damping , 0.0 , 1.0 , 10 , 0 ,
" General movement damping " ) ;
2005-08-03 18:48:22 +00:00
uiDefButF ( block , NUM , B_DIFF , " RotDamp: " ,
2004-03-22 22:02:18 +00:00
110 , 165 , 120 , 19 , & ob - > rdamping , 0.0 , 1.0 , 10 , 0 ,
" General rotation damping " ) ;
}
}
}
void buttons_ketsji ( uiBlock * block , Object * ob )
{
2008-09-16 22:52:42 +00:00
uiDefButBitI ( block , TOG , OB_COLLISION , B_REDR , " Physics " ,
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
10 , 205 , 70 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Objects that have a physics representation " ) ;
2008-09-16 22:52:42 +00:00
if ( ob - > gameflag & OB_COLLISION ) {
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiBlockBeginAlign ( block ) ;
uiDefButBitI ( block , TOG , OB_ACTOR , B_REDR , " Actor " ,
80 , 205 , 55 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Objects that are evaluated by the engine " ) ;
if ( ob - > gameflag & OB_ACTOR ) {
uiDefButBitI ( block , TOG , OB_GHOST , B_REDR , " Ghost " , 135 , 205 , 55 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Objects that don't restitute collisions (like a ghost) " ) ;
uiDefButBitI ( block , TOG , OB_DYNAMIC , B_REDR , " Dynamic " , 190 , 205 , 75 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Motion defined by laws of physics " ) ;
if ( ob - > gameflag & OB_DYNAMIC ) {
uiDefButBitI ( block , TOG , OB_RIGID_BODY , B_REDR , " Rigid Body " , 265 , 205 , 85 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Enable rolling physics " ) ;
uiDefButF ( block , NUM , B_DIFF , " Mass: " , 10 , 185 , 130 , 19 ,
& ob - > mass , 0.01 , 10000.0 , 10 , 2 ,
" The mass of the Object " ) ;
uiDefButF ( block , NUM , REDRAWVIEW3D , " Radius: " , 140 , 185 , 130 , 19 ,
& ob - > inertia , 0.01 , 10.0 , 10 , 2 ,
" Bounding sphere radius " ) ;
uiDefButBitI ( block , TOG , OB_COLLISION_RESPONSE , B_REDR , " No sleeping " , 270 , 185 , 80 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Disable auto (de)activation " ) ;
uiDefButF ( block , NUMSLI , B_DIFF , " Damp " , 10 , 165 , 150 , 19 ,
& ob - > damping , 0.0 , 1.0 , 10 , 0 ,
" General movement damping " ) ;
uiDefButF ( block , NUMSLI , B_DIFF , " RotDamp " , 160 , 165 , 190 , 19 ,
& ob - > rdamping , 0.0 , 1.0 , 10 , 0 ,
" General rotation damping " ) ;
uiDefButBitI ( block , TOG , OB_DO_FH , B_DIFF , " Do Fh " , 10 , 145 , 50 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Use Fh settings in Materials " ) ;
uiDefButBitI ( block , TOG , OB_ROT_FH , B_DIFF , " Rot Fh " , 60 , 145 , 50 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Use face normal to rotate Object " ) ;
uiDefButF ( block , NUM , B_DIFF , " Form: " , 110 , 145 , 120 , 19 ,
& ob - > formfactor , 0.01 , 100.0 , 10 , 0 ,
" Form factor " ) ;
uiDefButBitI ( block , TOG , OB_ANISOTROPIC_FRICTION , B_REDR , " Anisotropic " ,
230 , 145 , 120 , 19 ,
& ob - > gameflag , 0.0 , 1.0 , 10 , 0 ,
" Enable anisotropic friction " ) ;
}
if ( ob - > gameflag & OB_ANISOTROPIC_FRICTION ) {
uiDefButF ( block , NUM , B_DIFF , " x friction: " , 10 , 125 , 114 , 19 ,
& ob - > anisotropicFriction [ 0 ] , 0.0 , 1.0 , 10 , 0 ,
" Relative friction coefficient in the x-direction. " ) ;
uiDefButF ( block , NUM , B_DIFF , " y friction: " , 124 , 125 , 113 , 19 ,
& ob - > anisotropicFriction [ 1 ] , 0.0 , 1.0 , 10 , 0 ,
" Relative friction coefficient in the y-direction. " ) ;
uiDefButF ( block , NUM , B_DIFF , " z friction: " , 237 , 125 , 113 , 19 ,
& ob - > anisotropicFriction [ 2 ] , 0.0 , 1.0 , 10 , 0 ,
" Relative friction coefficient in the z-direction. " ) ;
}
2004-03-22 22:02:18 +00:00
}
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
if ( ! ( ob - > gameflag & OB_GHOST ) ) {
uiBlockBeginAlign ( block ) ;
uiDefButBitI ( block , TOG , OB_BOUNDS , B_REDR , " Bounds " , 10 , 105 , 75 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
2008-09-25 16:48:25 +00:00
" Specify a collision shape bounds type " ) ;
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
if ( ob - > gameflag & OB_BOUNDS ) {
2008-09-25 16:48:25 +00:00
uiDefButS ( block , MENU , REDRAWVIEW3D , " Collision Type%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Concave TriangleMesh %x4 " ,
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
85 , 105 , 160 , 19 , & ob - > boundtype , 0 , 0 , 0 , 0 , " Selects the collision type " ) ;
uiDefButBitI ( block , TOG , OB_CHILD , B_REDR , " Compound " , 250 , 105 , 100 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Add Children " ) ;
}
uiBlockEndAlign ( block ) ;
2004-03-22 22:02:18 +00:00
}
}
}
2008-09-16 22:52:42 +00:00
static void check_actor ( void * arg1_but , void * arg2_object )
{
int * gameflag = arg2_object ;
/* force enabled ACTOR for body >= dynamic */
if ( * gameflag & OB_DYNAMIC )
* gameflag | = OB_ACTOR ;
}
static void check_body_type ( void * arg1_but , void * arg2_object )
{
Object * ob = arg2_object ;
switch ( ob - > body_type ) {
case OB_BODY_TYPE_NO_COLLISION :
ob - > gameflag & = ~ OB_COLLISION ;
break ;
case OB_BODY_TYPE_STATIC :
ob - > gameflag | = OB_COLLISION ;
ob - > gameflag & = ~ ( OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY ) ;
break ;
case OB_BODY_TYPE_DYNAMIC :
ob - > gameflag | = OB_COLLISION | OB_DYNAMIC | OB_ACTOR ;
ob - > gameflag & = ~ ( OB_RIGID_BODY | OB_SOFT_BODY ) ;
break ;
case OB_BODY_TYPE_RIGID :
ob - > gameflag | = OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY | OB_ACTOR ;
ob - > gameflag & = ~ ( OB_SOFT_BODY ) ;
break ;
default :
case OB_BODY_TYPE_SOFT :
ob - > gameflag | = OB_COLLISION | OB_DYNAMIC | OB_SOFT_BODY | OB_ACTOR ;
ob - > gameflag & = ~ ( OB_RIGID_BODY ) ;
break ;
}
}
2008-09-19 20:41:38 +00:00
static uiBlock * advanced_bullet_menu ( void * arg_ob )
{
uiBlock * block ;
Object * ob = arg_ob ;
2008-09-24 22:58:49 +00:00
short yco = 105 , xco = 0 ;
2008-09-19 20:41:38 +00:00
block = uiNewBlock ( & curarea - > uiblocks , " advanced_bullet_options " , UI_EMBOSS , UI_HELV , curarea - > win ) ;
/* use this for a fake extra empy space around the buttons */
2008-09-24 22:58:49 +00:00
uiDefBut ( block , LABEL , 0 , " " , - 5 , - 10 , 255 , 140 , NULL , 0 , 0 , 0 , 0 , " " ) ;
2008-09-19 20:41:38 +00:00
uiDefButBitI ( block , TOG , OB_ACTOR , 0 , " Sensor actor " ,
xco , yco , 118 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Objects that are detected by the Near and Radar sensor " ) ;
if ( ob - > gameflag & OB_DYNAMIC ) {
uiDefButBitI ( block , TOG , OB_COLLISION_RESPONSE , 0 , " No sleeping " ,
xco + = 120 , yco , 118 , 19 , & ob - > gameflag , 0 , 0 , 0 , 0 ,
" Disable auto (de)activation " ) ;
}
yco - = 25 ;
xco = 0 ;
if ( ob - > gameflag & OB_DYNAMIC ) {
if ( ob - > margin < 0.001f )
ob - > margin = 0.06f ;
uiDefButF ( block , NUM , 0 , " Margin " ,
xco , yco , 118 , 19 , & ob - > margin , 0.001 , 1.0 , 1 , 0 ,
" Collision margin " ) ;
} else {
uiDefButF ( block , NUM , 0 , " Margin " ,
xco , yco , 118 , 19 , & ob - > margin , 0.0 , 1.0 , 1 , 0 ,
" Collision margin " ) ;
}
2008-09-24 22:58:49 +00:00
if ( ob - > gameflag & OB_SOFT_BODY ) {
2008-09-25 16:48:25 +00:00
if ( ob - > soft )
{
uiDefButBitI ( block , TOG , OB_SB_GOAL , 0 , " Shape matching " ,
xco + = 120 , yco , 118 , 19 , & ob - > softflag , 0 , 0 , 0 , 0 ,
" Enable soft body shape matching goal " ) ;
yco - = 25 ;
xco = 0 ;
uiDefButF ( block , NUMSLI , 0 , " LinStiff " , xco , yco , 238 , 19 ,
& ob - > soft - > inspring , 0.0 , 1.0 , 1 , 0 ,
" Linear stiffness of the soft body vertex spring " ) ;
/*
yco - = 25 ;
uiDefButF ( block , NUMSLI , 0 , " AngStiff " , xco , yco , 238 , 19 ,
& ob - > angularStiffness , 0.0 , 1.0 , 1 , 0 ,
" Angular stiffness of the soft body vertex spring " ) ;
yco - = 25 ;
uiDefButF ( block , NUMSLI , 0 , " Volume " , xco , yco , 238 , 19 ,
& ob - > volumePreservation , 0.0 , 1.0 , 1 , 0 ,
" Factor of soft body volume preservation " ) ;
*/
}
2008-09-24 22:58:49 +00:00
}
2008-09-19 20:41:38 +00:00
uiBlockSetDirection ( block , UI_TOP ) ;
return block ;
}
2007-04-09 10:52:22 +00:00
void buttons_bullet ( uiBlock * block , Object * ob )
{
2008-09-16 22:52:42 +00:00
uiBut * but ;
/* determine the body_type setting based on flags */
if ( ! ( ob - > gameflag & OB_COLLISION ) )
ob - > body_type = OB_BODY_TYPE_NO_COLLISION ;
2008-09-19 20:41:38 +00:00
else if ( ! ( ob - > gameflag & OB_DYNAMIC ) )
2008-09-16 22:52:42 +00:00
ob - > body_type = OB_BODY_TYPE_STATIC ;
else if ( ! ( ob - > gameflag & ( OB_RIGID_BODY | OB_SOFT_BODY ) ) )
ob - > body_type = OB_BODY_TYPE_DYNAMIC ;
else if ( ob - > gameflag & OB_RIGID_BODY )
ob - > body_type = OB_BODY_TYPE_RIGID ;
else
ob - > body_type = OB_BODY_TYPE_SOFT ;
2008-09-25 16:48:25 +00:00
//only enable game soft body if Blender Soft Body exists
if ( ob - > soft )
{
but = uiDefButS ( block , MENU , REDRAWVIEW3D ,
" Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4 " ,
10 , 205 , 120 , 19 , & ob - > body_type , 0 , 0 , 0 , 0 , " Selects the type of physical representation " ) ;
uiButSetFunc ( but , check_body_type , but , ob ) ;
} else
{
but = uiDefButS ( block , MENU , REDRAWVIEW3D ,
" Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3 " ,
10 , 205 , 120 , 19 , & ob - > body_type , 0 , 0 , 0 , 0 , " Selects the type of physical representation " ) ;
uiButSetFunc ( but , check_body_type , but , ob ) ;
}
2008-09-16 22:52:42 +00:00
if ( ob - > gameflag & OB_COLLISION ) {
2008-09-19 20:41:38 +00:00
uiBlockSetCol ( block , TH_BUT_SETTING1 ) ;
uiDefBlockBut ( block , advanced_bullet_menu , ob ,
" Advanced Settings " ,
200 , 205 , 150 , 20 , " Display collision advanced settings " ) ;
uiBlockSetCol ( block , TH_BUT_SETTING2 ) ;
uiBlockBeginAlign ( block ) ;
uiDefButBitI ( block , TOG , OB_GHOST , 0 , " Ghost " , 10 , 182 , 60 , 19 ,
2008-09-16 22:52:42 +00:00
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Objects that don't restitute collisions (like a ghost) " ) ;
2008-09-19 20:41:38 +00:00
if ( ( ob - > gameflag & OB_DYNAMIC ) | | ( ( ob - > gameflag & OB_BOUNDS ) & & ( ob - > boundtype = = OB_BOUND_SPHERE ) ) ) {
uiDefButF ( block , NUM , REDRAWVIEW3D , " Radius: " , 70 , 182 , 140 , 19 ,
& ob - > inertia , 0.01 , 10.0 , 10 , 2 ,
" Bounding sphere radius, not used for other bounding shapes " ) ;
}
2008-09-16 22:52:42 +00:00
if ( ob - > gameflag & OB_DYNAMIC ) {
2008-09-19 20:41:38 +00:00
uiDefButF ( block , NUM , B_DIFF , " Mass: " , 210 , 182 , 140 , 19 ,
2008-09-16 22:52:42 +00:00
& ob - > mass , 0.01 , 10000.0 , 10 , 2 ,
" The mass of the Object " ) ;
2008-09-19 20:41:38 +00:00
uiDefButF ( block , NUMSLI , B_DIFF , " Damp " , 10 , 162 , 150 , 19 ,
2008-09-16 22:52:42 +00:00
& ob - > damping , 0.0 , 1.0 , 10 , 0 ,
" General movement damping " ) ;
2008-09-19 20:41:38 +00:00
uiDefButF ( block , NUMSLI , B_DIFF , " RotDamp " , 160 , 162 , 190 , 19 ,
2008-09-16 22:52:42 +00:00
& ob - > rdamping , 0.0 , 1.0 , 10 , 0 ,
" General rotation damping " ) ;
2007-04-09 10:52:22 +00:00
}
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiBlockEndAlign ( block ) ;
2007-04-09 10:52:22 +00:00
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiBlockBeginAlign ( block ) ;
2008-09-19 20:41:38 +00:00
uiDefButBitI ( block , TOG , OB_BOUNDS , B_REDR , " Bounds " , 10 , 105 , 80 , 19 ,
& ob - > gameflag , 0 , 0 , 0 , 0 ,
2008-09-25 16:48:25 +00:00
" Specify a collision bounds type " ) ;
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
if ( ob - > gameflag & OB_BOUNDS ) {
2008-09-25 16:48:25 +00:00
uiDefButS ( block , MENU , REDRAWVIEW3D , " Collision Bounds%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Triangle Mesh%x4 " ,
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
//almost ready to enable this one: uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull Polytope%x5|Static TriangleMesh %x4|Dynamic Mesh %x5|",
2008-09-19 20:41:38 +00:00
90 , 105 , 150 , 19 , & ob - > boundtype , 0 , 0 , 0 , 0 , " Selects the collision type " ) ;
uiDefButBitI ( block , TOG , OB_CHILD , B_REDR , " Compound " , 240 , 105 , 110 , 19 ,
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
& ob - > gameflag , 0 , 0 , 0 , 0 ,
" Add Children " ) ;
}
2007-04-09 10:52:22 +00:00
}
2008-09-16 22:52:42 +00:00
uiBlockEndAlign ( block ) ;
2007-04-09 10:52:22 +00:00
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
static void check_controller_state_mask ( void * arg1_but , void * arg2_mask )
{
unsigned int * cont_mask = arg2_mask ;
uiBut * but = arg1_but ;
/* a controller is always in a single state */
* cont_mask = ( 1 < < but - > retval ) ;
but - > retval = B_REDR ;
}
static int first_bit ( unsigned int mask )
{
int bit ;
for ( bit = 0 ; bit < 32 ; bit + + ) {
if ( mask & ( 1 < < bit ) )
return bit ;
}
return - 1 ;
}
static uiBlock * controller_state_mask_menu ( void * arg_cont )
{
uiBlock * block ;
uiBut * but ;
bController * cont = arg_cont ;
short yco = 12 , xco = 0 , stbit , offset ;
block = uiNewBlock ( & curarea - > uiblocks , " Controller state mask " , UI_EMBOSS , UI_HELV , curarea - > win ) ;
/* use this for a fake extra empy space around the buttons */
uiDefBut ( block , LABEL , 0 , " " , - 5 , - 5 , 200 , 34 , NULL , 0 , 0 , 0 , 0 , " " ) ;
for ( offset = 0 ; offset < 15 ; offset + = 5 ) {
uiBlockBeginAlign ( block ) ;
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
but = uiDefButBitI ( block , TOG , ( 1 < < ( stbit + offset ) ) , ( stbit + offset ) , " " , ( short ) ( xco + 12 * stbit + 13 * offset ) , yco , 12 , 12 , ( int * ) & ( cont - > state_mask ) , 0 , 0 , 0 , 0 , " " ) ;
uiButSetFunc ( but , check_controller_state_mask , but , & ( cont - > state_mask ) ) ;
}
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
but = uiDefButBitI ( block , TOG , ( 1 < < ( stbit + offset + 15 ) ) , ( stbit + offset + 15 ) , " " , ( short ) ( xco + 12 * stbit + 13 * offset ) , yco - 12 , 12 , 12 , ( int * ) & ( cont - > state_mask ) , 0 , 0 , 0 , 0 , " " ) ;
uiButSetFunc ( but , check_controller_state_mask , but , & ( cont - > state_mask ) ) ;
}
}
uiBlockEndAlign ( block ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
return block ;
}
static void do_object_state_menu ( void * arg , int event )
{
Object * ob = arg ;
switch ( event ) {
case 0 :
ob - > state = 0x3FFFFFFF ;
break ;
case 1 :
ob - > state = ob - > init_state ;
if ( ! ob - > state )
ob - > state = 1 ;
break ;
case 2 :
ob - > init_state = ob - > state ;
break ;
}
allqueue ( REDRAWBUTSLOGIC , 0 ) ;
}
static uiBlock * object_state_mask_menu ( void * arg_obj )
{
uiBlock * block ;
short xco = 0 ;
block = uiNewBlock ( & curarea - > uiblocks , " obstatemenu " , UI_EMBOSSP , UI_HELV , curarea - > win ) ;
uiBlockSetButmFunc ( block , do_object_state_menu , arg_obj ) ;
uiDefBut ( block , BUTM , 1 , " Set all bits " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Recall init state " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , ( short ) ( xco - = 6 ) , 160 , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Store init state " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
return block ;
}
static int is_sensor_linked ( uiBlock * block , bSensor * sens )
{
bController * cont ;
int i , count ;
for ( count = 0 , i = 0 ; i < sens - > totlinks ; i + + ) {
cont = sens - > links [ i ] ;
if ( uiFindInlink ( block , cont ) ! = NULL )
return 1 ;
}
return 0 ;
}
2002-10-12 11:37:38 +00:00
/* never used, see CVS 1.134 for the code */
/* static FreeCamera *new_freecamera(void) */
/* never used, see CVS 1.120 for the code */
/* static uiBlock *freecamera_menu(void) */
2004-03-22 22:02:18 +00:00
Another huge commit!!!
First, check on the new files, which are listed below.
The new butspace.h is a local include, only to be used for the buttons
drawn in the buttonswindow.
- editbuts, animbuts, gamebuts, displaybuts, paintbuts, work now
- i quite completely reorganized it, it's now nicely telling you what
context it is in
- sorting error in panel align fixed (tabs were flipping)
- align works correctly automatic when you click around in Blender
- editsca.c renamed to buttons_logic.h
- button names are truncated from the right for allmost all buttons
(except text buttons and number buttons)
- while dragging panels, you cannot move them outside window anymore
And of course fixed loads of little bugs I encountered while testing
it all. This is a version I really need good test & feedback for.
Next step: restoring material/lamp/texture/world
2003-10-10 17:29:01 +00:00
void logic_buts ( void )
2002-10-12 11:37:38 +00:00
{
ID * * idar ;
Object * ob ;
bProperty * prop ;
bSensor * sens ;
bController * cont ;
bActuator * act ;
uiBlock * block ;
uiBut * but ;
2004-03-22 22:02:18 +00:00
World * wrld ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
int a , iact , stbit , offset ;
2002-10-12 11:37:38 +00:00
short xco , yco , count , width , ycoo ;
char * pupstr , name [ 32 ] ;
2008-09-04 12:11:47 +00:00
/* pin is a bool used for actuator and sensor drawing with states
* pin so changing states dosnt hide the logic brick */
char pin ;
2002-10-12 11:37:38 +00:00
2004-03-22 22:02:18 +00:00
wrld = G . scene - > world ;
2002-10-12 11:37:38 +00:00
ob = OBACT ;
if ( ob = = 0 ) return ;
2008-03-06 23:45:17 +00:00
uiSetButLock ( object_is_libdata ( ob ) , ERROR_LIBDATA_MESSAGE ) ;
2002-10-12 11:37:38 +00:00
sprintf ( name , " buttonswin %d " , curarea - > win ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
block = uiNewBlock ( & curarea - > uiblocks , name , UI_EMBOSS , UI_HELV , curarea - > win ) ;
2002-10-12 11:37:38 +00:00
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetCol ( block , TH_BUT_SETTING2 ) ;
2004-04-22 13:08:49 +00:00
if ( wrld ) {
2007-04-09 10:52:22 +00:00
switch ( wrld - > physicsEngine ) {
case WOPHY_ENJI :
buttons_enji ( block , ob ) ;
break ;
case WOPHY_BULLET :
buttons_bullet ( block , ob ) ;
break ;
default :
2004-04-22 13:08:49 +00:00
buttons_ketsji ( block , ob ) ;
2007-04-09 10:52:22 +00:00
break ;
}
2004-04-22 13:08:49 +00:00
}
else buttons_ketsji ( block , ob ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetCol ( block , TH_AUTO ) ;
2007-04-09 10:52:22 +00:00
uiBlockBeginAlign ( block ) ;
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefBut ( block , BUT , B_ADD_PROP , " Add Property " , 10 , 70 , 340 , 24 ,
2002-10-12 11:37:38 +00:00
NULL , 0.0 , 100.0 , 100 , 0 ,
" " ) ;
pupstr = " Types %t|Bool %x0|Int %x1|Float %x2|String %x3|Timer %x5 " ;
a = 0 ;
prop = ob - > prop . first ;
while ( prop ) {
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
but = uiDefBut ( block , BUT , 1 , " Del " , 10 , ( short ) ( 50 - 20 * a ) , 40 , 20 , NULL , 0.0 , 0.0 , 1 , ( float ) a , " " ) ;
2002-10-12 11:37:38 +00:00
uiButSetFunc ( but , del_property , prop , NULL ) ;
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefButS ( block , MENU , B_CHANGE_PROP , pupstr , 50 , ( short ) ( 50 - 20 * a ) , 60 , 20 , & prop - > type , 0 , 0 , 0 , 0 , " " ) ;
2008-09-15 09:08:36 +00:00
but = uiDefBut ( block , TEX , 1 , " Name: " , 110 , ( short ) ( 50 - 20 * a ) , 110 , 20 , prop - > name , 0 , 31 , 0 , 0 , " Available as GameObject attributes in the game engines python api " ) ;
2002-10-12 11:37:38 +00:00
uiButSetFunc ( but , make_unique_prop_names_cb , prop - > name , ( void * ) 1 ) ;
if ( prop - > type = = PROP_BOOL ) {
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefButBitI ( block , TOG , 1 , B_REDR , " True " , 220 , ( short ) ( 50 - 20 * a ) , 55 , 20 , & prop - > data , 0 , 0 , 0 , 0 , " " ) ;
uiDefButBitI ( block , TOGN , 1 , B_REDR , " False " , 270 , ( short ) ( 50 - 20 * a ) , 55 , 20 , & prop - > data , 0 , 0 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
}
else if ( prop - > type = = PROP_INT )
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefButI ( block , NUM , B_REDR , " " , 220 , ( short ) ( 50 - 20 * a ) , 110 , 20 , & prop - > data , - 10000 , 10000 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
else if ( prop - > type = = PROP_FLOAT )
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefButF ( block , NUM , B_REDR , " " , 220 , ( short ) ( 50 - 20 * a ) , 110 , 20 , ( float * ) & prop - > data , - 10000 , 10000 , 100 , 3 , " " ) ;
2002-10-12 11:37:38 +00:00
else if ( prop - > type = = PROP_STRING )
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefBut ( block , TEX , B_REDR , " " , 220 , ( short ) ( 50 - 20 * a ) , 110 , 20 , prop - > poin , 0 , 127 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
else if ( prop - > type = = PROP_TIME )
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefButF ( block , NUM , B_REDR , " " , 220 , ( short ) ( 50 - 20 * a ) , 110 , 20 , ( float * ) & prop - > data , - 10000 , 10000 , 100 , 3 , " " ) ;
2002-10-12 11:37:38 +00:00
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
2008-09-14 19:34:06 +00:00
uiDefButBitS ( block , TOG , PROP_DEBUG , B_REDR , " D " , 330 , ( short ) ( 50 - 20 * a ) , 20 , 20 , & prop - > flag , 0 , 0 , 0 , 0 , " Print Debug info " ) ;
2002-10-12 11:37:38 +00:00
a + + ;
prop = prop - > next ;
2007-01-17 12:40:40 +00:00
2002-10-12 11:37:38 +00:00
}
2007-04-09 10:52:22 +00:00
uiBlockEndAlign ( block ) ;
2002-10-12 11:37:38 +00:00
uiClearButLock ( ) ;
idar = get_selected_and_linked_obs ( & count , G . buts - > scaflag ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
/* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that
we can determine which is actually linked / visible */
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
act = ob - > actuators . first ;
while ( act ) {
act - > flag & = ~ ( ACT_LINKED | ACT_VISIBLE ) ;
act = act - > next ;
}
/* same for sensors */
sens = ob - > sensors . first ;
while ( sens ) {
sens - > flag & = ~ ( SENS_VISIBLE ) ;
sens = sens - > next ;
}
}
/* start with the controller because we need to know which one is visible */
2002-10-12 11:37:38 +00:00
/* ******************************* */
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
xco = 695 ; yco = 170 ; width = 275 ;
2002-10-12 11:37:38 +00:00
2003-05-06 12:51:04 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSP ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefBlockBut ( block , controller_menu , NULL , " Controllers " , xco - 10 , yco + 35 , 100 , 19 , " " ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
2007-01-17 12:40:40 +00:00
uiBlockBeginAlign ( block ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefButBitS ( block , TOG , BUTS_CONT_SEL , B_REDR , " Sel " , xco + 110 , yco + 35 , ( width - 100 ) / 3 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show all selected Objects " ) ;
uiDefButBitS ( block , TOG , BUTS_CONT_ACT , B_REDR , " Act " , xco + 110 + ( width - 100 ) / 3 , yco + 35 , ( width - 100 ) / 3 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show active Object " ) ;
uiDefButBitS ( block , TOG , BUTS_CONT_LINK , B_REDR , " Link " , xco + 110 + 2 * ( width - 100 ) / 3 , yco + 35 , ( width - 100 ) / 3 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show linked Objects to Sensor/Actuator " ) ;
2007-01-17 12:40:40 +00:00
uiBlockEndAlign ( block ) ;
2002-10-12 11:37:38 +00:00
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
ob = OBACT ;
2002-10-12 11:37:38 +00:00
for ( a = 0 ; a < count ; a + + ) {
2008-07-06 14:11:30 +00:00
unsigned int controller_state_mask = 0 ; /* store a bitmask for states that are used */
2002-10-12 11:37:38 +00:00
ob = ( Object * ) idar [ a ] ;
uiClearButLock ( ) ;
2008-03-06 23:45:17 +00:00
uiSetButLock ( object_is_libdata ( ob ) , ERROR_LIBDATA_MESSAGE ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ( ob - > scavisflag & OB_VIS_CONT ) = = 0 ) continue ;
2002-10-12 11:37:38 +00:00
/* presume it is only objects for now */
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
2007-01-17 12:40:40 +00:00
uiBlockBeginAlign ( block ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ob - > controllers . first ) uiSetCurFont ( block , UI_HELVB ) ;
uiDefButBitS ( block , TOG , OB_SHOWCONT , B_REDR , ob - > id . name + 2 , ( short ) ( xco - 10 ) , yco , ( short ) ( width - 30 ) , 19 , & ob - > scaflag , 0 , 0 , 0 , 0 , " Active Object name " ) ;
if ( ob - > controllers . first ) uiSetCurFont ( block , UI_HELV ) ;
uiDefButBitS ( block , TOG , OB_ADDCONT , B_ADD_CONT , " Add " , ( short ) ( xco + width - 40 ) , yco , 50 , 19 , & ob - > scaflag , 0 , 0 , 0 , 0 , " Add a new Controller " ) ;
2007-01-17 12:40:40 +00:00
uiBlockEndAlign ( block ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
yco - = 17 ;
2002-10-12 11:37:38 +00:00
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
/* mark all actuators linked to these controllers */
/* note that some of these actuators could be from objects that are not in the display list.
It ' s ok because those actuators will not be displayed here */
cont = ob - > controllers . first ;
while ( cont ) {
for ( iact = 0 ; iact < cont - > totlinks ; iact + + ) {
act = cont - > links [ iact ] ;
2008-08-16 00:06:51 +00:00
if ( act )
act - > flag | = ACT_LINKED ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
}
2008-07-06 14:11:30 +00:00
controller_state_mask | = cont - > state_mask ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
cont = cont - > next ;
}
2002-10-12 11:37:38 +00:00
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ob - > scaflag & OB_SHOWCONT ) {
2002-10-12 11:37:38 +00:00
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
/* first show the state */
uiBlockSetEmboss ( block , UI_EMBOSSP ) ;
2008-09-25 16:19:07 +00:00
uiDefBlockBut ( block , object_state_mask_menu , ob , " State " , ( short ) ( xco - 10 ) , ( short ) ( yco - 10 ) , 36 , 19 , " Object state menu: store and retrieve initial state " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
if ( ! ob - > state )
ob - > state = 1 ;
for ( offset = 0 ; offset < 15 ; offset + = 5 ) {
uiBlockBeginAlign ( block ) ;
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
2008-09-25 16:19:07 +00:00
but = uiDefButBitI ( block , controller_state_mask & ( 1 < < ( stbit + offset ) ) ? BUT_TOGDUAL : TOG , 1 < < ( stbit + offset ) , stbit + offset , " " , ( short ) ( xco + 31 + 12 * stbit + 13 * offset ) , yco , 12 , 12 , ( int * ) & ( ob - > state ) , 0 , 0 , 0 , 0 , get_state_name ( ob , ( short ) ( stbit + offset ) ) ) ;
2008-09-15 21:10:51 +00:00
uiButSetFunc ( but , check_state_mask , but , & ( ob - > state ) ) ;
2002-10-12 11:37:38 +00:00
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
2008-09-25 16:19:07 +00:00
but = uiDefButBitI ( block , controller_state_mask & ( 1 < < ( stbit + offset + 15 ) ) ? BUT_TOGDUAL : TOG , 1 < < ( stbit + offset + 15 ) , stbit + offset + 15 , " " , ( short ) ( xco + 31 + 12 * stbit + 13 * offset ) , yco - 12 , 12 , 12 , ( int * ) & ( ob - > state ) , 0 , 0 , 0 , 0 , get_state_name ( ob , ( short ) ( stbit + offset + 15 ) ) ) ;
2008-09-15 21:10:51 +00:00
uiButSetFunc ( but , check_state_mask , but , & ( ob - > state ) ) ;
2002-10-12 11:37:38 +00:00
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
}
uiBlockBeginAlign ( block ) ;
2008-09-25 16:19:07 +00:00
uiDefButBitS ( block , TOG , OB_SETSTBIT , B_SET_STATE_BIT , " All " , ( short ) ( xco + 226 ) , yco - 10 , 22 , 19 , & ob - > scaflag , 0 , 0 , 0 , 0 , " Set all state bits " ) ;
uiDefButBitS ( block , TOG , OB_INITSTBIT , B_INIT_STATE_BIT , " Ini " , ( short ) ( xco + 248 ) , yco - 10 , 22 , 19 , & ob - > scaflag , 0 , 0 , 0 , 0 , " Set the initial state " ) ;
uiDefButBitS ( block , TOG , OB_DEBUGSTATE , 0 , " D " , ( short ) ( xco + 270 ) , yco - 10 , 15 , 19 , & ob - > scaflag , 0 , 0 , 0 , 0 , " Print state debug info " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiBlockEndAlign ( block ) ;
2002-10-12 11:37:38 +00:00
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
yco - = 35 ;
/* display only the controllers that match the current state */
offset = 0 ;
for ( stbit = 0 ; stbit < 32 ; stbit + + ) {
if ( ! ( ob - > state & ( 1 < < stbit ) ) )
continue ;
/* add a separation between controllers of different states */
if ( offset ) {
offset = 0 ;
yco - = 6 ;
}
cont = ob - > controllers . first ;
while ( cont ) {
if ( cont - > state_mask & ( 1 < < stbit ) ) {
/* this controller is visible, mark all its actuator */
for ( iact = 0 ; iact < cont - > totlinks ; iact + + ) {
act = cont - > links [ iact ] ;
2008-08-16 00:06:51 +00:00
if ( act )
act - > flag | = ACT_VISIBLE ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
}
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
uiDefIconButBitS ( block , TOG , CONT_DEL , B_DEL_CONT , ICON_X , xco , yco , 22 , 19 , & cont - > flag , 0 , 0 , 0 , 0 , " Delete Controller " ) ;
uiDefIconButBitS ( block , ICONTOG , CONT_SHOW , B_REDR , ICON_RIGHTARROW , ( short ) ( xco + width - 22 ) , yco , 22 , 19 , & cont - > flag , 0 , 0 , 0 , 0 , " Controller settings " ) ;
uiBlockSetEmboss ( block , UI_EMBOSSP ) ;
sprintf ( name , " %d " , first_bit ( cont - > state_mask ) + 1 ) ;
2008-09-15 09:08:36 +00:00
uiDefBlockBut ( block , controller_state_mask_menu , cont , name , ( short ) ( xco + width - 44 ) , yco , 22 , 19 , " Set controller state index (from 1 to 30) " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
if ( cont - > flag & CONT_SHOW ) {
cont - > otype = cont - > type ;
2008-09-11 01:51:45 +00:00
uiDefButS ( block , MENU , B_CHANGE_CONT , controller_pup ( ) , ( short ) ( xco + 22 ) , yco , 70 , 19 , & cont - > type , 0 , 0 , 0 , 0 , " Controller type " ) ;
but = uiDefBut ( block , TEX , 1 , " " , ( short ) ( xco + 92 ) , yco , ( short ) ( width - 136 ) , 19 , cont - > name , 0 , 31 , 0 , 0 , " Controller name " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , make_unique_prop_names_cb , cont - > name , ( void * ) 0 ) ;
ycoo = yco ;
yco = draw_controllerbuttons ( cont , block , xco , yco , width ) ;
if ( yco - 6 < ycoo ) ycoo = ( yco + ycoo - 20 ) / 2 ;
}
else {
cpack ( 0x999999 ) ;
glRecti ( xco + 22 , yco , xco + width - 22 , yco + 19 ) ;
2008-09-11 01:51:45 +00:00
but = uiDefBut ( block , LABEL , 0 , controller_name ( cont - > type ) , ( short ) ( xco + 22 ) , yco , 70 , 19 , cont , 0 , 0 , 0 , 0 , " Controller type " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , sca_move_controller , cont , NULL ) ;
2008-09-11 01:51:45 +00:00
but = uiDefBut ( block , LABEL , 0 , cont - > name , ( short ) ( xco + 92 ) , yco , ( short ) ( width - 136 ) , 19 , cont , 0 , 0 , 0 , 0 , " Controller name " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , sca_move_controller , cont , NULL ) ;
ycoo = yco ;
}
but = uiDefIconBut ( block , LINK , 0 , ICON_LINK , ( short ) ( xco + width ) , ycoo , 19 , 19 , NULL , 0 , 0 , 0 , 0 , " " ) ;
uiSetButLink ( but , NULL , ( void * * * ) & ( cont - > links ) , & cont - > totlinks , LINK_CONTROLLER , LINK_ACTUATOR ) ;
uiDefIconBut ( block , INLINK , 0 , ICON_INLINK , ( short ) ( xco - 19 ) , ycoo , 19 , 19 , cont , LINK_CONTROLLER , 0 , 0 , 0 , " " ) ;
/* offset is >0 if at least one controller was displayed */
offset + + ;
yco - = 20 ;
}
cont = cont - > next ;
}
2002-10-12 11:37:38 +00:00
}
yco - = 6 ;
}
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
2002-10-12 11:37:38 +00:00
/* ******************************* */
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
xco = 375 ; yco = 170 ; width = 250 ;
2002-10-12 11:37:38 +00:00
2003-05-06 12:51:04 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSP ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefBlockBut ( block , sensor_menu , NULL , " Sensors " , xco - 10 , yco + 35 , 70 , 19 , " " ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
2007-01-17 12:40:40 +00:00
uiBlockBeginAlign ( block ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefButBitS ( block , TOG , BUTS_SENS_SEL , B_REDR , " Sel " , xco + 80 , yco + 35 , ( width - 70 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show all selected Objects " ) ;
uiDefButBitS ( block , TOG , BUTS_SENS_ACT , B_REDR , " Act " , xco + 80 + ( width - 70 ) / 4 , yco + 35 , ( width - 70 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show active Object " ) ;
uiDefButBitS ( block , TOG , BUTS_SENS_LINK , B_REDR , " Link " , xco + 80 + 2 * ( width - 70 ) / 4 , yco + 35 , ( width - 70 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show linked Objects to Controller " ) ;
2008-07-07 21:04:30 +00:00
uiDefButBitS ( block , TOG , BUTS_SENS_STATE , B_REDR , " State " , xco + 80 + 3 * ( width - 70 ) / 4 , yco + 35 , ( width - 70 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show only sensors connected to active states " ) ;
2007-01-17 12:40:40 +00:00
uiBlockEndAlign ( block ) ;
2002-10-12 11:37:38 +00:00
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
uiClearButLock ( ) ;
2008-03-06 23:45:17 +00:00
uiSetButLock ( object_is_libdata ( ob ) , ERROR_LIBDATA_MESSAGE ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ( ob - > scavisflag & OB_VIS_SENS ) = = 0 ) continue ;
2002-10-12 11:37:38 +00:00
/* presume it is only objects for now */
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
2007-01-17 12:40:40 +00:00
uiBlockBeginAlign ( block ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ob - > sensors . first ) uiSetCurFont ( block , UI_HELVB ) ;
uiDefButBitS ( block , TOG , OB_SHOWSENS , B_REDR , ob - > id . name + 2 , ( short ) ( xco - 10 ) , yco , ( short ) ( width - 30 ) , 19 , & ob - > scaflag , 0 , 31 , 0 , 0 , " Object name, click to show/hide sensors " ) ;
if ( ob - > sensors . first ) uiSetCurFont ( block , UI_HELV ) ;
uiDefButBitS ( block , TOG , OB_ADDSENS , B_ADD_SENS , " Add " , ( short ) ( xco + width - 40 ) , yco , 50 , 19 , & ob - > scaflag , 0 , 0 , 0 , 0 , " Add a new Sensor " ) ;
2007-01-17 12:40:40 +00:00
uiBlockEndAlign ( block ) ;
2002-10-12 11:37:38 +00:00
yco - = 20 ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ob - > scaflag & OB_SHOWSENS ) {
sens = ob - > sensors . first ;
while ( sens ) {
if ( ! ( G . buts - > scaflag & BUTS_SENS_STATE ) | |
2008-09-04 12:11:47 +00:00
( sens - > totlinks = = 0 ) | | /* always display sensor without links so that is can be edited */
( sens - > flag & SENS_PIN & & G . buts - > scaflag & BUTS_SENS_STATE ) | | /* states can hide some sensors, pinned sensors ignore the visible state */
( is_sensor_linked ( block , sens ) )
) {
/* should we draw the pin? - for now always draw when there is a state */
pin = ( G . buts - > scaflag & BUTS_SENS_STATE & & ( sens - > flag & SENS_SHOW | | sens - > flag & SENS_PIN ) ) ? 1 : 0 ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
sens - > flag | = SENS_VISIBLE ;
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
uiDefIconButBitS ( block , TOG , SENS_DEL , B_DEL_SENS , ICON_X , xco , yco , 22 , 19 , & sens - > flag , 0 , 0 , 0 , 0 , " Delete Sensor " ) ;
2008-09-04 12:11:47 +00:00
if ( pin )
2008-09-09 10:58:58 +00:00
uiDefIconButBitS ( block , ICONTOG , SENS_PIN , B_REDR , ICON_PIN_DEHLT , ( short ) ( xco + width - 44 ) , yco , 22 , 19 , & sens - > flag , 0 , 0 , 0 , 0 , " Display when not linked to a visible states controller " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefIconButBitS ( block , ICONTOG , SENS_SHOW , B_REDR , ICON_RIGHTARROW , ( short ) ( xco + width - 22 ) , yco , 22 , 19 , & sens - > flag , 0 , 0 , 0 , 0 , " Sensor settings " ) ;
2002-10-12 11:37:38 +00:00
ycoo = yco ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( sens - > flag & SENS_SHOW )
{
2008-08-18 02:29:25 +00:00
uiDefButS ( block , MENU , B_CHANGE_SENS , sensor_pup ( ) , ( short ) ( xco + 22 ) , yco , 80 , 19 , & sens - > type , 0 , 0 , 0 , 0 , " Sensor type " ) ;
2008-09-04 12:11:47 +00:00
but = uiDefBut ( block , TEX , 1 , " " , ( short ) ( xco + 102 ) , yco , ( short ) ( width - ( pin ? 146 : 124 ) ) , 19 , sens - > name , 0 , 31 , 0 , 0 , " Sensor name " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , make_unique_prop_names_cb , sens - > name , ( void * ) 0 ) ;
sens - > otype = sens - > type ;
yco = draw_sensorbuttons ( sens , block , xco , yco , width , ob - > id . name ) ;
if ( yco - 6 < ycoo ) ycoo = ( yco + ycoo - 20 ) / 2 ;
}
else {
set_col_sensor ( sens - > type , 1 ) ;
glRecti ( xco + 22 , yco , xco + width - 22 , yco + 19 ) ;
2008-08-18 02:29:25 +00:00
but = uiDefBut ( block , LABEL , 0 , sensor_name ( sens - > type ) , ( short ) ( xco + 22 ) , yco , 80 , 19 , sens , 0 , 0 , 0 , 0 , " " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , sca_move_sensor , sens , NULL ) ;
2008-09-04 12:17:01 +00:00
but = uiDefBut ( block , LABEL , 0 , sens - > name , ( short ) ( xco + 102 ) , yco , ( short ) ( width - ( pin ? 146 : 124 ) ) , 19 , sens , 0 , 31 , 0 , 0 , " " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , sca_move_sensor , sens , NULL ) ;
}
but = uiDefIconBut ( block , LINK , 0 , ICON_LINK , ( short ) ( xco + width ) , ycoo , 19 , 19 , NULL , 0 , 0 , 0 , 0 , " " ) ;
uiSetButLink ( but , NULL , ( void * * * ) & ( sens - > links ) , & sens - > totlinks , LINK_SENSOR , LINK_CONTROLLER ) ;
yco - = 20 ;
2002-10-12 11:37:38 +00:00
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
sens = sens - > next ;
2002-10-12 11:37:38 +00:00
}
yco - = 6 ;
}
}
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
2002-10-12 11:37:38 +00:00
/* ******************************* */
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
xco = 1040 ; yco = 170 ; width = 280 ;
2002-10-12 11:37:38 +00:00
2003-05-06 12:51:04 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSP ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefBlockBut ( block , actuator_menu , NULL , " Actuators " , xco - 10 , yco + 35 , 90 , 19 , " " ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
2007-01-17 12:40:40 +00:00
uiBlockBeginAlign ( block ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefButBitS ( block , TOG , BUTS_ACT_SEL , B_REDR , " Sel " , xco + 110 , yco + 35 , ( width - 100 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show all selected Objects " ) ;
uiDefButBitS ( block , TOG , BUTS_ACT_ACT , B_REDR , " Act " , xco + 110 + ( width - 100 ) / 4 , yco + 35 , ( width - 100 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show active Object " ) ;
uiDefButBitS ( block , TOG , BUTS_ACT_LINK , B_REDR , " Link " , xco + 110 + 2 * ( width - 100 ) / 4 , yco + 35 , ( width - 100 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show linked Objects to Controller " ) ;
2008-07-07 21:04:30 +00:00
uiDefButBitS ( block , TOG , BUTS_ACT_STATE , B_REDR , " State " , xco + 110 + 3 * ( width - 100 ) / 4 , yco + 35 , ( width - 100 ) / 4 , 19 , & G . buts - > scaflag , 0 , 0 , 0 , 0 , " Show only actuators connected to active states " ) ;
2007-01-17 12:40:40 +00:00
uiBlockEndAlign ( block ) ;
2002-10-12 11:37:38 +00:00
for ( a = 0 ; a < count ; a + + ) {
ob = ( Object * ) idar [ a ] ;
uiClearButLock ( ) ;
2008-03-06 23:45:17 +00:00
uiSetButLock ( object_is_libdata ( ob ) , ERROR_LIBDATA_MESSAGE ) ;
2002-10-12 11:37:38 +00:00
if ( ( ob - > scavisflag & OB_VIS_ACT ) = = 0 ) continue ;
/* presume it is only objects for now */
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
2007-01-17 12:40:40 +00:00
uiBlockBeginAlign ( block ) ;
2002-10-12 11:37:38 +00:00
if ( ob - > actuators . first ) uiSetCurFont ( block , UI_HELVB ) ;
2005-08-03 18:48:22 +00:00
uiDefButBitS ( block , TOG , OB_SHOWACT , B_REDR , ob - > id . name + 2 , ( short ) ( xco - 10 ) , yco , ( short ) ( width - 30 ) , 19 , & ob - > scaflag , 0 , 31 , 0 , 0 , " Object name, click to show/hide actuators " ) ;
2002-10-12 11:37:38 +00:00
if ( ob - > actuators . first ) uiSetCurFont ( block , UI_HELV ) ;
2005-08-03 18:48:22 +00:00
uiDefButBitS ( block , TOG , OB_ADDACT , B_ADD_ACT , " Add " , ( short ) ( xco + width - 40 ) , yco , 50 , 19 , & ob - > scaflag , 0 , 0 , 0 , 0 , " Add a new Actuator " ) ;
2007-01-17 12:40:40 +00:00
uiBlockEndAlign ( block ) ;
2002-10-12 11:37:38 +00:00
yco - = 20 ;
if ( ob - > scaflag & OB_SHOWACT ) {
act = ob - > actuators . first ;
while ( act ) {
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( ! ( G . buts - > scaflag & BUTS_ACT_STATE ) | |
! ( act - > flag & ACT_LINKED ) | | /* always display actuators without links so that is can be edited */
2008-09-04 12:11:47 +00:00
( act - > flag & ACT_VISIBLE ) | | /* this actuator has visible connection, display it */
( act - > flag & ACT_PIN & & G . buts - > scaflag & BUTS_ACT_STATE ) ) {
pin = ( G . buts - > scaflag & BUTS_ACT_STATE & & ( act - > flag & SENS_SHOW | | act - > flag & SENS_PIN ) ) ? 1 : 0 ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
act - > flag | = ACT_VISIBLE ; /* mark the actuator as visible to help implementing the up/down action */
uiBlockSetEmboss ( block , UI_EMBOSSM ) ;
uiDefIconButBitS ( block , TOG , ACT_DEL , B_DEL_ACT , ICON_X , xco , yco , 22 , 19 , & act - > flag , 0 , 0 , 0 , 0 , " Delete Actuator " ) ;
2008-09-04 12:11:47 +00:00
if ( pin )
2008-09-09 10:58:58 +00:00
uiDefIconButBitS ( block , ICONTOG , ACT_PIN , B_REDR , ICON_PIN_DEHLT , ( short ) ( xco + width - 44 ) , yco , 22 , 19 , & act - > flag , 0 , 0 , 0 , 0 , " Display when not linked to a visible states controller " ) ;
2008-09-04 12:11:47 +00:00
uiDefIconButBitS ( block , ICONTOG , ACT_SHOW , B_REDR , ICON_RIGHTARROW , ( short ) ( xco + width - 22 ) , yco , 22 , 19 , & act - > flag , 0 , 0 , 0 , 0 , " Display the actuator " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
if ( act - > flag & ACT_SHOW ) {
act - > otype = act - > type ;
2008-08-18 02:29:25 +00:00
uiDefButS ( block , MENU , B_CHANGE_ACT , actuator_pup ( ob ) , ( short ) ( xco + 22 ) , yco , 90 , 19 , & act - > type , 0 , 0 , 0 , 0 , " Actuator type " ) ;
2008-09-04 12:11:47 +00:00
but = uiDefBut ( block , TEX , 1 , " " , ( short ) ( xco + 112 ) , yco , ( short ) ( width - ( pin ? 156 : 134 ) ) , 19 , act - > name , 0 , 31 , 0 , 0 , " Actuator name " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , make_unique_prop_names_cb , act - > name , ( void * ) 0 ) ;
ycoo = yco ;
yco = draw_actuatorbuttons ( ob , act , block , xco , yco , width ) ;
if ( yco - 6 < ycoo ) ycoo = ( yco + ycoo - 20 ) / 2 ;
}
else {
set_col_actuator ( act - > type , 1 ) ;
glRecti ( ( short ) ( xco + 22 ) , yco , ( short ) ( xco + width - 22 ) , ( short ) ( yco + 19 ) ) ;
2008-08-18 02:29:25 +00:00
but = uiDefBut ( block , LABEL , 0 , actuator_name ( act - > type ) , ( short ) ( xco + 22 ) , yco , 90 , 19 , act , 0 , 0 , 0 , 0 , " Actuator type " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , sca_move_actuator , act , NULL ) ;
2008-09-04 12:17:01 +00:00
but = uiDefBut ( block , LABEL , 0 , act - > name , ( short ) ( xco + 112 ) , yco , ( short ) ( width - ( pin ? 156 : 134 ) ) , 19 , act , 0 , 0 , 0 , 0 , " Actuator name " ) ;
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiButSetFunc ( but , sca_move_actuator , act , NULL ) ;
ycoo = yco ;
}
2002-10-12 11:37:38 +00:00
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
uiDefIconBut ( block , INLINK , 0 , ICON_INLINK , ( short ) ( xco - 19 ) , ycoo , 19 , 19 , act , LINK_ACTUATOR , 0 , 0 , 0 , " " ) ;
2002-10-12 11:37:38 +00:00
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
yco - = 20 ;
2002-10-12 11:37:38 +00:00
}
act = act - > next ;
}
yco - = 6 ;
}
}
uiComposeLinks ( block ) ;
uiDrawBlock ( block ) ;
if ( idar ) MEM_freeN ( idar ) ;
}
2007-10-22 20:24:26 +00:00