[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17623] branches/blender2.5/blender/source /blender/makesrna: more rna_sensor codes
Hamed Zaghaghi
hamed.zaghaghi at gmail.com
Sat Nov 29 17:07:54 CET 2008
Revision: 17623
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17623
Author: zaghaghi
Date: 2008-11-29 17:07:49 +0100 (Sat, 29 Nov 2008)
Log Message:
-----------
more rna_sensor codes
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_sensor.c
Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_access.h 2008-11-29 15:43:53 UTC (rev 17622)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_access.h 2008-11-29 16:07:49 UTC (rev 17623)
@@ -82,6 +82,7 @@
extern StructRNA RNA_Operator;
extern StructRNA RNA_WindowManager;
extern StructRNA RNA_Sensor;
+extern StructRNA RNA_MouseSensor;
/* Pointer
*
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c 2008-11-29 15:43:53 UTC (rev 17622)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c 2008-11-29 16:07:49 UTC (rev 17623)
@@ -58,6 +58,9 @@
prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_ui_text(prop, "Location", "");
+ prop= RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Sensor");
+ RNA_def_property_ui_text(prop, "Sensors", "Sensors of this object.");
}
#endif
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_sensor.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_sensor.c 2008-11-29 15:43:53 UTC (rev 17622)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_sensor.c 2008-11-29 16:07:49 UTC (rev 17623)
@@ -33,16 +33,98 @@
#include "DNA_sensor_types.h"
#ifdef RNA_RUNTIME
-
+/*
+static struct StructRNA* rna_Sensor_data_type(struct PointerRNA *ptr)
+{
+// This function should reture the type of
+// void* data;
+// in bSensor structure
+ switch( ((bSensor*)ptr)->type ){
+ case SENS_MOUSE:
+ return &RNA_MouseSensor;
+ }
+ return NULL;
+}
+*/
#else
-
void RNA_def_sensor(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
- srna= RNA_def_struct(brna, "Sensor", NULL, "Sensor");
+ static EnumPropertyItem pulse_modes[]={
+ {SENS_PULSE_CONT, "CONTINUE", "Continue Pulse", ""},
+ {SENS_PULSE_REPEAT, "REPEAT", "Repeat Pulse", ""},
+ {SENS_NEG_PULSE_MODE, "NEGATIVE", "Negative Pulse", ""},
+ {0, NULL, NULL, NULL}};
+
+ static EnumPropertyItem sensor_types_items[] ={
+ {SENS_ALWAYS, "ALWAYS", "Always", ""},
+ {SENS_TOUCH, "TOUCH", "Touch", ""},
+ {SENS_NEAR, "NEAR", "Near", ""},
+ {SENS_KEYBOARD, "KEYBOARD", "Keyboard", ""},
+ {SENS_PROPERTY, "PROPERTY", "Property", ""},
+ {SENS_MOUSE, "MOUSE", "Mouse", ""},
+ {SENS_COLLISION, "COLLISION", "Collision", ""},
+ {SENS_RADAR, "RADAR", "Radar", ""},
+ {SENS_RANDOM, "RANDOM", "Random", ""},
+ {SENS_RAY, "RAY", "Ray", ""},
+ {SENS_MESSAGE, "MESSAGE", "Message", ""},
+ {SENS_JOYSTICK, "JOYSTICK", "joystick", ""},
+ {SENS_ACTUATOR, "ACTUATOR", "Actuator", ""},
+ {SENS_DELAY, "DELAY", "Delay", ""},
+ {0, NULL, NULL, NULL}};
+
+ static EnumPropertyItem mouse_event_items[] ={
+ {BL_SENS_MOUSE_LEFT_BUTTON, "LEFTCLICK", "Left Button", ""},
+ {BL_SENS_MOUSE_MIDDLE_BUTTON, "MIDDLECLICK", "Middle Button", ""},
+ {BL_SENS_MOUSE_RIGHT_BUTTON, "RIGHTCLICK", "Right Button", ""},
+ {BL_SENS_MOUSE_WHEEL_UP, "WHEELUP", "Wheel Up", ""},
+ {BL_SENS_MOUSE_WHEEL_DOWN, "WHEELDOWN", "Wheel Down", ""},
+ {BL_SENS_MOUSE_MOVEMENT, "MOVEMENT", "Movement", ""},
+ {BL_SENS_MOUSE_MOUSEOVER, "MOUSEOVER", "Mouse Over", ""},
+ {BL_SENS_MOUSE_MOUSEOVER_ANY, "MOUSEOVERANY", "Mouse Over Any", ""},
+ {0, NULL, NULL, NULL}};
+
+ srna= RNA_def_struct(brna, "Sensor", NULL , "Sensor");
+ RNA_def_struct_sdna(srna, "bSensor");
+
+ prop= RNA_def_property(srna, "sensor_name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Name", "Sensor name.");
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, sensor_types_items);
+ RNA_def_property_ui_text(prop, "Sensor types", "Sensor Types.");
+
+ prop= RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Invert Output", "Invert the level(output) of this sensor.");
+
+ prop= RNA_def_property(srna, "level", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Level", "Level detector, trigger controllers of new states(only applicable upon logic state transition).");
+
+ prop= RNA_def_property(srna, "pulse", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, pulse_modes);
+ RNA_def_property_ui_text(prop, "Sensor pulse modes", "Sensor pulse modes.");
+
+ prop= RNA_def_property(srna, "freq", PROP_INT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Frequency", "Delay between repeated pulses(in logic tics, 0=no delay).");
+ RNA_def_property_range(prop, 0, 10000);
+
+ /*
+ //This add data property to Sensor, and because data can be bMouseSensor, bNearSensor, bAlwaysSensor ...
+ //rna_Sensor_data_type defines above in runtime section to get its type and proper structure for data
+ prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Data", "Sensor data.");
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_Sensor_data_type", NULL);
+
+ srna= RNA_def_struct(brna, "MouseSensor", NULL , "MouseSensor");
+ RNA_def_struct_sdna(srna, "bMouseSensor");
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, mouse_event_items);
+ RNA_def_property_ui_text(prop, "MouseEvent", "Specify the type of event this mouse sensor should trigger on.");
+ */
}
#endif
More information about the Bf-blender-cvs
mailing list