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