Blender V2.61 - r43446

DNA_sensor_types.h

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