4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
27 #include "RNA_define.h"
28 #include "RNA_types.h"
30 #include "rna_internal.h"
32 #include "DNA_curve_types.h"
33 #include "DNA_key_types.h"
34 #include "DNA_lattice_types.h"
35 #include "DNA_meshdata_types.h"
39 static void rna_LatticePoint_co_get(PointerRNA *ptr, float *values)
41 Lattice *lt= (Lattice*)ptr->id.data;
42 BPoint *bp= (BPoint*)ptr->data;
45 int y= (a/lt->pntsu) % lt->pntsv;
46 int z= (a/(lt->pntsu*lt->pntsv));
48 values[0]= lt->fu + x*lt->du;
49 values[1]= lt->fv + y*lt->dv;
50 values[2]= lt->fw + z*lt->dw;
53 static void rna_LatticePoint_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
55 Lattice *lt= (Lattice*)ptr->id.data;
58 BPoint *bp= (BPoint*)ptr->data;
59 MDeformVert *dvert= lt->dvert + (bp-lt->def);
61 rna_iterator_array_begin(iter, (void*)dvert->dw, sizeof(MDeformWeight), dvert->totweight, NULL);
64 rna_iterator_array_begin(iter, NULL, 0, 0, NULL);
67 static void rna_Lattice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
69 Lattice *lt= (Lattice*)ptr->data;
72 int tot= lt->pntsu*lt->pntsv*lt->pntsw;
73 rna_iterator_array_begin(iter, (void*)lt->def, sizeof(BPoint), tot, NULL);
76 rna_iterator_array_begin(iter, NULL, 0, 0, NULL);
81 static void rna_def_latticepoint(BlenderRNA *brna)
86 srna= RNA_def_struct(brna, "LatticePoint", NULL);
87 RNA_def_struct_sdna(srna, "BPoint");
88 RNA_def_struct_ui_text(srna, "LatticePoint", "Point in the lattice grid.");
90 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR);
91 RNA_def_property_array(prop, 3);
92 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
93 RNA_def_property_float_funcs(prop, "rna_LatticePoint_co_get", NULL, NULL);
94 RNA_def_property_ui_text(prop, "Location", "");
96 prop= RNA_def_property(srna, "deformed_co", PROP_FLOAT, PROP_VECTOR);
97 RNA_def_property_float_sdna(prop, NULL, "vec");
98 RNA_def_property_array(prop, 3);
99 RNA_def_property_ui_text(prop, "Deformed Location", "");
101 prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
102 RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
103 RNA_def_property_struct_type(prop, "VertexGroupElement");
104 RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this point is member of.");
107 static void rna_def_lattice(BlenderRNA *brna)
112 static EnumPropertyItem prop_keyblock_type_items[] = {
113 {KEY_LINEAR, "KEY_LINEAR", "Linear", ""},
114 {KEY_CARDINAL, "KEY_CARDINAL", "Cardinal", ""},
115 {KEY_BSPLINE, "KEY_BSPLINE", "BSpline", ""},
116 {0, NULL, NULL, NULL}};
118 srna= RNA_def_struct(brna, "Lattice", "ID");
119 RNA_def_struct_ui_text(srna, "Lattice", "Lattice datablock defining a grid for deforming other objects.");
121 prop= RNA_def_property(srna, "points_u", PROP_INT, PROP_NONE);
122 RNA_def_property_int_sdna(prop, NULL, "pntsu");
123 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
124 RNA_def_property_ui_text(prop, "U", "Points in U direction.");
126 prop= RNA_def_property(srna, "points_v", PROP_INT, PROP_NONE);
127 RNA_def_property_int_sdna(prop, NULL, "pntsv");
128 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
129 RNA_def_property_ui_text(prop, "V", "Points in V direction.");
131 prop= RNA_def_property(srna, "points_w", PROP_INT, PROP_NONE);
132 RNA_def_property_int_sdna(prop, NULL, "pntsw");
133 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
134 RNA_def_property_ui_text(prop, "W", "Points in W direction.");
136 prop= RNA_def_property(srna, "interpolation_type_u", PROP_ENUM, PROP_NONE);
137 RNA_def_property_enum_sdna(prop, NULL, "typeu");
138 RNA_def_property_enum_items(prop, prop_keyblock_type_items);
139 RNA_def_property_ui_text(prop, "Interpolation Type U", "");
141 prop= RNA_def_property(srna, "interpolation_type_v", PROP_ENUM, PROP_NONE);
142 RNA_def_property_enum_sdna(prop, NULL, "typev");
143 RNA_def_property_enum_items(prop, prop_keyblock_type_items);
144 RNA_def_property_ui_text(prop, "Interpolation Type V", "");
146 prop= RNA_def_property(srna, "interpolation_type_w", PROP_ENUM, PROP_NONE);
147 RNA_def_property_enum_sdna(prop, NULL, "typew");
148 RNA_def_property_enum_items(prop, prop_keyblock_type_items);
149 RNA_def_property_ui_text(prop, "Interpolation Type W", "");
151 prop= RNA_def_property(srna, "outside", PROP_BOOLEAN, PROP_NONE);
152 RNA_def_property_boolean_sdna(prop, NULL, "flag", LT_OUTSIDE);
153 RNA_def_property_ui_text(prop, "Outside", "Only draw, and take into account, the outer vertices.");
155 prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
156 RNA_def_property_pointer_sdna(prop, NULL, "key");
157 RNA_def_property_ui_text(prop, "Shape Keys", "");
159 prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
160 RNA_def_property_struct_type(prop, "LatticePoint");
161 RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
162 RNA_def_property_ui_text(prop, "Points", "Points of the lattice.");
165 void RNA_def_lattice(BlenderRNA *brna)
167 rna_def_lattice(brna);
168 rna_def_latticepoint(brna);