Blender  V2.59
DNA_sensor_types.h
Go to the documentation of this file.
00001 /*
00002  * $Id: DNA_sensor_types.h 34941 2011-02-17 20:48:12Z jesterking $ 
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 #ifndef DNA_SENSOR_TYPES_H
00030 #define DNA_SENSOR_TYPES_H
00031 
00038 struct Object;
00039 struct Material;
00040 
00041 /* ****************** SENSORS ********************* */
00042 
00043 typedef struct bNearSensor {
00044         char name[32];
00045         float dist, resetdist;
00046         int lastval, pad;
00047 } bNearSensor;
00048 
00052 typedef struct bMouseSensor {
00056         short type;
00057         short flag;
00058         short pad1;
00059         short pad2;
00060 } bMouseSensor;
00061 
00062 typedef struct bTouchSensor {
00063         char name[32];
00064         struct Material *ma;
00065         float dist, pad;
00066 } bTouchSensor;
00067 
00068 typedef struct bKeyboardSensor {
00069         short key, qual;
00070         short type, qual2;
00074         char targetName[32];
00078         char toggleName[32];
00079 } bKeyboardSensor;
00080 
00081 typedef struct bPropertySensor {
00082         int type;
00083         int pad;
00084         char name[32];
00085         char value[32];
00086         char maxvalue[32];
00087 } bPropertySensor;
00088 
00089 typedef struct bActuatorSensor {
00090         int type;
00091         int pad;
00092         char name[32];
00093 } bActuatorSensor;
00094 
00095 typedef struct bDelaySensor {
00096         short delay;
00097         short duration;
00098         short flag;
00099         short pad;
00100 } bDelaySensor;
00101 
00102 typedef struct bCollisionSensor {
00103         char name[32];          /* property name */
00104         char materialName[32];  /* material      */
00105         // struct Material *ma; // XXX remove materialName
00106         short damptimer, damp;
00107         short mode;             /* flag to choose material or property */
00108          short pad2;
00109 } bCollisionSensor;
00110 
00111 typedef struct bRadarSensor {
00112         char name[32];
00113         float angle;
00114         float range;
00115         short flag, axis;
00116 } bRadarSensor;
00117 
00118 typedef struct bRandomSensor {
00119         char name[32];
00120         int seed;
00121         int delay;
00122 } bRandomSensor;
00123 
00124 typedef struct bRaySensor {
00125         char name[32];
00126         float range;
00127         char propname[32];
00128         char matname[32];
00129         //struct Material *ma; // XXX remove materialName
00130         short mode;
00131         short pad1;
00132         int axisflag;
00133 } bRaySensor;
00134 
00135 typedef struct bArmatureSensor {
00136         char posechannel[32];
00137         char constraint[32];
00138         int  type;
00139         float value;
00140 } bArmatureSensor;
00141 
00142 typedef struct bMessageSensor {
00146         struct Object *fromObject;
00147 
00151         char subject[32];
00152 
00156         char body[32];
00157 } bMessageSensor;
00158 
00159 typedef struct bSensor {
00160         struct bSensor *next, *prev;
00161         /* pulse and freq are the bool toggle and frame count for pulse mode */
00162         short type, otype, flag, pulse;
00163         short freq, totlinks, pad1, pad2;
00164         char name[32];
00165         void *data;
00166         
00167         struct bController **links;
00168         
00169         struct Object *ob;
00170 
00171         /* just add here, to avoid align errors... */
00172         short invert; /* Whether or not to invert the output. */
00173         short level;  /* Whether the sensor is level base (edge by default) */
00174         short tap;
00175         short pad;
00176 } bSensor;
00177 
00178 typedef struct bJoystickSensor {
00179         char name[32];
00180         char type;
00181         char joyindex;
00182         short flag;
00183         short axis;
00184         short axis_single;
00185         int axisf;
00186         int button;
00187         int hat;
00188         int hatf;
00189         int precision;
00190 } bJoystickSensor;
00191 
00192 /* bMouseSensor->type: uses blender event defines */
00193 
00194 /* bMouseSensor->flag: only pulse for now */
00195 #define SENS_MOUSE_FOCUS_PULSE  1
00196 
00197 /* propertysensor->type */
00198 #define SENS_PROP_EQUAL         0
00199 #define SENS_PROP_NEQUAL        1
00200 #define SENS_PROP_INTERVAL      2
00201 #define SENS_PROP_CHANGED       3
00202 #define SENS_PROP_EXPRESSION    4
00203 
00204 /* raysensor->axisflag */
00205 /* flip x and y to make y default!!! */
00206 #define SENS_RAY_X_AXIS     1
00207 #define SENS_RAY_Y_AXIS     0
00208 #define SENS_RAY_Z_AXIS     2
00209 #define SENS_RAY_NEG_X_AXIS     3
00210 #define SENS_RAY_NEG_Y_AXIS     4
00211 #define SENS_RAY_NEG_Z_AXIS     5
00212 //#define SENS_RAY_NEGATIVE_AXIS     1
00213 
00214 /* bRadarSensor->axis */
00215 #define SENS_RADAR_X_AXIS     0
00216 #define SENS_RADAR_Y_AXIS     1
00217 #define SENS_RADAR_Z_AXIS     2
00218 #define SENS_RADAR_NEG_X_AXIS     3
00219 #define SENS_RADAR_NEG_Y_AXIS     4
00220 #define SENS_RADAR_NEG_Z_AXIS     5
00221 
00222 /* bMessageSensor->type */
00223 #define SENS_MESG_MESG          0
00224 #define SENS_MESG_PROP          1
00225 
00226 /* bArmatureSensor->type */
00227 #define SENS_ARM_STATE_CHANGED          0
00228 #define SENS_ARM_LIN_ERROR_BELOW        1
00229 #define SENS_ARM_LIN_ERROR_ABOVE        2
00230 #define SENS_ARM_ROT_ERROR_BELOW        3
00231 #define SENS_ARM_ROT_ERROR_ABOVE        4
00232 /* update this when adding new type */
00233 #define SENS_ARM_MAXTYPE                        4
00234 
00235 /* sensor->type */
00236 #define SENS_ALWAYS             0
00237 #define SENS_TOUCH              1
00238 #define SENS_NEAR               2
00239 #define SENS_KEYBOARD   3
00240 #define SENS_PROPERTY   4
00241 #define SENS_MOUSE              5
00242 #define SENS_COLLISION  6
00243 #define SENS_RADAR              7
00244 #define SENS_RANDOM     8
00245 #define SENS_RAY        9
00246 #define SENS_MESSAGE   10
00247 #define SENS_JOYSTICK  11
00248 #define SENS_ACTUATOR  12
00249 #define SENS_DELAY     13
00250 #define SENS_ARMATURE  14
00251 /* sensor->flag */
00252 #define SENS_SHOW               1
00253 #define SENS_DEL                2
00254 #define SENS_NEW                4
00255 #define SENS_NOT                8
00256 #define SENS_VISIBLE    16
00257 #define SENS_PIN                32
00258 
00259 /* sensor->pulse */
00260 #define SENS_PULSE_CONT         0
00261 #define SENS_PULSE_REPEAT       1
00262 //#define SENS_PULSE_ONCE       2
00263 #define SENS_NEG_PULSE_MODE 4
00264 
00265 /* sensor->suppress */
00266 #define SENS_SUPPRESS_POSITIVE (1 << 0)
00267 #define SENS_SUPPRESS_NEGATIVE (1 << 1)
00268 
00269 /* collision, ray sensor modes: */
00270 /* A little bit fake: when property is active, the first bit is
00271  * reset. Bite me :) So we don't actually use it, so we comment it out
00272  * ... The reason for this is that we need to be backward compatible,
00273  * and have a proper default value for this thing.
00274  * */
00275 #define SENS_COLLISION_PROPERTY 0
00276 #define SENS_COLLISION_MATERIAL 1
00277 #define SENS_COLLISION_PULSE 2
00278 
00279 /* ray specific mode */
00280 /* X-Ray means that the ray will traverse objects that don't have the property/material */
00281 #define SENS_RAY_PROPERTY               0
00282 #define SENS_RAY_MATERIAL               1
00283 #define SENS_RAY_XRAY                   2
00284 
00285 /* Some stuff for the mouse sensor Type: */
00286 #define BL_SENS_MOUSE_LEFT_BUTTON    1
00287 #define BL_SENS_MOUSE_MIDDLE_BUTTON  2
00288 #define BL_SENS_MOUSE_RIGHT_BUTTON   4
00289 #define BL_SENS_MOUSE_WHEEL_UP       5
00290 #define BL_SENS_MOUSE_WHEEL_DOWN     6
00291 #define BL_SENS_MOUSE_MOVEMENT       8
00292 #define BL_SENS_MOUSE_MOUSEOVER      16
00293 #define BL_SENS_MOUSE_MOUSEOVER_ANY      32
00294 
00295 /* Joystick sensor - sorted by axis types */
00296 #define SENS_JOY_ANY_EVENT              1
00297 
00298 #define SENS_JOY_BUTTON         0                       /* axis type */
00299 #define SENS_JOY_BUTTON_PRESSED 0
00300 #define SENS_JOY_BUTTON_RELEASED        1
00301 
00302 #define SENS_JOY_AXIS                   1               /* axis type */
00303 #define SENS_JOY_X_AXIS         0
00304 #define SENS_JOY_Y_AXIS         1
00305 #define SENS_JOY_NEG_X_AXIS             2
00306 #define SENS_JOY_NEG_Y_AXIS             3
00307 #define SENS_JOY_PRECISION              4
00308 
00309 #define SENS_JOY_HAT                    2               /* axis type */
00310 #define SENS_JOY_HAT_DIR                0
00311 #define SENS_JOY_HAT_UP                 1
00312 #define SENS_JOY_HAT_RIGHT              2
00313 #define SENS_JOY_HAT_DOWN               4
00314 #define SENS_JOY_HAT_LEFT               8
00315 
00316 #define SENS_JOY_HAT_UP_RIGHT   SENS_JOY_HAT_UP | SENS_JOY_HAT_RIGHT
00317 #define SENS_JOY_HAT_DOWN_RIGHT SENS_JOY_HAT_DOWN | SENS_JOY_HAT_RIGHT
00318 #define SENS_JOY_HAT_UP_LEFT    SENS_JOY_HAT_UP | SENS_JOY_HAT_LEFT
00319 #define SENS_JOY_HAT_DOWN_LEFT  SENS_JOY_HAT_DOWN | SENS_JOY_HAT_LEFT
00320 
00321 
00322 #define SENS_JOY_AXIS_SINGLE    3               /* axis type */
00323 
00324 
00325 #define SENS_DELAY_REPEAT               1
00326 // should match JOYINDEX_MAX in SCA_JoystickDefines.h */
00327 #define SENS_JOY_MAXINDEX               8
00328 #endif
00329