|
Blender
V2.59
|
00001 /* 00002 * $Id: BKE_cdderivedmesh.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) 2006 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): Ben Batt <benbatt@gmail.com> 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00037 #ifndef BKE_CDDERIVEDMESH_H 00038 #define BKE_CDDERIVEDMESH_H 00039 00040 #include "BKE_DerivedMesh.h" 00041 00042 struct DerivedMesh; 00043 struct EditMesh; 00044 struct Mesh; 00045 struct Object; 00046 00047 /* creates a new CDDerivedMesh */ 00048 struct DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces); 00049 00050 /* creates a CDDerivedMesh from the given Mesh, this will reference the 00051 original data in Mesh, but it is safe to apply vertex coordinates or 00052 calculate normals as those functions will automtically create new 00053 data to not overwrite the original */ 00054 struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob); 00055 00056 /* creates a CDDerivedMesh from the given EditMesh */ 00057 struct DerivedMesh *CDDM_from_editmesh(struct EditMesh *em, struct Mesh *me); 00058 00059 /* creates a CDDerivedMesh from the given curve object */ 00060 struct DerivedMesh *CDDM_from_curve(struct Object *ob); 00061 00062 /* creates a CDDerivedMesh from the given curve object and specified dispbase */ 00063 /* useful for OrcoDM creation for curves with constructive modifiers */ 00064 DerivedMesh *CDDM_from_curve_customDB(struct Object *ob, struct ListBase *dispbase); 00065 00066 /* Copies the given DerivedMesh with verts, faces & edges stored as 00067 * custom element data. 00068 */ 00069 struct DerivedMesh *CDDM_copy(struct DerivedMesh *dm); 00070 00071 /* creates a CDDerivedMesh with the same layer stack configuration as the 00072 * given DerivedMesh and containing the requested numbers of elements. 00073 * elements are initialised to all zeros 00074 */ 00075 struct DerivedMesh *CDDM_from_template(struct DerivedMesh *source, 00076 int numVerts, int numEdges, int numFaces); 00077 00078 /* applies vertex coordinates or normals to a CDDerivedMesh. if the MVert 00079 * layer is a referenced layer, it will be duplicate to not overwrite the 00080 * original 00081 */ 00082 void CDDM_apply_vert_coords(struct DerivedMesh *cddm, float (*vertCoords)[3]); 00083 void CDDM_apply_vert_normals(struct DerivedMesh *cddm, short (*vertNormals)[3]); 00084 00085 /* recalculates vertex and face normals for a CDDerivedMesh 00086 */ 00087 void CDDM_calc_normals(struct DerivedMesh *dm); 00088 00089 /* calculates edges for a CDDerivedMesh (from face data) 00090 * this completely replaces the current edge data in the DerivedMesh 00091 */ 00092 void CDDM_calc_edges(struct DerivedMesh *dm); 00093 00094 /* lowers the number of vertices/edges/faces in a CDDerivedMesh 00095 * the layer data stays the same size 00096 */ 00097 void CDDM_lower_num_verts(struct DerivedMesh *dm, int numVerts); 00098 void CDDM_lower_num_edges(struct DerivedMesh *dm, int numEdges); 00099 void CDDM_lower_num_faces(struct DerivedMesh *dm, int numFaces); 00100 00101 /* vertex/edge/face access functions 00102 * should always succeed if index is within bounds 00103 * note these return pointers - any change modifies the internals of the mesh 00104 */ 00105 struct MVert *CDDM_get_vert(struct DerivedMesh *dm, int index); 00106 struct MEdge *CDDM_get_edge(struct DerivedMesh *dm, int index); 00107 struct MFace *CDDM_get_face(struct DerivedMesh *dm, int index); 00108 00109 /* vertex/edge/face array access functions - return the array holding the 00110 * desired data 00111 * should always succeed 00112 * note these return pointers - any change modifies the internals of the mesh 00113 */ 00114 struct MVert *CDDM_get_verts(struct DerivedMesh *dm); 00115 struct MEdge *CDDM_get_edges(struct DerivedMesh *dm); 00116 struct MFace *CDDM_get_faces(struct DerivedMesh *dm); 00117 #endif 00118