Blender V2.61 - r43446
|
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 * Contributor(s): none yet. 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 #ifndef BKE_SKETCH_H 00023 #define BKE_SKETCH_H 00024 00029 typedef enum SK_PType 00030 { 00031 PT_CONTINUOUS, 00032 PT_EXACT, 00033 } SK_PType; 00034 00035 typedef enum SK_PMode 00036 { 00037 PT_SNAP, 00038 PT_PROJECT, 00039 } SK_PMode; 00040 00041 typedef struct SK_Point 00042 { 00043 float p[3]; 00044 short p2d[2]; 00045 float no[3]; 00046 float size; 00047 SK_PType type; 00048 SK_PMode mode; 00049 } SK_Point; 00050 00051 typedef struct SK_Stroke 00052 { 00053 struct SK_Stroke *next, *prev; 00054 00055 SK_Point *points; 00056 int nb_points; 00057 int buf_size; 00058 int selected; 00059 } SK_Stroke; 00060 00061 #define SK_OVERDRAW_LIMIT 5 00062 00063 typedef struct SK_Overdraw 00064 { 00065 SK_Stroke *target; 00066 int start, end; 00067 int count; 00068 } SK_Overdraw; 00069 00070 #define SK_Stroke_BUFFER_INIT_SIZE 20 00071 00072 typedef struct SK_DrawData 00073 { 00074 int mval[2]; 00075 int previous_mval[2]; 00076 SK_PType type; 00077 } SK_DrawData; 00078 00079 typedef struct SK_Intersection 00080 { 00081 struct SK_Intersection *next, *prev; 00082 SK_Stroke *stroke; 00083 int before; 00084 int after; 00085 int gesture_index; 00086 float p[3]; 00087 float lambda; /* used for sorting intersection points */ 00088 } SK_Intersection; 00089 00090 typedef struct SK_Sketch 00091 { 00092 ListBase strokes; 00093 ListBase depth_peels; 00094 SK_Stroke *active_stroke; 00095 SK_Stroke *gesture; 00096 SK_Point next_point; 00097 SK_Overdraw over; 00098 } SK_Sketch; 00099 00100 00101 typedef struct SK_Gesture { 00102 SK_Stroke *stk; 00103 SK_Stroke *segments; 00104 00105 ListBase intersections; 00106 ListBase self_intersections; 00107 00108 int nb_self_intersections; 00109 int nb_intersections; 00110 int nb_segments; 00111 } SK_Gesture; 00112 00113 00114 /************************************************/ 00115 00116 void freeSketch(SK_Sketch *sketch); 00117 SK_Sketch* createSketch(void); 00118 00119 void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk); 00120 00121 void sk_freeStroke(SK_Stroke *stk); 00122 SK_Stroke* sk_createStroke(void); 00123 00124 SK_Point *sk_lastStrokePoint(SK_Stroke *stk); 00125 00126 void sk_allocStrokeBuffer(SK_Stroke *stk); 00127 void sk_shrinkStrokeBuffer(SK_Stroke *stk); 00128 void sk_growStrokeBuffer(SK_Stroke *stk); 00129 void sk_growStrokeBufferN(SK_Stroke *stk, int n); 00130 00131 void sk_replaceStrokePoint(SK_Stroke *stk, SK_Point *pt, int n); 00132 void sk_insertStrokePoint(SK_Stroke *stk, SK_Point *pt, int n); 00133 void sk_appendStrokePoint(SK_Stroke *stk, SK_Point *pt); 00134 void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end); 00135 00136 void sk_trimStroke(SK_Stroke *stk, int start, int end); 00137 void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], float p_end[3]); 00138 void sk_polygonizeStroke(SK_Stroke *stk, int start, int end); 00139 void sk_flattenStroke(SK_Stroke *stk, int start, int end); 00140 void sk_reverseStroke(SK_Stroke *stk); 00141 00142 void sk_filterLastContinuousStroke(SK_Stroke *stk); 00143 void sk_filterStroke(SK_Stroke *stk, int start, int end); 00144 00145 void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no); 00146 void sk_copyPoint(SK_Point *dst, SK_Point *src); 00147 00148 int sk_stroke_filtermval(SK_DrawData *dd); 00149 void sk_endContinuousStroke(SK_Stroke *stk); 00150 00151 void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk); 00152 00153 void sk_initDrawData(SK_DrawData *dd, const int mval[2]); 00154 00155 void sk_deleteSelectedStrokes(SK_Sketch *sketch); 00156 void sk_selectAllSketch(SK_Sketch *sketch, int mode); 00157 00158 #endif