BlenderDev/mesh

Wikipedia,自由的百科全书

Mesh的结构定义如下:

代码:


typedef struct Mesh {

  ID id;


  struct BoundBox *bb;


  ListBase effect;
  ListBase disp;


  struct Ipo *ipo;
  struct Key *key;
  struct Material **mat;


  void *mface, *dface, *tface;
  struct MVert *mvert;
  struct MEdge *medge;
  struct MDeformVert *dvert;   /* __NLA */
  struct MCol *mcol;
  struct MSticky *msticky;
  struct Mesh *texcomesh;
  float *orco;


     /* not written in file, caches derived mesh */
  struct DerivedMesh *derived;
     /* hacky place to store temporary decimated mesh */
  struct DispListMesh *decimated;


  struct OcInfo *oc;      /* not written in file */
  void *sumohandle;


  int totvert, totedge, totface;
  int texflag;


  float loc[3];
  float size[3];
  float rot[3];


  float cubemapsize, pad;


  short smoothresh, flag;


  short subdiv, subdivr;
  short totcol;
  short subsurftype;


} Mesh;



这个定义在DNA_mesh_types.h中,这个Mesh的定义和我们正常定义差不多,其中,顶点的定义在DNA_meshdata_type.h中,一般在VS的工程中找不到这个文件,需要自己在makesdna文件夹下找一下,其定义如下:

代码:


typedef struct MFace {

  unsigned int v1, v2, v3, v4;
  char puno, mat_nr;
  char edcode, flag;

} MFace;


typedef struct MEdge {

  unsigned int v1, v2;
  char crease, pad;
  short flag;

} MEdge;


typedef struct MDeformWeight {

  int            def_nr;
  float         weight;
  struct Bone      *data;      /* Runtime: Does not need to be valid in file */

} MDeformWeight;


typedef struct MDeformVert {

  struct MDeformWeight *dw;
  int totweight;
  int reserved1;

} MDeformVert;


typedef struct MVert {

  float   co[3];
  short   no[3];
  char flag, mat_nr;

} MVert;


typedef struct MCol {

  char a, r, g, b;

} MCol;


typedef struct MSticky {

  float co[2];

} MSticky;



这是mail list 给我的解释,没有翻译:

> typedef struct Mesh {

> ID id;


id: used for storage of the Mesh struct in the library


> struct BoundBox *bb;


The boundbox of the mesh (surprise!)


> ListBase effect;


A list of effects applied to the mesh (again, surprise!)


> ListBase disp;


A list of display lists, I suppose. Not sure.


> struct Ipo *ipo;


A list of IPOs, for vertex keys, etc.


> struct Key *key;


A list of vertex keys (surprise!)


> struct Material **mat;


A list of materials applied to this mesh (surprise!)


> void *mface, *dface, *tface;


tface stores UV mapping, I think together with mface, in some way. About

dface, I'm not sure. This part is pretty chaotic from what I remember.


> struct MVert *mvert;


The vertices.


> struct MEdge *medge;


The edges.


> struct MDeformVert *dvert; /* __NLA */


This stores vertex groups.


> struct MCol *mcol;


This stores vertes colors.


> struct MSticky *msticky;


Sticky coordinates.


> struct Mesh *texcomesh;


Pointer to the mesh giving texture coordinates ("TexMesh")


> float *orco;


Used for texture mapping, storing the original texture coordinates of the

undeformed mesh - or something. Not sure, check the code for the exact

meaning.


> /* not written in file, caches derived mesh */

> struct DerivedMesh *derived;

> /* hacky place to store temporary decimated mesh */

> struct DispListMesh *decimated;

>

> struct OcInfo *oc; /* not written in file */

> void *sumohandle;


sumohandle is game-engine related and stores a handle for the physics

system.


> int totvert, totedge, totface;


Self-explanatory.


> int texflag;


Should be explained further below in the file.


> float loc[3];

> float size[3];

> float rot[3];


Stores texture space transform.


> float cubemapsize, pad;


Not sure about cubemapsize.


> short smoothresh, flag;


Not sure about smoothresh, flag is explained further below.


> short subdiv, subdivr;


Should be clear, SubSurf levels for OGL/Render.


> short totcol;


Total amount of materials on the mesh.


> short subsurftype;

>

> } Mesh;

Personal tools