Blender V2.61 - r43446

BKE_cdderivedmesh.h

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