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 * 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 #ifndef BKE_MBALL_H 00028 #define BKE_MBALL_H 00029 00035 struct MetaBall; 00036 struct Object; 00037 struct Scene; 00038 struct MetaElem; 00039 00040 typedef struct point { /* a three-dimensional point */ 00041 float x, y, z; /* its coordinates */ 00042 } MB_POINT; 00043 00044 typedef struct vertex { /* surface vertex */ 00045 MB_POINT position, normal; /* position and surface normal */ 00046 } VERTEX; 00047 00048 typedef struct vertices { /* list of vertices in polygonization */ 00049 int count, max; /* # vertices, max # allowed */ 00050 VERTEX *ptr; /* dynamically allocated */ 00051 } VERTICES; 00052 00053 typedef struct corner { /* corner of a cube */ 00054 int i, j, k; /* (i, j, k) is index within lattice */ 00055 float x, y, z, value; /* location and function value */ 00056 struct corner *next; 00057 } CORNER; 00058 00059 typedef struct cube { /* partitioning cell (cube) */ 00060 int i, j, k; /* lattice location of cube */ 00061 CORNER *corners[8]; /* eight corners */ 00062 } CUBE; 00063 00064 typedef struct cubes { /* linked list of cubes acting as stack */ 00065 CUBE cube; /* a single cube */ 00066 struct cubes *next; /* remaining elements */ 00067 } CUBES; 00068 00069 typedef struct centerlist { /* list of cube locations */ 00070 int i, j, k; /* cube location */ 00071 struct centerlist *next; /* remaining elements */ 00072 } CENTERLIST; 00073 00074 typedef struct edgelist { /* list of edges */ 00075 int i1, j1, k1, i2, j2, k2; /* edge corner ids */ 00076 int vid; /* vertex id */ 00077 struct edgelist *next; /* remaining elements */ 00078 } EDGELIST; 00079 00080 typedef struct intlist { /* list of integers */ 00081 int i; /* an integer */ 00082 struct intlist *next; /* remaining elements */ 00083 } INTLIST; 00084 00085 typedef struct intlists { /* list of list of integers */ 00086 INTLIST *list; /* a list of integers */ 00087 struct intlists *next; /* remaining elements */ 00088 } INTLISTS; 00089 00090 typedef struct process { /* parameters, function, storage */ 00091 /* what happens here? floats, I think. */ 00092 /* float (*function)(void); */ /* implicit surface function */ 00093 float (*function)(float, float, float); 00094 float size, delta; /* cube size, normal delta */ 00095 int bounds; /* cube range within lattice */ 00096 CUBES *cubes; /* active cubes */ 00097 VERTICES vertices; /* surface vertices */ 00098 CENTERLIST **centers; /* cube center hash table */ 00099 CORNER **corners; /* corner value hash table */ 00100 EDGELIST **edges; /* edge and vertex id hash table */ 00101 } PROCESS; 00102 00103 /* dividing scene using octal tree makes polygonisation faster */ 00104 typedef struct ml_pointer { 00105 struct ml_pointer *next, *prev; 00106 struct MetaElem *ml; 00107 } ml_pointer; 00108 00109 typedef struct octal_node { 00110 struct octal_node *nodes[8]; /* children of current node */ 00111 struct octal_node *parent; /* parent of current node */ 00112 struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */ 00113 float x_min, y_min, z_min; /* 1st border point */ 00114 float x_max, y_max, z_max; /* 7th border point */ 00115 float x,y,z; /* center of node */ 00116 int pos, neg; /* number of positive and negative MetaElements in the node */ 00117 int count; /* number of MetaElems, which belongs to the node */ 00118 } octal_node; 00119 00120 typedef struct octal_tree { 00121 struct octal_node *first; /* first node */ 00122 int pos, neg; /* number of positive and negative MetaElements in the scene */ 00123 short depth; /* number of scene subdivision */ 00124 } octal_tree; 00125 00126 struct pgn_elements { 00127 struct pgn_elements *next, *prev; 00128 char *data; 00129 }; 00130 00131 octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth); 00132 00133 void freepolygonize(PROCESS *p); 00134 void docube(CUBE *cube, PROCESS *p, struct MetaBall *mb); 00135 void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p); 00136 CORNER *setcorner (PROCESS* p, int i, int j, int k); 00137 int vertid (CORNER *c1, CORNER *c2, PROCESS *p, struct MetaBall *mb); 00138 int setcenter(CENTERLIST *table[], int i, int j, int k); 00139 int otherface (int edge, int face); 00140 void makecubetable (void); 00141 void setedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2, int vid); 00142 int getedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2); 00143 void addtovertices (VERTICES *vertices, VERTEX v); 00144 void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v); 00145 void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, float (*function)(float, float, float), MB_POINT *p, struct MetaBall *mb, int f); 00146 void add_cube(PROCESS *mbproc, int i, int j, int k, int count); 00147 void find_first_points(PROCESS *mbproc, struct MetaBall *mb, int a); 00148 00149 void fill_metaball_octal_node(octal_node *node, struct MetaElem *ml, short i); 00150 void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth); 00151 void free_metaball_octal_node(octal_node *node); 00152 void init_metaball_octal_tree(int depth); 00153 void polygonize(PROCESS *mbproc, struct MetaBall *mb); 00154 float init_meta(struct Scene *scene, struct Object *ob); 00155 00156 void unlink_mball(struct MetaBall *mb); 00157 void free_mball(struct MetaBall *mb); 00158 struct MetaBall *add_mball(const char *name); 00159 struct MetaBall *copy_mball(struct MetaBall *mb); 00160 void make_local_mball(struct MetaBall *mb); 00161 struct MetaElem *add_metaball_element(struct MetaBall *mb, const int type); 00162 void tex_space_mball(struct Object *ob); 00163 float *make_orco_mball(struct Object *ob, struct ListBase *dispbase); 00164 void copy_mball_properties(struct Scene *scene, struct Object *active_object); 00165 struct Object *find_basis_mball(struct Scene *scene, struct Object *ob); 00166 int is_basis_mball(struct Object *ob); 00167 int is_mball_basis_for(struct Object *ob1, struct Object *ob2); 00168 void metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); 00169 void calc_mballco(struct MetaElem *ml, float *vec); 00170 float densfunc(struct MetaElem *ball, float x, float y, float z); 00171 float metaball(float x, float y, float z); 00172 void accum_mballfaces(int i1, int i2, int i3, int i4); 00173 void *new_pgn_element(int size); 00174 int nextcwedge (int edge, int face); 00175 void BKE_freecubetable(void); 00176 00177 #endif 00178