Blender  V2.59
DNA_curve_types.h
Go to the documentation of this file.
00001 /*
00002  * $Id: DNA_curve_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_CURVE_TYPES_H
00030 #define DNA_CURVE_TYPES_H
00031 
00036 #include "DNA_listBase.h"
00037 #include "DNA_vec_types.h"
00038 #include "DNA_ID.h"
00039 
00040 #define MAXTEXTBOX 256  /* used in readfile.c and editfont.c */
00041 
00042 struct BoundBox;
00043 struct Object;
00044 struct Ipo;
00045 struct Key;
00046 struct Material;
00047 struct VFont;
00048 struct AnimData;
00049 struct SelBox;
00050 struct EditFont;
00051 struct GHash;
00052 
00053 /* These two Lines with # tell makesdna this struct can be excluded. */
00054 #
00055 #
00056 typedef struct PathPoint {
00057         float vec[4]; /* grr, cant get rid of tilt yet */
00058         float quat[4];
00059         float radius, weight;
00060 } PathPoint;
00061 
00062 /* These two Lines with # tell makesdna this struct can be excluded. */
00063 #
00064 #
00065 typedef struct Path {
00066         struct PathPoint *data;
00067         int len;
00068         float totdist;
00069 } Path;
00070 
00071 /* These two Lines with # tell makesdna this struct can be excluded. */
00072 #
00073 #
00074 typedef struct BevList {
00075         struct BevList *next, *prev;
00076         int nr, dupe_nr;
00077         short poly, hole;
00078 } BevList;
00079 
00080 /* These two Lines with # tell makesdna this struct can be excluded. */
00081 #
00082 #
00083 typedef struct BevPoint {
00084         float vec[3], alfa, radius, weight;
00085         float sina, cosa;                               /* 2D Only */
00086         float dir[3], tan[3], quat[4];  /* 3D Only */
00087         short split_tag, dupe_tag;
00088 } BevPoint;
00089 
00090 /* Keyframes on F-Curves (allows code reuse of Bezier eval code) and 
00091  * Points on Bezier Curves/Paths are generally BezTriples 
00092  */
00093 /* note: alfa location in struct is abused by Key system */
00094 /* vec in BezTriple looks like this:
00095         vec[0][0]=x location of handle 1
00096         vec[0][1]=y location of handle 1
00097         vec[0][2]=z location of handle 1 (not used for FCurve Points(2d))
00098         vec[1][0]=x location of control point
00099         vec[1][1]=y location of control point
00100         vec[1][2]=z location of control point
00101         vec[2][0]=x location of handle 2
00102         vec[2][1]=y location of handle 2
00103         vec[2][2]=z location of handle 2 (not used for FCurve Points(2d))
00104 */
00105 typedef struct BezTriple {
00106         float vec[3][3];
00107         float alfa, weight, radius;     /* alfa: tilt in 3D View, weight: used for softbody goal weight, radius: for bevel tapering */
00108         short ipo;                                      /* ipo: interpolation mode for segment from this BezTriple to the next */
00109         char h1, h2;                            /* h1, h2: the handle type of the two handles */
00110         char f1, f2, f3;                        /* f1, f2, f3: used for selection status */
00111         char hide;                                      /* hide: used to indicate whether BezTriple is hidden (3D), type of keyframe (eBezTriple_KeyframeTypes) */
00112 } BezTriple;
00113 
00114 /* note; alfa location in struct is abused by Key system */
00115 typedef struct BPoint {
00116         float vec[4];
00117         float alfa, weight;             /* alfa: tilt in 3D View, weight: used for softbody goal weight */
00118         short f1, hide;                 /* f1: selection status,  hide: is point hidden or not */
00119         float radius, pad;              /* user-set radius per point for bevelling etc */
00120 } BPoint;
00121 
00122 typedef struct Nurb {
00123         struct Nurb *next, *prev;       /* multiple nurbs per curve object are allowed */
00124         short type;
00125         short mat_nr;           /* index into material list */
00126         short hide, flag;
00127         short pntsu, pntsv;             /* number of points in the U or V directions */
00128         short resolu, resolv;   /* tesselation resolution in the U or V directions */
00129         short orderu, orderv;
00130         short flagu, flagv;
00131         
00132         float *knotsu, *knotsv;
00133         BPoint *bp;
00134         BezTriple *bezt;
00135 
00136         short tilt_interp;      /* KEY_LINEAR, KEY_CARDINAL, KEY_BSPLINE */
00137         short radius_interp;
00138         
00139         int charidx;
00140 } Nurb;
00141 
00142 typedef struct CharInfo {
00143         short kern;
00144         short mat_nr; /* index start at 1, unlike mesh & nurbs */
00145         char flag;
00146         char pad;
00147         short pad2;
00148 } CharInfo;
00149 
00150 typedef struct TextBox {
00151         float x, y, w, h;
00152 } TextBox;
00153 
00154 typedef struct EditNurb {
00155         /* base of nurbs' list (old Curve->editnurb) */
00156         ListBase nurbs;
00157 
00158         /* index data for shape keys */
00159         struct GHash *keyindex;
00160 
00161         /* shape key being edited */
00162         int shapenr;
00163 
00164         char pad[4];
00165 } EditNurb;
00166 
00167 typedef struct Curve {
00168         ID id;
00169         struct AnimData *adt;           /* animation data (must be immediately after id for utilities to use it) */ 
00170         
00171         struct BoundBox *bb;
00172         
00173         ListBase nurb;          /* actual data, called splines in rna */
00174         ListBase disp;          /* undeformed display list, used mostly for texture space calculation */
00175         
00176         EditNurb *editnurb;     /* edited data, not in file, use pointer so we can check for it */
00177         
00178         struct Object *bevobj, *taperobj, *textoncurve;
00179         struct Ipo *ipo;        // XXX depreceated... old animation system
00180         Path *path;
00181         struct Key *key;
00182         struct Material **mat;
00183         
00184         ListBase bev;
00185         
00186         /* texture space, copied as one block in editobject.c */
00187         float loc[3];
00188         float size[3];
00189         float rot[3];
00190 
00191         short texflag, pad1; /* keep a short because of give_obdata_texspace() */
00192         short drawflag, twist_mode;
00193         float twist_smooth, smallcaps_scale;
00194 
00195         int pathlen;
00196         short pad, totcol;
00197         short flag, bevresol;
00198         float width, ext1, ext2;
00199         
00200         /* default */
00201         short resolu, resolv;
00202         short resolu_ren, resolv_ren;
00203 
00204         /* edit, index in nurb list */
00205         int actnu;
00206         /* edit, last selected point */
00207         void *lastsel;
00208         
00209         /* font part */
00210         short len, lines, pos, spacemode;
00211         float spacing, linedist, shear, fsize, wordspace, ulpos, ulheight;
00212         float xof, yof;
00213         float linewidth;
00214 
00215         char *str;
00216         struct SelBox *selboxes;
00217         struct EditFont *editfont;
00218         
00219         char family[24];
00220         struct VFont *vfont;
00221         struct VFont *vfontb;
00222         struct VFont *vfonti;
00223         struct VFont *vfontbi;
00224 
00225         int sepchar;
00226         
00227         float ctime;                    /* current evaltime - for use by Objects parented to curves */
00228         int totbox, actbox;
00229         struct TextBox *tb;     
00230         
00231         int selstart, selend;   
00232         
00233         struct CharInfo *strinfo;       
00234         struct CharInfo curinfo;
00235 } Curve;
00236 
00237 /* **************** CURVE ********************* */
00238 
00239 /* texflag */
00240 #define CU_AUTOSPACE    1
00241 
00242 /* drawflag */
00243 #define CU_HIDE_HANDLES (1 << 0)
00244 #define CU_HIDE_NORMALS (1 << 1)
00245 
00246 /* flag */
00247 #define CU_3D                   1
00248 #define CU_FRONT                2
00249 #define CU_BACK                 4
00250 #define CU_PATH                 8
00251 #define CU_FOLLOW               16
00252 #define CU_UV_ORCO              32
00253 #define CU_DEFORM_BOUNDS_OFF 64 
00254 #define CU_STRETCH              128
00255 #define CU_OFFS_PATHDIST        256
00256 #define CU_FAST                 512 /* Font: no filling inside editmode */
00257 #define CU_RETOPO               1024
00258 #define CU_DS_EXPAND    2048
00259 #define CU_PATH_RADIUS  4096 /* make use of the path radius if this is enabled (default for new curves) */
00260 #define CU_DEFORM_FILL  8192 /* fill 2d curve after deformation */
00261 
00262 /* twist mode */
00263 #define CU_TWIST_Z_UP                   0
00264 // #define CU_TWIST_Y_UP                        1 // not used yet
00265 // #define CU_TWIST_X_UP                        2
00266 #define CU_TWIST_MINIMUM                3
00267 #define CU_TWIST_TANGENT                4
00268 
00269 /* spacemode */
00270 #define CU_LEFT                 0
00271 #define CU_MIDDLE               1
00272 #define CU_RIGHT                2
00273 #define CU_JUSTIFY              3
00274 #define CU_FLUSH                4
00275 
00276 /* flag (nurb) */
00277 #define CU_SMOOTH               1
00278 #define CU_2D                   8 /* moved from type since 2.4x */
00279 
00280 /* type (nurb) */
00281 #define CU_POLY                 0
00282 #define CU_BEZIER               1
00283 #define CU_BSPLINE              2
00284 #define CU_CARDINAL             3
00285 #define CU_NURBS                4
00286 #define CU_TYPE                 (CU_POLY|CU_BEZIER|CU_BSPLINE|CU_CARDINAL|CU_NURBS)
00287 
00288                 /* only for adding */
00289 #define CU_PRIMITIVE    0xF00
00290 
00291                 /* 2 or 4 points */
00292 #define CU_PRIM_CURVE   0x100
00293                 /* 8 points circle */
00294 #define CU_PRIM_CIRCLE  0x200
00295                 /* 4x4 patch Nurb */
00296 #define CU_PRIM_PATCH   0x300
00297 #define CU_PRIM_TUBE    0x400
00298 #define CU_PRIM_SPHERE  0x500
00299 #define CU_PRIM_DONUT   0x600
00300                 /* 5 points,  5th order straight line (for anim path) */
00301 #define CU_PRIM_PATH    0x700
00302 
00303 
00304 /* flagu flagv (nurb) */
00305 #define CU_NURB_CYCLIC          1
00306 #define CU_NURB_ENDPOINT        2
00307 #define CU_NURB_BEZIER          4
00308 
00309 /* *************** BEZTRIPLE **************** */
00310 
00311 /* h1 h2 (beztriple) */
00312 typedef enum eBezTriple_Handle {
00313         HD_FREE = 0,
00314         HD_AUTO,
00315         HD_VECT,
00316         HD_ALIGN,
00317         HD_AUTO_ANIM    /* not real handle type, but is just used as dummy item for anim code */
00318 } eBezTriple_Handle;
00319 
00320 /* interpolation modes (used only for BezTriple->ipo) */
00321 typedef enum eBezTriple_Interpolation {
00322         BEZT_IPO_CONST = 0,     /* constant interpolation */
00323         BEZT_IPO_LIN,           /* linear interpolation */
00324         BEZT_IPO_BEZ            /* bezier interpolation */
00325 } eBezTriple_Interpolation;
00326 
00327 /* types of keyframe (used only for BezTriple->hide when BezTriple is used in F-Curves) */
00328 typedef enum eBezTriple_KeyframeType {
00329         BEZT_KEYTYPE_KEYFRAME = 0,      /* default - 'proper' Keyframe */
00330         BEZT_KEYTYPE_EXTREME,           /* 'extreme' keyframe */
00331         BEZT_KEYTYPE_BREAKDOWN,         /* 'breakdown' keyframe */
00332         BEZT_KEYTYPE_JITTER,            /* 'jitter' keyframe (for adding 'filler' secondary motion) */
00333 } eBezTriple_KeyframeType;
00334 
00335 /* checks if the given BezTriple is selected */
00336 #define BEZSELECTED(bezt) (((bezt)->f2 & SELECT) || ((bezt)->f1 & SELECT) || ((bezt)->f3 & SELECT))
00337 #define BEZSELECTED_HIDDENHANDLES(cu, bezt)   (((cu)->drawflag & CU_HIDE_HANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
00338 
00339 /* *************** CHARINFO **************** */
00340 
00341 /* flag */
00342 /* note: CU_CHINFO_WRAP and CU_CHINFO_SMALLCAPS_TEST are set dynamically */
00343 #define CU_CHINFO_BOLD                  (1<<0)
00344 #define CU_CHINFO_ITALIC                (1<<1)
00345 #define CU_CHINFO_UNDERLINE     (1<<2)
00346 #define CU_CHINFO_WRAP                  (1<<3)  /* wordwrap occurred here */
00347 #define CU_CHINFO_SMALLCAPS     (1<<4)
00348 #define CU_CHINFO_SMALLCAPS_CHECK (1<<5) /* set at runtime, checks if case switching is needed */
00349 
00350 /* mixed with KEY_LINEAR but define here since only curve supports */
00351 #define KEY_CU_EASE                     3
00352 
00353 
00354 #endif
00355