2011-02-23 10:52:22 +00:00
/*
2008-11-29 02:01:39 +00:00
* $ Id $
*
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
*
* 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
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
2010-02-12 13:34:04 +00:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2008-11-29 02:01:39 +00:00
*
* Contributor ( s ) : Blender Foundation ( 2008 ) .
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
2011-02-27 20:20:01 +00:00
/** \file blender/makesrna/intern/rna_sensor.c
* \ ingroup RNA
*/
2008-11-29 02:01:39 +00:00
# include <stdlib.h>
# include "RNA_define.h"
2010-05-05 00:12:31 +00:00
# include "RNA_enum_types.h"
2010-11-26 03:58:31 +00:00
# include "RNA_access.h"
2008-11-29 02:01:39 +00:00
# include "rna_internal.h"
2010-05-11 06:56:59 +00:00
# include "DNA_constraint_types.h"
2010-05-06 19:12:08 +00:00
# include "DNA_object_types.h"
2008-11-29 02:01:39 +00:00
# include "DNA_sensor_types.h"
2010-05-07 08:10:20 +00:00
# include "WM_types.h"
2010-05-11 06:56:59 +00:00
/* Always keep in alphabetical order */
2010-04-29 07:01:48 +00:00
EnumPropertyItem sensor_type_items [ ] = {
2010-05-04 00:06:13 +00:00
{ SENS_ACTUATOR , " ACTUATOR " , 0 , " Actuator " , " " } ,
2010-04-29 07:01:48 +00:00
{ SENS_ALWAYS , " ALWAYS " , 0 , " Always " , " " } ,
2010-05-04 00:06:13 +00:00
{ SENS_ARMATURE , " ARMATURE " , 0 , " Armature " , " " } ,
{ SENS_COLLISION , " COLLISION " , 0 , " Collision " , " " } ,
{ SENS_DELAY , " DELAY " , 0 , " Delay " , " " } ,
{ SENS_JOYSTICK , " JOYSTICK " , 0 , " Joystick " , " " } ,
2010-04-29 07:01:48 +00:00
{ SENS_KEYBOARD , " KEYBOARD " , 0 , " Keyboard " , " " } ,
2010-05-04 00:06:13 +00:00
{ SENS_MESSAGE , " MESSAGE " , 0 , " Message " , " " } ,
2010-04-29 07:01:48 +00:00
{ SENS_MOUSE , " MOUSE " , 0 , " Mouse " , " " } ,
2010-05-04 00:06:13 +00:00
{ SENS_NEAR , " NEAR " , 0 , " Near " , " " } ,
{ SENS_PROPERTY , " PROPERTY " , 0 , " Property " , " " } ,
2010-04-29 07:01:48 +00:00
{ SENS_RADAR , " RADAR " , 0 , " Radar " , " " } ,
{ SENS_RANDOM , " RANDOM " , 0 , " Random " , " " } ,
{ SENS_RAY , " RAY " , 0 , " Ray " , " " } ,
2010-05-04 00:06:13 +00:00
{ SENS_TOUCH , " TOUCH " , 0 , " Touch " , " " } ,
2010-04-29 07:01:48 +00:00
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-11-29 02:01:39 +00:00
# ifdef RNA_RUNTIME
2008-11-29 19:08:46 +00:00
2010-04-29 07:01:48 +00:00
# include "BKE_sca.h"
2008-12-02 23:45:11 +00:00
static StructRNA * rna_Sensor_refine ( struct PointerRNA * ptr )
2008-11-29 16:07:49 +00:00
{
2008-11-29 19:08:46 +00:00
bSensor * sensor = ( bSensor * ) ptr - > data ;
switch ( sensor - > type ) {
2008-11-29 22:16:23 +00:00
case SENS_ALWAYS :
2008-12-02 23:45:11 +00:00
return & RNA_AlwaysSensor ;
2008-11-29 22:16:23 +00:00
case SENS_TOUCH :
return & RNA_TouchSensor ;
case SENS_NEAR :
return & RNA_NearSensor ;
case SENS_KEYBOARD :
return & RNA_KeyboardSensor ;
case SENS_PROPERTY :
return & RNA_PropertySensor ;
2009-09-24 21:22:24 +00:00
case SENS_ARMATURE :
return & RNA_ArmatureSensor ;
2008-11-29 16:07:49 +00:00
case SENS_MOUSE :
return & RNA_MouseSensor ;
2008-11-29 22:16:23 +00:00
case SENS_COLLISION :
return & RNA_CollisionSensor ;
case SENS_RADAR :
return & RNA_RadarSensor ;
case SENS_RANDOM :
return & RNA_RandomSensor ;
case SENS_RAY :
return & RNA_RaySensor ;
case SENS_MESSAGE :
return & RNA_MessageSensor ;
case SENS_JOYSTICK :
return & RNA_JoystickSensor ;
case SENS_ACTUATOR :
return & RNA_ActuatorSensor ;
case SENS_DELAY :
return & RNA_DelaySensor ;
2008-11-30 15:55:14 +00:00
default :
2008-12-02 23:45:11 +00:00
return & RNA_Sensor ;
2008-11-29 16:07:49 +00:00
}
}
2008-11-29 19:08:46 +00:00
2010-05-06 19:12:08 +00:00
static void rna_Sensor_type_set ( struct PointerRNA * ptr , int value )
2010-04-29 07:01:48 +00:00
{
bSensor * sens = ( bSensor * ) ptr - > data ;
2010-05-06 19:12:08 +00:00
if ( value ! = sens - > type )
{
sens - > type = value ;
init_sensor ( sens ) ;
}
}
2010-05-11 06:56:59 +00:00
/* Always keep in alphabetical order */
2010-05-07 02:01:50 +00:00
EnumPropertyItem * rna_Sensor_type_itemf ( bContext * C , PointerRNA * ptr , int * free )
2010-05-06 19:12:08 +00:00
{
EnumPropertyItem * item = NULL ;
2010-05-07 02:01:50 +00:00
Object * ob = NULL ;
2010-05-06 19:12:08 +00:00
int totitem = 0 ;
2010-11-26 03:58:31 +00:00
if ( ptr - > type = = & RNA_Sensor | | RNA_struct_is_a ( ptr - > type , & RNA_Sensor ) ) {
2010-05-07 02:01:50 +00:00
ob = ( Object * ) ptr - > id . data ;
} else {
/* can't use ob from ptr->id.data because that enum is also used by operators */
ob = CTX_data_active_object ( C ) ;
}
2010-05-06 19:12:08 +00:00
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_ACTUATOR ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_ALWAYS ) ;
2010-05-07 02:01:50 +00:00
if ( ob ! = NULL ) {
if ( ob - > type = = OB_ARMATURE ) {
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_ARMATURE ) ;
}
2010-05-06 19:12:08 +00:00
}
2010-05-19 09:40:45 +00:00
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_COLLISION ) ;
2010-05-06 19:12:08 +00:00
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_DELAY ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_JOYSTICK ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_KEYBOARD ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_MESSAGE ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_MOUSE ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_NEAR ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_PROPERTY ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_RADAR ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_RANDOM ) ;
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_RAY ) ;
2010-05-19 09:40:45 +00:00
RNA_enum_items_add_value ( & item , & totitem , sensor_type_items , SENS_TOUCH ) ;
2010-04-29 07:01:48 +00:00
2010-05-06 19:12:08 +00:00
RNA_enum_item_end ( & item , & totitem ) ;
* free = 1 ;
return item ;
2010-04-29 07:01:48 +00:00
}
2010-05-07 08:10:20 +00:00
static void rna_Sensor_keyboard_key_set ( struct PointerRNA * ptr , int value )
{
bSensor * sens = ( bSensor * ) ptr - > data ;
2010-05-27 07:37:09 +00:00
bKeyboardSensor * ks = ( bKeyboardSensor * ) sens - > data ;
2010-05-07 08:10:20 +00:00
2010-05-24 10:38:05 +00:00
if ( ISKEYBOARD ( value ) )
2010-05-07 08:10:20 +00:00
ks - > key = value ;
2010-09-15 04:42:01 +00:00
else
ks - > key = 0 ;
2010-05-07 08:10:20 +00:00
}
static void rna_Sensor_keyboard_modifier_set ( struct PointerRNA * ptr , int value )
{
bSensor * sens = ( bSensor * ) ptr - > data ;
2010-05-27 07:37:09 +00:00
bKeyboardSensor * ks = ( bKeyboardSensor * ) sens - > data ;
2010-05-07 08:10:20 +00:00
2010-05-24 10:38:05 +00:00
if ( ISKEYBOARD ( value ) )
2010-05-07 08:10:20 +00:00
ks - > qual = value ;
2010-09-15 04:42:01 +00:00
else
ks - > qual = 0 ;
2010-05-07 08:10:20 +00:00
}
static void rna_Sensor_keyboard_modifier2_set ( struct PointerRNA * ptr , int value )
{
bSensor * sens = ( bSensor * ) ptr - > data ;
2010-05-27 07:37:09 +00:00
bKeyboardSensor * ks = ( bKeyboardSensor * ) sens - > data ;
2010-05-07 08:10:20 +00:00
2010-05-24 10:38:05 +00:00
if ( ISKEYBOARD ( value ) )
2010-05-07 08:10:20 +00:00
ks - > qual2 = value ;
2010-09-15 04:42:01 +00:00
else
ks - > qual2 = 0 ;
2010-05-07 08:10:20 +00:00
}
2010-05-11 06:56:59 +00:00
static void rna_Sensor_tap_set ( struct PointerRNA * ptr , int value )
{
bSensor * sens = ( bSensor * ) ptr - > data ;
sens - > tap = value ;
if ( sens - > tap = = 1 )
sens - > level = 0 ;
}
static void rna_Sensor_level_set ( struct PointerRNA * ptr , int value )
{
bSensor * sens = ( bSensor * ) ptr - > data ;
sens - > level = value ;
if ( sens - > level = = 1 )
sens - > tap = 0 ;
}
static void rna_Sensor_Armature_update ( Main * bmain , Scene * scene , PointerRNA * ptr )
{
bSensor * sens = ( bSensor * ) ptr - > data ;
bArmatureSensor * as = sens - > data ;
Object * ob = ( Object * ) ptr - > id . data ;
char * posechannel = as - > posechannel ;
char * constraint = as - > constraint ;
/* check that bone exist in the active object */
if ( ob - > type = = OB_ARMATURE & & ob - > pose ) {
bPoseChannel * pchan ;
bPose * pose = ob - > pose ;
for ( pchan = pose - > chanbase . first ; pchan ; pchan = pchan - > next ) {
if ( ! strcmp ( pchan - > name , posechannel ) ) {
/* found it, now look for constraint channel */
bConstraint * con ;
for ( con = pchan - > constraints . first ; con ; con = con - > next ) {
if ( ! strcmp ( con - > name , constraint ) ) {
/* found it, all ok */
return ;
}
}
/* didn't find constraint, make empty */
constraint [ 0 ] = 0 ;
return ;
}
}
}
/* didn't find any */
posechannel [ 0 ] = 0 ;
constraint [ 0 ] = 0 ;
}
2010-05-27 07:37:09 +00:00
/* note: the following set functions exists only to avoid id refcounting */
static void rna_Sensor_touch_material_set ( PointerRNA * ptr , PointerRNA value )
{
bSensor * sens = ( bSensor * ) ptr - > data ;
bTouchSensor * ts = ( bTouchSensor * ) sens - > data ;
ts - > ma = value . data ;
}
2008-11-29 02:01:39 +00:00
# else
2008-11-29 22:16:23 +00:00
2009-09-14 16:52:06 +00:00
static void rna_def_sensor ( BlenderRNA * brna )
2008-11-29 02:01:39 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-11-29 16:07:49 +00:00
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " Sensor " , NULL ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Sensor " , " Game engine logic brick to detect events " ) ;
2008-11-29 16:07:49 +00:00
RNA_def_struct_sdna ( srna , " bSensor " ) ;
2009-01-01 15:52:51 +00:00
RNA_def_struct_refine_func ( srna , " rna_Sensor_refine " ) ;
2008-11-29 16:07:49 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " name " , PROP_STRING , PROP_NONE ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Name " , " Sensor name " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_name_property ( srna , prop ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 16:07:49 +00:00
prop = RNA_def_property ( srna , " type " , PROP_ENUM , PROP_NONE ) ;
2010-04-29 07:01:48 +00:00
RNA_def_property_clear_flag ( prop , PROP_ANIMATABLE ) ;
2008-12-02 23:45:11 +00:00
RNA_def_property_enum_items ( prop , sensor_type_items ) ;
2010-05-06 19:12:08 +00:00
RNA_def_property_enum_funcs ( prop , NULL , " rna_Sensor_type_set " , " rna_Sensor_type_itemf " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_property_ui_text ( prop , " Type " , " " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-05-06 19:12:08 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " pin " , PROP_BOOLEAN , PROP_NONE ) ;
2010-06-21 07:51:40 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " flag " , SENS_PIN ) ;
RNA_def_property_ui_text ( prop , " Pinned " , " Display when not linked to a visible states controller " ) ;
RNA_def_property_ui_icon ( prop , ICON_UNPINNED , 1 ) ;
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " show_expanded " , PROP_BOOLEAN , PROP_NONE ) ;
2010-04-29 07:01:48 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " flag " , SENS_SHOW ) ;
RNA_def_property_ui_text ( prop , " Expanded " , " Set sensor expanded in the user interface " ) ;
RNA_def_property_ui_icon ( prop , ICON_TRIA_RIGHT , 1 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 16:07:49 +00:00
prop = RNA_def_property ( srna , " invert " , PROP_BOOLEAN , PROP_NONE ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Invert Output " , " Invert the level(output) of this sensor " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 16:07:49 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_level " , PROP_BOOLEAN , PROP_NONE ) ;
RNA_def_property_boolean_sdna ( prop , NULL , " level " , 1 ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Level " , " Level detector, trigger controllers of new states(only applicable upon logic state transition) " ) ;
2010-05-11 06:56:59 +00:00
RNA_def_property_boolean_funcs ( prop , NULL , " rna_Sensor_level_set " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 16:07:49 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_pulse_true_level " , PROP_BOOLEAN , PROP_NONE ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " pulse " , SENS_PULSE_REPEAT ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Pulse True Level " , " Activate TRUE level triggering (pulse mode) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_pulse_false_level " , PROP_BOOLEAN , PROP_NONE ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " pulse " , SENS_NEG_PULSE_MODE ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Pulse False Level " , " Activate FALSE level triggering (pulse mode) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2010-05-04 00:06:13 +00:00
prop = RNA_def_property ( srna , " frequency " , PROP_INT , PROP_NONE ) ;
2009-01-10 22:57:33 +00:00
RNA_def_property_int_sdna ( prop , NULL , " freq " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Frequency " , " Delay between repeated pulses(in logic tics, 0=no delay) " ) ;
2008-11-29 16:07:49 +00:00
RNA_def_property_range ( prop , 0 , 10000 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-05-04 00:06:13 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_tap " , PROP_BOOLEAN , PROP_NONE ) ;
2010-05-04 00:06:13 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " tap " , 1 ) ;
2010-05-11 06:56:59 +00:00
RNA_def_property_boolean_funcs ( prop , NULL , " rna_Sensor_tap_set " ) ;
2010-05-04 00:06:13 +00:00
RNA_def_property_ui_text ( prop , " Tap " , " Trigger controllers only for an instant, even while the sensor remains true " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-07-10 21:15:10 +00:00
RNA_api_sensor ( srna ) ;
2008-12-02 23:45:11 +00:00
}
2008-11-29 16:07:49 +00:00
2009-09-14 16:52:06 +00:00
static void rna_def_always_sensor ( BlenderRNA * brna )
2008-12-02 23:45:11 +00:00
{
2008-12-19 04:06:24 +00:00
StructRNA * srna ;
srna = RNA_def_struct ( brna , " AlwaysSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Always Sensor " , " Sensor to generate continuous pulses " ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_near_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " NearSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Near Sensor " , " Sensor to detect nearby objects " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bNearSensor " , " data " ) ;
2008-11-29 22:16:23 +00:00
prop = RNA_def_property ( srna , " property " , PROP_STRING , PROP_NONE ) ;
RNA_def_property_string_sdna ( prop , NULL , " name " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Property " , " Only look for objects with this property (blank = all objects) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
2008-12-26 02:02:06 +00:00
prop = RNA_def_property ( srna , " distance " , PROP_FLOAT , PROP_NONE ) ;
RNA_def_property_float_sdna ( prop , NULL , " dist " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Distance " , " Trigger distance " ) ;
2008-12-26 02:02:06 +00:00
RNA_def_property_range ( prop , 0.0f , 10000.0f ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
2008-12-26 02:02:06 +00:00
prop = RNA_def_property ( srna , " reset_distance " , PROP_FLOAT , PROP_NONE ) ;
RNA_def_property_float_sdna ( prop , NULL , " resetdist " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Reset Distance " , " The distance where the sensor forgets the actor " ) ;
2008-12-26 02:02:06 +00:00
RNA_def_property_range ( prop , 0.0f , 10000.0f ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_mouse_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
static EnumPropertyItem mouse_event_items [ ] = {
2009-06-16 00:52:21 +00:00
{ BL_SENS_MOUSE_LEFT_BUTTON , " LEFTCLICK " , 0 , " Left Button " , " " } ,
{ BL_SENS_MOUSE_MIDDLE_BUTTON , " MIDDLECLICK " , 0 , " Middle Button " , " " } ,
{ BL_SENS_MOUSE_RIGHT_BUTTON , " RIGHTCLICK " , 0 , " Right Button " , " " } ,
{ BL_SENS_MOUSE_WHEEL_UP , " WHEELUP " , 0 , " Wheel Up " , " " } ,
{ BL_SENS_MOUSE_WHEEL_DOWN , " WHEELDOWN " , 0 , " Wheel Down " , " " } ,
{ BL_SENS_MOUSE_MOVEMENT , " MOVEMENT " , 0 , " Movement " , " " } ,
{ BL_SENS_MOUSE_MOUSEOVER , " MOUSEOVER " , 0 , " Mouse Over " , " " } ,
{ BL_SENS_MOUSE_MOUSEOVER_ANY , " MOUSEOVERANY " , 0 , " Mouse Over Any " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-11-29 16:07:49 +00:00
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " MouseSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Mouse Sensor " , " Sensor to detect mouse events " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bMouseSensor " , " data " ) ;
2008-11-29 16:07:49 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " mouse_event " , PROP_ENUM , PROP_NONE ) ;
2008-12-03 20:17:12 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " type " ) ;
2008-11-29 16:07:49 +00:00
RNA_def_property_enum_items ( prop , mouse_event_items ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Mouse Event " , " Specify the type of event this mouse sensor should trigger on " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_touch_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " TouchSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Touch Sensor " , " Sensor to detect objects colliding with the current object " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bTouchSensor " , " data " ) ;
2008-11-29 22:16:23 +00:00
prop = RNA_def_property ( srna , " material " , PROP_POINTER , PROP_NONE ) ;
2010-02-05 23:50:33 +00:00
RNA_def_property_struct_type ( prop , " Material " ) ;
2008-11-29 22:16:23 +00:00
RNA_def_property_pointer_sdna ( prop , NULL , " ma " ) ;
2009-05-28 23:23:47 +00:00
RNA_def_property_flag ( prop , PROP_EDITABLE ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Material " , " Only look for objects with this material (blank = all objects) " ) ;
2010-05-27 07:37:09 +00:00
/* note: custom set function is ONLY to avoid rna setting a user for this. */
2010-08-03 05:14:59 +00:00
RNA_def_property_pointer_funcs ( prop , NULL , " rna_Sensor_touch_material_set " , NULL , NULL ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_keyboard_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " KeyboardSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Keyboard Sensor " , " Sensor to detect keyboard events " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bKeyboardSensor " , " data " ) ;
2008-11-30 09:00:32 +00:00
2010-05-05 00:12:31 +00:00
prop = RNA_def_property ( srna , " key " , PROP_ENUM , PROP_NONE ) ;
RNA_def_property_enum_sdna ( prop , NULL , " key " ) ;
RNA_def_property_enum_items ( prop , event_type_items ) ;
2010-05-07 08:10:20 +00:00
RNA_def_property_enum_funcs ( prop , NULL , " rna_Sensor_keyboard_key_set " , NULL ) ;
2010-05-05 00:12:31 +00:00
RNA_def_property_ui_text ( prop , " Key " , " " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-05-05 00:12:31 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " modifier_key_1 " , PROP_ENUM , PROP_NONE ) ;
2010-05-05 00:12:31 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " qual " ) ;
RNA_def_property_enum_items ( prop , event_type_items ) ;
2010-05-07 08:10:20 +00:00
RNA_def_property_enum_funcs ( prop , NULL , " rna_Sensor_keyboard_modifier_set " , NULL ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Modifier Key " , " Modifier key code " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-05-05 00:12:31 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " modifier_key_2 " , PROP_ENUM , PROP_NONE ) ;
2010-05-05 00:12:31 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " qual2 " ) ;
RNA_def_property_enum_items ( prop , event_type_items ) ;
2010-05-07 08:10:20 +00:00
RNA_def_property_enum_funcs ( prop , NULL , " rna_Sensor_keyboard_modifier2_set " , NULL ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Second Modifier Key " , " Modifier key code " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " target " , PROP_STRING , PROP_NONE ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_string_sdna ( prop , NULL , " targetName " ) ;
2010-11-14 19:46:14 +00:00
RNA_def_property_ui_text ( prop , " Target " , " Property that receive the keystrokes in case a string is logged " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " log " , PROP_STRING , PROP_NONE ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_string_sdna ( prop , NULL , " toggleName " ) ;
2010-11-14 19:46:14 +00:00
RNA_def_property_ui_text ( prop , " Log Toggle " , " Property that indicates whether to log keystrokes as a string " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_all_keys " , PROP_BOOLEAN , PROP_NONE ) ;
2008-12-02 23:45:11 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " type " , 1 ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " All Keys " , " Trigger this sensor on any keystroke " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_property_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-02 23:45:11 +00:00
static EnumPropertyItem prop_type_items [ ] = {
2009-06-16 00:52:21 +00:00
{ SENS_PROP_EQUAL , " PROPEQUAL " , 0 , " Equal " , " " } ,
{ SENS_PROP_NEQUAL , " PROPNEQUAL " , 0 , " Not Equal " , " " } ,
{ SENS_PROP_INTERVAL , " PROPINTERVAL " , 0 , " Interval " , " " } ,
{ SENS_PROP_CHANGED , " PROPCHANGED " , 0 , " Changed " , " " } ,
/* {SENS_PROP_EXPRESSION, "PROPEXPRESSION", 0, "Expression", ""}, NOT_USED_IN_UI */
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-11-29 22:16:23 +00:00
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " PropertySensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Property Sensor " , " Sensor to detect values and changes in values of properties " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bPropertySensor " , " data " ) ;
2008-11-30 09:00:32 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " evaluation_type " , PROP_ENUM , PROP_NONE ) ;
2008-12-03 20:17:12 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " type " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_property_enum_items ( prop , prop_type_items ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Evaluation Type " , " Type of property evaluation " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " property " , PROP_STRING , PROP_NONE ) ;
RNA_def_property_string_sdna ( prop , NULL , " name " ) ;
RNA_def_property_ui_text ( prop , " Property " , " " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " value " , PROP_STRING , PROP_NONE ) ;
RNA_def_property_string_sdna ( prop , NULL , " value " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Value " , " Check for this value in types in Equal or Not Equal types " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " value_min " , PROP_STRING , PROP_NONE ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_string_sdna ( prop , NULL , " value " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Minimum Value " , " Specify minimum value in Interval type " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " value_max " , PROP_STRING , PROP_NONE ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_string_sdna ( prop , NULL , " maxvalue " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Maximum Value " , " Specify maximum value in Interval type " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-24 21:22:24 +00:00
static void rna_def_armature_sensor ( BlenderRNA * brna )
{
StructRNA * srna ;
PropertyRNA * prop ;
static EnumPropertyItem prop_type_items [ ] = {
{ SENS_ARM_STATE_CHANGED , " STATECHG " , 0 , " State Changed " , " " } ,
{ SENS_ARM_LIN_ERROR_BELOW , " LINERRORBELOW " , 0 , " Lin error below " , " " } ,
{ SENS_ARM_LIN_ERROR_ABOVE , " LINERRORABOVE " , 0 , " Lin error above " , " " } ,
{ SENS_ARM_ROT_ERROR_BELOW , " ROTERRORBELOW " , 0 , " Rot error below " , " " } ,
2010-11-01 21:45:38 +00:00
{ SENS_ARM_ROT_ERROR_ABOVE , " ROTERRORABOVE " , 0 , " Rot error above " , " " } ,
2009-09-24 21:22:24 +00:00
{ 0 , NULL , 0 , NULL , NULL } } ;
srna = RNA_def_struct ( brna , " ArmatureSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Armature Sensor " , " Sensor to detect values and changes in values of IK solver " ) ;
2009-09-24 21:22:24 +00:00
RNA_def_struct_sdna_from ( srna , " bArmatureSensor " , " data " ) ;
2010-05-06 19:12:08 +00:00
prop = RNA_def_property ( srna , " test_type " , PROP_ENUM , PROP_NONE ) ;
2009-09-24 21:22:24 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " type " ) ;
RNA_def_property_enum_items ( prop , prop_type_items ) ;
2011-01-21 08:59:08 +00:00
RNA_def_property_ui_text ( prop , " Test " , " Type of value and test " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2009-09-24 21:22:24 +00:00
2010-05-11 06:56:59 +00:00
prop = RNA_def_property ( srna , " bone " , PROP_STRING , PROP_NONE ) ;
2009-09-24 21:22:24 +00:00
RNA_def_property_string_sdna ( prop , NULL , " posechannel " ) ;
2011-02-07 18:24:15 +00:00
RNA_def_property_ui_text ( prop , " Bone Name " , " Identify the bone to check value from " ) ;
2010-05-11 06:56:59 +00:00
RNA_def_property_update ( prop , NC_LOGIC , " rna_Sensor_Armature_update " ) ;
2009-09-24 21:22:24 +00:00
2010-05-11 06:56:59 +00:00
prop = RNA_def_property ( srna , " constraint " , PROP_STRING , PROP_NONE ) ;
2009-09-24 21:22:24 +00:00
RNA_def_property_string_sdna ( prop , NULL , " constraint " ) ;
2011-02-07 18:24:15 +00:00
RNA_def_property_ui_text ( prop , " Constraint Name " , " Identify the bone constraint to check value from " ) ;
2010-05-11 06:56:59 +00:00
RNA_def_property_update ( prop , NC_LOGIC , " rna_Sensor_Armature_update " ) ;
2009-09-24 21:22:24 +00:00
prop = RNA_def_property ( srna , " value " , PROP_FLOAT , PROP_NONE ) ;
RNA_def_property_float_sdna ( prop , NULL , " value " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Compare Value " , " Specify value to be used in comparison " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2009-09-24 21:22:24 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_actuator_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " ActuatorSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Actuator Sensor " , " Sensor to detect state modifications of actuators " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bActuatorSensor " , " data " ) ;
2008-11-30 09:00:32 +00:00
2010-02-05 23:50:33 +00:00
// XXX if eventually have Logics using RNA 100%, we could use the actuator datablock isntead of its name
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " actuator " , PROP_STRING , PROP_NONE ) ;
RNA_def_property_string_sdna ( prop , NULL , " name " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Actuator " , " Actuator name, actuator active state modifications will be detected " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_delay_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " DelaySensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Delay Sensor " , " Sensor to send delayed events " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bDelaySensor " , " data " ) ;
2008-11-30 09:00:32 +00:00
prop = RNA_def_property ( srna , " delay " , PROP_INT , PROP_NONE ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Delay " , " Delay in number of logic tics before the positive trigger (default 60 per second) " ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_range ( prop , 0 , 5000 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
prop = RNA_def_property ( srna , " duration " , PROP_INT , PROP_NONE ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Duration " , " If >0, delay in number of logic tics before the negative trigger following the positive trigger " ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_range ( prop , 0 , 5000 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 09:00:32 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_repeat " , PROP_BOOLEAN , PROP_NONE ) ;
2008-11-30 09:00:32 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " flag " , SENS_DELAY_REPEAT ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Repeat " , " Toggle repeat option. If selected, the sensor restarts after Delay+Dur logic tics " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_collision_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " CollisionSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Collision Sensor " , " Sensor to detect objects colliding with the current object, with more settings than the Touch sensor " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bCollisionSensor " , " data " ) ;
2008-11-30 12:00:03 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_pulse " , PROP_BOOLEAN , PROP_NONE ) ;
2010-05-07 07:31:39 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " mode " , SENS_COLLISION_PULSE ) ;
RNA_def_property_ui_text ( prop , " Pulse " , " Changes to the set of colliding objects generates pulse " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-05-04 00:06:13 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_material " , PROP_BOOLEAN , PROP_NONE ) ;
2010-05-07 07:31:39 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " mode " , SENS_COLLISION_MATERIAL ) ;
RNA_def_property_ui_text ( prop , " M/P " , " Toggle collision on material or property " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-05-04 00:06:13 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " property " , PROP_STRING , PROP_NONE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_string_sdna ( prop , NULL , " name " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Property " , " Only look for Objects with this property (blank = all objects) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2010-05-04 00:06:13 +00:00
//XXX to make a setFunction to create a lookup with all materials in Blend File (not only this object mat.)
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " material " , PROP_STRING , PROP_NONE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_string_sdna ( prop , NULL , " materialName " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Material " , " Only look for Objects with this material (blank = all objects) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2010-05-04 21:31:46 +00:00
/*//XXX either use a datablock look up to store the string name (material)
// or to do a doversion and use a material pointer.
2010-02-05 23:50:33 +00:00
prop = RNA_def_property ( srna , " material " , PROP_POINTER , PROP_NONE ) ;
RNA_def_property_struct_type ( prop , " Material " ) ;
RNA_def_property_flag ( prop , PROP_EDITABLE ) ;
RNA_def_property_pointer_sdna ( prop , NULL , " ma " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Material " , " Only look for Objects with this material (blank = all objects) " ) ;
2010-02-05 23:50:33 +00:00
*/
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_radar_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-11-30 12:00:03 +00:00
static EnumPropertyItem axis_items [ ] = {
2010-11-26 03:37:08 +00:00
{ SENS_RADAR_X_AXIS , " XAXIS " , 0 , " +X axis " , " " } ,
{ SENS_RADAR_Y_AXIS , " YAXIS " , 0 , " +Y axis " , " " } ,
{ SENS_RADAR_Z_AXIS , " ZAXIS " , 0 , " +Z axis " , " " } ,
{ SENS_RADAR_NEG_X_AXIS , " NEGXAXIS " , 0 , " -X axis " , " " } ,
{ SENS_RADAR_NEG_Y_AXIS , " NEGYAXIS " , 0 , " -Y axis " , " " } ,
{ SENS_RADAR_NEG_Z_AXIS , " NEGZAXIS " , 0 , " -Z axis " , " " } ,
2009-06-16 00:52:21 +00:00
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-11-30 12:00:03 +00:00
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " RadarSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Radar Sensor " , " Sensor to detect objects in a cone shaped radar emanating from the current object " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bRadarSensor " , " data " ) ;
prop = RNA_def_property ( srna , " property " , PROP_STRING , PROP_NONE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_string_sdna ( prop , NULL , " name " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Property " , " Only look for Objects with this property (blank = all objects) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " axis " , PROP_ENUM , PROP_NONE ) ;
RNA_def_property_enum_items ( prop , axis_items ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Axis " , " Specify along which axis the radar cone is cast " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2011-01-21 06:12:56 +00:00
prop = RNA_def_property ( srna , " angle " , PROP_FLOAT , PROP_ANGLE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_range ( prop , 0.0 , 179.9 ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Angle " , " Opening angle of the radar cone " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " distance " , PROP_FLOAT , PROP_NONE ) ;
RNA_def_property_float_sdna ( prop , NULL , " range " ) ;
RNA_def_property_range ( prop , 0.0 , 10000.0 ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Distance " , " Depth of the radar cone " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_random_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " RandomSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Random Sensor " , " Sensor to send random events " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bRandomSensor " , " data " ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " seed " , PROP_INT , PROP_NONE ) ;
RNA_def_property_range ( prop , 0 , 1000 ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Seed " , " Initial seed of the generator. (Choose 0 for not random) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_ray_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-11-30 12:00:03 +00:00
static EnumPropertyItem axis_items [ ] = {
2009-06-16 00:52:21 +00:00
{ SENS_RAY_X_AXIS , " XAXIS " , 0 , " +X axis " , " " } ,
{ SENS_RAY_Y_AXIS , " YAXIS " , 0 , " +Y axis " , " " } ,
{ SENS_RAY_Z_AXIS , " ZAXIS " , 0 , " +Z axis " , " " } ,
{ SENS_RAY_NEG_X_AXIS , " NEGXAXIS " , 0 , " -X axis " , " " } ,
{ SENS_RAY_NEG_Y_AXIS , " NEGYAXIS " , 0 , " -Y axis " , " " } ,
{ SENS_RAY_NEG_Z_AXIS , " NEGZAXIS " , 0 , " -Z axis " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2010-05-10 00:12:36 +00:00
static const EnumPropertyItem prop_ray_type_items [ ] = {
2010-05-11 06:56:59 +00:00
{ SENS_COLLISION_PROPERTY , " PROPERTY " , ICON_LOGIC , " Property " , " Use a material for ray intersections " } ,
2010-05-10 00:12:36 +00:00
{ SENS_COLLISION_MATERIAL , " MATERIAL " , ICON_MATERIAL_DATA , " Material " , " Use a property for ray intersections " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-11-29 22:16:23 +00:00
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " RaySensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Ray Sensor " , " Sensor to detect intersections with a ray emanating from the current object " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bRaySensor " , " data " ) ;
2010-05-10 00:12:36 +00:00
prop = RNA_def_property ( srna , " ray_type " , PROP_ENUM , PROP_NONE ) ;
RNA_def_property_enum_bitflag_sdna ( prop , NULL , " mode " ) ;
RNA_def_property_enum_items ( prop , prop_ray_type_items ) ;
RNA_def_property_ui_text ( prop , " Ray Type " , " Toggle collision on material or property " ) ;
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " property " , PROP_STRING , PROP_NONE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_string_sdna ( prop , NULL , " propname " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Property " , " Only look for Objects with this property (blank = all objects) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2008-12-02 23:45:11 +00:00
prop = RNA_def_property ( srna , " material " , PROP_STRING , PROP_NONE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_string_sdna ( prop , NULL , " matname " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Material " , " Only look for Objects with this material (blank = all objects) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2010-05-04 21:31:46 +00:00
/* //XXX either use a datablock look up to store the string name (material)
// or to do a doversion and use a material pointer.
2010-02-05 23:50:33 +00:00
prop = RNA_def_property ( srna , " material " , PROP_POINTER , PROP_NONE ) ;
RNA_def_property_struct_type ( prop , " Material " ) ;
RNA_def_property_flag ( prop , PROP_EDITABLE ) ;
RNA_def_property_pointer_sdna ( prop , NULL , " ma " ) ;
2011-01-21 06:12:56 +00:00
RNA_def_property_ui_text ( prop , " Material " , " Only look for Objects with this material (blank = all objects) " ) ;
2010-02-05 23:50:33 +00:00
*/
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_x_ray " , PROP_BOOLEAN , PROP_NONE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " mode " , SENS_RAY_XRAY ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " X-Ray Mode " , " Toggle X-Ray option (see through objects that don't have the property) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " range " , PROP_FLOAT , PROP_NONE ) ;
2008-12-02 23:45:11 +00:00
RNA_def_property_range ( prop , 0.01 , 10000.0 ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Range " , " Sense objects no farther than this distance " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " axis " , PROP_ENUM , PROP_NONE ) ;
2008-12-03 20:17:12 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " axisflag " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_enum_items ( prop , axis_items ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Axis " , " Specify along which axis the ray is cast " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_message_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " MessageSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Message Sensor " , " Sensor to detect incoming messages " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bMessageSensor " , " data " ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " subject " , PROP_STRING , PROP_NONE ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Subject " , " Optional subject filter: only accept messages with this subject, or empty for all " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
2009-09-14 16:52:06 +00:00
static void rna_def_joystick_sensor ( BlenderRNA * brna )
2008-11-29 22:16:23 +00:00
{
StructRNA * srna ;
PropertyRNA * prop ;
2008-11-30 12:00:03 +00:00
static EnumPropertyItem event_type_items [ ] = {
2009-06-16 00:52:21 +00:00
{ SENS_JOY_BUTTON , " BUTTON " , 0 , " Button " , " " } ,
{ SENS_JOY_AXIS , " AXIS " , 0 , " Axis " , " " } ,
{ SENS_JOY_HAT , " HAT " , 0 , " Hat " , " " } ,
2010-05-04 07:34:46 +00:00
{ SENS_JOY_AXIS_SINGLE , " AXIS_SINGLE " , 0 , " Single Axis " , " " } ,
2009-06-16 00:52:21 +00:00
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-11-30 12:00:03 +00:00
static EnumPropertyItem axis_direction_items [ ] = {
2009-06-16 00:52:21 +00:00
{ SENS_JOY_X_AXIS , " RIGHTAXIS " , 0 , " Right Axis " , " " } ,
{ SENS_JOY_Y_AXIS , " UPAXIS " , 0 , " Up Axis " , " " } ,
{ SENS_JOY_NEG_X_AXIS , " LEFTAXIS " , 0 , " Left Axis " , " " } ,
{ SENS_JOY_NEG_Y_AXIS , " DOWNAXIS " , 0 , " Down Axis " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-11-30 12:00:03 +00:00
2010-05-04 07:34:46 +00:00
static EnumPropertyItem hat_direction_items [ ] = {
{ SENS_JOY_HAT_UP , " UP " , 0 , " Up " , " " } ,
{ SENS_JOY_HAT_DOWN , " DOWN " , 0 , " Down " , " " } ,
{ SENS_JOY_HAT_LEFT , " LEFT " , 0 , " Left " , " " } ,
{ SENS_JOY_HAT_RIGHT , " RIGHT " , 0 , " Right " , " " } ,
{ SENS_JOY_HAT_UP_RIGHT , " UPRIGHT " , 0 , " Up/Right " , " " } ,
{ SENS_JOY_HAT_DOWN_LEFT , " DOWNLEFT " , 0 , " Down/Left " , " " } ,
{ SENS_JOY_HAT_UP_LEFT , " UPLEFT " , 0 , " Up/Left " , " " } ,
{ SENS_JOY_HAT_DOWN_RIGHT , " DOWNRIGHT " , 0 , " Down/Right " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2008-12-19 04:06:24 +00:00
srna = RNA_def_struct ( brna , " JoystickSensor " , " Sensor " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_struct_ui_text ( srna , " Joystick Sensor " , " Sensor to detect joystick events " ) ;
2008-12-02 23:45:11 +00:00
RNA_def_struct_sdna_from ( srna , " bJoystickSensor " , " data " ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " joystick_index " , PROP_INT , PROP_NONE ) ;
RNA_def_property_int_sdna ( prop , NULL , " joyindex " ) ;
2010-05-04 07:34:46 +00:00
RNA_def_property_ui_text ( prop , " Index " , " Specify which joystick to use " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_range ( prop , 0 , SENS_JOY_MAXINDEX - 1 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " event_type " , PROP_ENUM , PROP_NONE ) ;
2008-12-03 20:17:12 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " type " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_enum_items ( prop , event_type_items ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Event Type " , " The type of event this joystick sensor is triggered on " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2010-08-17 16:27:10 +00:00
prop = RNA_def_property ( srna , " use_all_events " , PROP_BOOLEAN , PROP_NONE ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_boolean_sdna ( prop , NULL , " flag " , SENS_JOY_ANY_EVENT ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " All Events " , " Triggered by all events on this joysticks current type (axis/button/hat) " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
/* Button */
prop = RNA_def_property ( srna , " button_number " , PROP_INT , PROP_NONE ) ;
RNA_def_property_int_sdna ( prop , NULL , " button " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Button Number " , " Specify which button to use " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_range ( prop , 0 , 18 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
/* Axis */
prop = RNA_def_property ( srna , " axis_number " , PROP_INT , PROP_NONE ) ;
RNA_def_property_int_sdna ( prop , NULL , " axis " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Axis Number " , " Specify which axis pair to use, 1 is usually the main direction input " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_range ( prop , 1 , 2 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " axis_threshold " , PROP_INT , PROP_NONE ) ;
RNA_def_property_int_sdna ( prop , NULL , " precision " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Axis Threshold " , " Specify the precision of the axis " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_range ( prop , 0 , 32768 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
prop = RNA_def_property ( srna , " axis_direction " , PROP_ENUM , PROP_NONE ) ;
2008-12-03 20:17:12 +00:00
RNA_def_property_enum_sdna ( prop , NULL , " axisf " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_enum_items ( prop , axis_direction_items ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Axis Direction " , " The direction of the axis " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2010-05-04 07:34:46 +00:00
/* Single Axis */
prop = RNA_def_property ( srna , " single_axis_number " , PROP_INT , PROP_NONE ) ;
RNA_def_property_int_sdna ( prop , NULL , " axis_single " ) ;
RNA_def_property_ui_text ( prop , " Axis Number " , " Specify a single axis (verticle/horizontal/other) to detect " ) ;
RNA_def_property_range ( prop , 1 , 16 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2010-05-04 07:34:46 +00:00
2008-11-30 12:00:03 +00:00
/* Hat */
prop = RNA_def_property ( srna , " hat_number " , PROP_INT , PROP_NONE ) ;
RNA_def_property_int_sdna ( prop , NULL , " hat " ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Hat Number " , " Specify which hat to use " ) ;
2008-11-30 12:00:03 +00:00
RNA_def_property_range ( prop , 1 , 2 ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-30 12:00:03 +00:00
2010-05-04 07:34:46 +00:00
prop = RNA_def_property ( srna , " hat_direction " , PROP_ENUM , PROP_NONE ) ;
RNA_def_property_enum_sdna ( prop , NULL , " hatf " ) ;
RNA_def_property_enum_items ( prop , hat_direction_items ) ;
2010-02-10 21:15:44 +00:00
RNA_def_property_ui_text ( prop , " Hat Direction " , " Specify hat direction " ) ;
2010-05-08 19:52:13 +00:00
RNA_def_property_update ( prop , NC_LOGIC , NULL ) ;
2008-11-29 22:16:23 +00:00
}
void RNA_def_sensor ( BlenderRNA * brna )
{
rna_def_sensor ( brna ) ;
2008-12-02 23:45:11 +00:00
rna_def_always_sensor ( brna ) ;
2008-11-29 22:16:23 +00:00
rna_def_near_sensor ( brna ) ;
rna_def_mouse_sensor ( brna ) ;
rna_def_touch_sensor ( brna ) ;
rna_def_keyboard_sensor ( brna ) ;
rna_def_property_sensor ( brna ) ;
2009-09-24 21:22:24 +00:00
rna_def_armature_sensor ( brna ) ;
2008-11-29 22:16:23 +00:00
rna_def_actuator_sensor ( brna ) ;
rna_def_delay_sensor ( brna ) ;
rna_def_collision_sensor ( brna ) ;
rna_def_radar_sensor ( brna ) ;
rna_def_random_sensor ( brna ) ;
rna_def_ray_sensor ( brna ) ;
rna_def_message_sensor ( brna ) ;
rna_def_joystick_sensor ( brna ) ;
2008-11-29 02:01:39 +00:00
}
# endif