Mesh Mesh.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /******************************************************************************
  2. 'Mesh' is a typical object mesh,
  3. it is an array of multiple level of details - 'MeshLods',
  4. it has a one bounding box.
  5. Every 'Mesh' object can be linked with custom 'Skeleton' file.
  6. Once a Mesh is being loaded, it automatically loads the linked Skeleton file,
  7. and adjusts vertex bone indexes to match the Skeleton bone indexes order (this is done according to bone names),
  8. making it possible to draw the mesh with Skeleton based matrixes.
  9. Use 'Meshes' cache for easy mesh accessing from files.
  10. /******************************************************************************/
  11. STRUCT(Mesh , MeshLod) // Mesh (array of Mesh Lod's)
  12. //{
  13. Extent ext ; // bounding box
  14. Vec lod_center; // mesh center position used for calculating lod level, usually equal to "ext.pos"
  15. Int lods( )C {return _lods.elms()+1 ;} // get number of Level of Details including self
  16. MeshLod& lod (Int i) {return i ? _lods[i-1] : T ;} // return i-th Level of Detail
  17. C MeshLod& lod (Int i)C {return i ? _lods[i-1] : SCAST(C MeshLod, T);} // return i-th Level of Detail
  18. Skeleton* skeleton( )C {return _skeleton;} // get Skeleton linked with this Mesh
  19. Mesh& skeleton(Skeleton *skeleton, Bool by_name=false); // link Mesh with specified Skeleton file, avoid calling this realtime as it requires adjusting the vertex skinning information (bone indexes) and re-creating the hardware mesh version, 'by_name'=if remap by bone name only and ignore type/indexes
  20. Mesh& clearSkeleton( ); // clear Mesh link to skeleton and remove all information related to vertex bone mapping
  21. Enum* drawGroupEnum( )C {return _draw_group_enum;} // get enum used for specifying draw groups in all parts for this Mesh, you should pass this value to 'MeshPart.drawGroup' method
  22. Mesh& drawGroupEnum(Enum *e, Bool reset_when_not_found=true); // set enum used for specifying draw groups in all parts for this Mesh, 'reset_when_not_found'=if existing mesh part draw groups are not found, then their draw masks will be reset for "reset_when_not_found==true" and kept for "reset_when_not_found==false"
  23. Bool hasDrawGroup ( Int draw_group_index )C; // check if at least one MeshPart has specified draw group enum index
  24. Bool hasDrawGroupMask(UInt draw_group_mask )C; // check if at least one MeshPart has specified draw group enum mask
  25. // manage
  26. Mesh& del ( ); // delete manually
  27. Mesh& create( Int parts ); // create with 'parts' empty MeshParts
  28. Mesh& create(C Mesh &src , UInt flag_and=~0); // create from 'src', 'flag_and'=MESH_BASE_FLAG
  29. Mesh& create(C MeshGroup &src , UInt flag_and=~0); // create from 'src', 'flag_and'=MESH_BASE_FLAG
  30. Mesh& create(C Mesh *mesh, Int meshes, UInt flag_and=~0); // create from mesh array, 'flag_and'=MESH_BASE_FLAG
  31. void copyParams(C Mesh &src); // copy only parameters without meshes
  32. #if EE_PRIVATE
  33. void zero();
  34. Mesh& include (UInt flag); // include elements specified with 'flag' MESH_BASE_FLAG
  35. #endif
  36. Mesh& exclude (UInt flag); // exclude elements specified with 'flag' MESH_BASE_FLAG
  37. Mesh& keepOnly(UInt flag); // keep only elements specified with 'flag' MESH_BASE_FLAG
  38. // get
  39. UInt memUsage()C; // get memory usage
  40. C MeshLod& getDrawLod (C Matrix &matrix)C; // get Level of Detail which should be used for drawing with current camera and given object 'matrix'
  41. C MeshLod& getDrawLod (C MatrixM &matrix)C; // get Level of Detail which should be used for drawing with current camera and given object 'matrix'
  42. C MeshLod& getDrawLod ( Flt dist2 )C; // get Level of Detail which should be used for drawing with current camera and given object 'dist2' squared distance to camera which can be calculated using 'GetLodDist2' function
  43. Int getDrawLodI(C Matrix &matrix)C; // get index of Level of Detail which should be used for drawing with current camera and given object 'matrix'
  44. Int getDrawLodI(C MatrixM &matrix)C; // get index of Level of Detail which should be used for drawing with current camera and given object 'matrix'
  45. Int getDrawLodI( Flt dist2 )C; // get index of Level of Detail which should be used for drawing with current camera and given object 'dist2' squared distance to camera which can be calculated using 'GetLodDist2' function
  46. #if EE_PRIVATE
  47. Flt lodQuality(Int i, Int base=0)C; // get quality of Level of Detail comparing i-th to base level, returning value in range of 0..1 where 1=full quality, 0=zero quality
  48. #endif
  49. // set
  50. #if EE_PRIVATE
  51. Mesh& setEdgeNormals(Bool flag=false); // recalculate edge 2D normals, 'flag'=if include ETQ_FLAG behavior
  52. Mesh& setNormals2D (Bool flag=false); // recalculate edge and vertex 2D normals, 'flag'=if include ETQ_FLAG behavior
  53. #endif
  54. Mesh& setNormals (); // recalculate vertex 3D normals
  55. Mesh& setTangents (); // recalculate vertex 3D tangents
  56. Mesh& setBinormals (); // recalculate vertex 3D binormals
  57. Mesh& setFaceNormals(); // recalculate triangle and quad 3D normals
  58. Mesh& setAutoTanBin (); // automatically calculate vertex tangents and binormals if needed, if they're not needed then they will be removed
  59. Bool setBox (Bool skip_hidden_parts=true); // recalculate bounding box, 'skip_hidden_parts'=if MeshParts with MSHP_HIDDEN should not be included in the box, returns false on fail
  60. #if EE_PRIVATE
  61. Mesh& setVtxColorAlphaAsTesselationIntensity(Bool tesselate_edges ); // set vertex color alpha (vtx.color.a) as tesselation intensity, 'tesselate_edges'=if tesselate non continuous edges
  62. Mesh& setVtxDup2D (UInt flag=0, Flt pos_eps=EPS, Flt nrm_cos=EPS_COL_COS); // set vertex 2D duplicates (vtx.dup)
  63. #endif
  64. Mesh& setVtxDup (UInt flag=0, Flt pos_eps=EPS, Flt nrm_cos=EPS_COL_COS); // set vertex 3D duplicates (vtx.dup)
  65. Mesh& setAdjacencies(Bool faces=true, Bool edges=false ); // set adjacencies, 'faces'=if set face adjacencies ('tri.adjFace', 'quad.adjFace'), 'edges'=if set edges ('edge') and edge adjacencies ('tri.adjEdge', 'quad.adjEdge', 'edge.adjFace')
  66. Mesh& delBase ( ); // delete all software meshes (MeshBase ) in this mesh
  67. Mesh& delRender( ); // delete all hardware meshes (MeshRender) in this mesh
  68. Mesh& setBase (Bool only_if_empty=true); // set software version, convert 'MeshRender' to 'MeshBase', 'only_if_empty'=perform conversion only if the MeshBase is empty (if set to false then conversion is always performed)
  69. Mesh& setRender(Bool optimize =true); // set rendering version, convert 'MeshBase' to 'MeshRender', 'optimize'=if optimize the mesh by re-ordering the vertexes/triangles for optimal processing on the GPU
  70. Mesh& setShader( ); // reset shader
  71. Mesh& material (C MaterialPtr &material); // set material, 'material' must point to object in constant memory address (mesh will store only the pointer to the material and later use it if needed), avoid changing materials real-time during rendering, instead consider using material variations (set them once, and later select which one to use with 'SetVariation' function)
  72. // join / split
  73. Mesh& join (Int i0, Int i1 , Flt weld_pos_eps=EPS); // join i0-th and i1-th parts together, 'weld_pos_eps'=epsilon used for welding vertexes after joining (use <0 to disable welding)
  74. Mesh& joinAll(Bool test_material, Bool test_draw_group, Bool test_name, UInt test_vtx_flag=0, Flt weld_pos_eps=EPS); // join all parts, 'test_material'=join only those MeshParts which have the same material, 'test_draw_group'=join only those MeshParts which have the same draw group, 'test_name'=join only those MeshParts which have the same name, 'test_vtx_flag'=join only those MeshParts which have same vertex flag, 'weld_pos_eps'=epsilon used for welding vertexes after joining (use <0 to disable welding)
  75. // transform
  76. Mesh& move ( C Vec &move ); // move
  77. Mesh& scale (C Vec &scale ); // scale
  78. Mesh& scaleMove (C Vec &scale, C Vec &move ); // scale and move
  79. Mesh& scaleMoveBase(C Vec &scale, C Vec &move ); // scale and move (including the 'MeshBase' but without 'MeshRender')
  80. Mesh& setSize (C Box &box ); // scale and move to fit box
  81. Mesh& transform (C Matrix3 &matrix ); // transform by matrix
  82. Mesh& transform (C Matrix &matrix ); // transform by matrix
  83. Mesh& animate (C MemPtrN<Matrix, 256> &matrixes ); // animate by matrixes
  84. Mesh& animate (C AnimatedSkeleton &anim_skel); // animate by skeleton
  85. Mesh& mirrorX ( ); // mirror in X axis
  86. Mesh& mirrorY ( ); // mirror in Y axis
  87. Mesh& mirrorZ ( ); // mirror in Z axis
  88. Mesh& reverse ( ); // reverse faces
  89. #if EE_PRIVATE
  90. Mesh& rightToLeft ( ); // convert from right hand to left hand coordinate system
  91. #endif
  92. // texture transform
  93. Mesh& texMove (C Vec2 &move , Byte tex_index=0); // move texture UV's
  94. Mesh& texScale (C Vec2 &scale, Byte tex_index=0); // scale texture UV's
  95. Mesh& texRotate( Flt angle, Byte tex_index=0); // rotate texture UV's
  96. #if EE_PRIVATE
  97. // texturize
  98. Mesh& texMap( Flt scale=1, Byte tex_index=0); // map texture UV's according to vertex XY position and scale
  99. Mesh& texMap(C Matrix &matrix , Byte tex_index=0); // map texture UV's according to matrix
  100. Mesh& texMap(C Plane &plane , Byte tex_index=0); // map texture UV's according to plane
  101. Mesh& texMap(C Ball &ball , Byte tex_index=0); // map texture UV's according to ball
  102. Mesh& texMap(C Tube &tube , Byte tex_index=0); // map texture UV's according to tube
  103. #endif
  104. // operations
  105. #if EE_PRIVATE
  106. Mesh& weldEdge (); // weld edges
  107. Mesh& weldVtx2D (UInt flag=0, Flt pos_eps=EPS, Flt nrm_cos=EPS_COL_COS, Flt remove_degenerate_faces_eps=EPS); // weld 2D vertexes , this function will weld vertexes together if they share the same position (ignoring Z), 'flag'=if selected elements aren't equal then don't weld (MESH_BASE_FLAG), 'remove_degenerate_faces_eps'=epsilon used for removing degenerate faces which may occur after welding vertexes (use <0 to disable removal)
  108. #endif
  109. Mesh& weldVtx (UInt flag=0, Flt pos_eps=EPS, Flt nrm_cos=EPS_COL_COS, Flt remove_degenerate_faces_eps=EPS); // weld 3D vertexes , this function will weld vertexes together if they share the same position , 'flag'=if selected elements aren't equal then don't weld (MESH_BASE_FLAG), 'remove_degenerate_faces_eps'=epsilon used for removing degenerate faces which may occur after welding vertexes (use <0 to disable removal)
  110. Mesh& weldVtxValues(UInt flag , Flt pos_eps=EPS, Flt nrm_cos=EPS_COL_COS, Flt remove_degenerate_faces_eps=EPS); // weld vertex values, this function will weld values of vertexes which share the same position , 'flag'= elements to weld (MESH_BASE_FLAG), 'remove_degenerate_faces_eps'=epsilon used for removing degenerate faces which may occur after welding vertexes (use <0 to disable removal)
  111. Mesh& tesselate(); // smooth subdivide faces, preserving original vertexes
  112. Mesh& subdivide(); // smooth subdivide faces, smoothing original vertexes
  113. Int boneFind (CChar8 *bone_name )C; // find bone by its name and return its index, -1 on fail
  114. Mesh& boneRemap(C MemPtr<Byte, 256> &old_to_new, Bool remap_names=true) ; // remap vertex bone/matrix indexes according to bone 'old_to_new' remap, 'remap_names'=if remap the bone names as well
  115. void setUsedBones(Bool (&bones)[256])C;
  116. void includeUsedBones(Bool (&bones)[256])C;
  117. Mesh& setVtxAO(Flt strength, Flt bias, Flt max, Flt ray_length, Flt pos_eps=EPS, Int rays=1024, MESH_AO_FUNC func=MAF_FULL, Threads *threads=null); // calculate per-vertex ambient occlusion in vertex colors, 'strength'=0..1 AO strength, 'bias'=0..1, 'max'=AO limit 0..1, 'ray_length'=max ray distance to test, 'rays'=number of rays to use for AO calculation, 'func'=falloff function
  118. Mesh& freeOpenGLESData(); // this method is used only under OpenGL ES (on other platforms it is ignored), the method frees the software copy of the GPU data which increases available memory, however after calling this method the data can no longer be accessed on the CPU (can no longer be locked or saved to file)
  119. // variations
  120. Mesh& variations (Int variations ); Int variations ( )C; // set/get number of material variations (meshes always have at least 1 material variation)
  121. Mesh& variationName (Int variation, C Str8 &name ); CChar8* variationName(Int i )C; // set/get material variation name (first material variation always has name = null and it can't be changed)
  122. UInt variationID (Int i )C; // get material variation ID (first material variation always has ID = 0 and it can't be changed, other variation ID's are always assigned to a random number when the variation is being created, so that each variation has a unique ID)
  123. Int variationFind(CChar8 *name)C; // find index of material variation which name is equal to 'name', -1 is returned if variation was not found
  124. Int variationFind(UInt id )C; // find index of material variation which ID is equal to 'id' , -1 is returned if variation was not found
  125. Mesh& variationKeep (Int variation ); // keep specified 'variation' and remove all others
  126. Mesh& variationRemove (Int variation ); // remove specified 'variation'
  127. Mesh& variationMove (Int variation, Int new_index); // move specified 'variation' to a 'new_index'
  128. Mesh& variationInclude(C Mesh &src ); // include variation names from 'src' if they don't exist in this mesh yet, this does not setup existing mesh part variation materials
  129. // fix
  130. Mesh& fixTexOffset (Byte tex_index=0); // fix texture offset , this reduces big texture coordinates to small ones increasing texturing quality on low precision video cards
  131. Mesh& fixTexWrapping(Byte tex_index=0); // fix texture wrapping, fixes texture coordinates created by spherical/tube mapping (this can add new vertexes to the mesh)
  132. // convert
  133. Mesh& edgeToDepth(Bool tex_align =true ); // edges to depth (extrude 2D edges to 3D faces)
  134. Mesh& edgeToTri (Bool set_id =false ); // edges to triangles (triangulation)
  135. Mesh& triToQuad (Flt cos =EPS_COL_COS); // triangles to quads , 'cos'=minimum cosine between 2 triangle normals to weld them into 1 quad (0..1)
  136. Mesh& quadToTri (Flt cos =2 ); // quads to triangles, 'cos'=minimum cosine between 2 quad triangle normals to leave them as 1 quad (0..1, value >1 converts all quads into triangles)
  137. // add / remove
  138. Mesh& add (C MeshBase &src ); // add MeshBase to self
  139. Mesh& add (C MeshPart &src ); // add MeshPart to self
  140. Mesh& add (C Mesh &src ); // add Mesh to self
  141. Mesh& remove(Int i, Bool set_box=true); // remove i-th MeshPart, 'set_box'=if recalculate bounding box
  142. MeshLod& newLod( ); // add empty MeshLod
  143. MeshLod& newLod(Int i); // add empty MeshLod at i lod index
  144. Mesh & removeLod(Int i); // remove i-th MeshLod
  145. Mesh & setLods(Int n); // set n levels of MeshLod's, new lods will be empty
  146. // optimize
  147. #if EE_PRIVATE
  148. Mesh& sortByMaterials (); // sort MeshParts according to their materials
  149. Mesh& removeDoubleEdges();
  150. Mesh& removeSingleFaces(Flt fraction ); // remove fraction of single faces (single triangles or quads not linked to any other face), 'fraction'=0..1
  151. Mesh& weldInlineEdges (Flt cos_edge=EPS_COL_COS, Flt cos_vtx=-1, Bool z_test=true); // weld inline edge vertexes, 'cos_edge'=minimum cosine between edge normals, 'cos_vtx'=minimum cosine between vertex normals, 'z_test'=if perform tests for inline 'z' vertex component
  152. #endif
  153. Mesh& removeDegenerateFaces(Flt eps=EPS);
  154. Bool removeUnusedVtxs (Bool include_edge_references=true, Bool set_box=true); // remove vertexes which aren't used by any face or edge, if 'include_edge_references' is set to false then only face references are tested (without the edges), 'set_box'=if recalculate bounding box upon vertex removal, returns true if any vertex was removed
  155. Mesh& simplify(Flt intensity, Flt max_distance=1.0f, Flt max_uv=1.0f, Flt max_color=0.02f, Flt max_material=0.02f, Flt max_skin=1, Flt max_normal=PI, Bool keep_border=false, MESH_SIMPLIFY mode=SIMPLIFY_QUADRIC, Flt pos_eps=EPS, Mesh *dest=null, Bool *stop=null); // simplify mesh by removing vertexes/faces, 'intensity'=how much to simplify (0..1, 0=no simplification, 1=full simplification), 'max_distance'=max distance between elements to merge them (0..Inf), 'max_uv'=max allowed vertex texture UV deviations (0..1), 'max_color'=max allowed vertex color deviations (0..1), 'max_material'=max allowed vertex material deviations (0..1), 'max_skin'=max allowed vertex skin deviations (0..1), 'max_normal'=max allowed vertex normal angle deviations (0..PI), 'keep_border'=if always keep border edges (edges that have faces only on one side), 'pos_eps'=vertex position epsilon, 'dest'=destination MeshBase (if set to null then the mesh will simplify itself), 'stop'=set to 'true' on secondary thread to stop this method, returns dest
  156. Mesh& weldCoplanarFaces(Flt cos_face=EPS_COL_COS, Flt cos_vtx=-1, Bool safe=true, Flt max_face_length=-1); // weld coplanar faces, 'cos_face'=minimum cosine between face normals, 'cos_vtx'=minimum cosine between vertex normals, 'safe'=if process only faces without neighbors, 'max_face_length'=max allowed face length (-1=no limit)
  157. // draw
  158. // default drawing, doesn't use automatic Frustum Culling, this doesn't draw the mesh immediately, instead it adds the mesh to a draw list
  159. void draw(C Matrix &matrix, C Vec &vel, C Vec &ang_vel=VecZero)C; // add mesh to draw list using 'matrix' matrix, 'vel' velocity and 'ang_vel' angular velocity, this should be called only in RM_PREPARE, when used it will automatically draw meshes in following modes when needed: RM_EARLY_Z RM_SIMPLE RM_SOLID RM_SOLID_M RM_AMBIENT RM_BLEND
  160. void draw(C MatrixM &matrix, C Vec &vel, C Vec &ang_vel=VecZero)C; // add mesh to draw list using 'matrix' matrix, 'vel' velocity and 'ang_vel' angular velocity, this should be called only in RM_PREPARE, when used it will automatically draw meshes in following modes when needed: RM_EARLY_Z RM_SIMPLE RM_SOLID RM_SOLID_M RM_AMBIENT RM_BLEND
  161. void draw(C Matrix &matrix )C; // add mesh to draw list using 'matrix' matrix and no velocities , this should be called only in RM_PREPARE, when used it will automatically draw meshes in following modes when needed: RM_EARLY_Z RM_SIMPLE RM_SOLID RM_SOLID_M RM_AMBIENT RM_BLEND
  162. void draw(C MatrixM &matrix )C; // add mesh to draw list using 'matrix' matrix and no velocities , this should be called only in RM_PREPARE, when used it will automatically draw meshes in following modes when needed: RM_EARLY_Z RM_SIMPLE RM_SOLID RM_SOLID_M RM_AMBIENT RM_BLEND
  163. void draw(C AnimatedSkeleton &anim_skel )C; // add mesh to draw list using 'anim_skel' matrixes and velocities , this should be called only in RM_PREPARE, when used it will automatically draw meshes in following modes when needed: RM_SIMPLE RM_SOLID RM_SOLID_M RM_AMBIENT RM_BLEND, 'anim_skel' must point to constant memory address (the pointer is stored through which the object can be accessed later during frame rendering)
  164. void draw(C AnimatedSkeleton &anim_skel, C Material &material )C; // add mesh to draw list using 'anim_skel' matrixes and velocities , this should be called only in RM_PREPARE, when used it will automatically draw meshes in following modes when needed: RM_SIMPLE RM_SOLID RM_SOLID_M RM_AMBIENT RM_BLEND, 'anim_skel' must point to constant memory address (the pointer is stored through which the object can be accessed later during frame rendering), 'material'=material used for rendering which overrides the default material, however for performance reasons, the default shader is used, which means that the 'material' should be similar to the default material, and if it's too different then some artifacts can occur
  165. void drawShadow(C Matrix &matrix )C; // add mesh to shadow draw list using 'matrix' matrix , this should be called only in RM_SHADOW
  166. void drawShadow(C MatrixM &matrix )C; // add mesh to shadow draw list using 'matrix' matrix , this should be called only in RM_SHADOW
  167. void drawShadow(C AnimatedSkeleton &anim_skel )C; // add mesh to shadow draw list using 'anim_skel' skeleton, this should be called only in RM_SHADOW, 'anim_skel' must point to constant memory address (the pointer is stored through which the object can be accessed later during frame rendering)
  168. void drawShadow(C AnimatedSkeleton &anim_skel, C Material &material)C; // add mesh to shadow draw list using 'anim_skel' skeleton, this should be called only in RM_SHADOW, 'anim_skel' must point to constant memory address (the pointer is stored through which the object can be accessed later during frame rendering), 'material'=material used for rendering which overrides the default material, however for performance reasons, the default shader is used, which means that the 'material' should be similar to the default material, and if it's too different then some artifacts can occur
  169. // draw blended, this is an alternative to default 'draw' (typically 'draw' draws blended meshes automatically for materials with technique in blend mode), this method however draws the mesh immediately (which allows to set custom shader parameters per draw call), it always uses blend shaders regardless if the material has technique set in blend mode, and provides additional control over material color, this can be called only in RM_BLEND rendering mode, doesn't use automatic Frustum culling
  170. void drawBlend( C Vec4 *color=null)C; // draw with current matrix , 'color'=pointer to optional Material color multiplication
  171. void drawBlend(C MatrixM &matrix, C Vec &vel=VecZero, C Vec &ang_vel=VecZero, C Vec4 *color=null)C; // draw with 'matrix' matrix , 'vel' velocity and 'ang_vel' angular velocity, 'color'=pointer to optional Material color multiplication
  172. void drawBlend(C AnimatedSkeleton &anim_skel, C Vec4 *color=null)C; // draw with 'anim_skel' matrixes, 'color'=pointer to optional Material color multiplication
  173. // draw mesh outline, this can be optionally called in RM_OUTLINE in order to outline the mesh, doesn't use automatic Frustum culling
  174. void drawOutline(C Color &color )C; // draw with current matrix
  175. void drawOutline(C Color &color, C MatrixM &matrix )C; // draw with 'matrix' matrix
  176. void drawOutline(C Color &color, C AnimatedSkeleton &anim_skel)C; // draw with 'anim_skel' matrixes
  177. // draw using the "behind" effect, this can be optionally called in RM_BEHIND, doesn't use automatic Frustum culling, 'color_perp'=color to be used for normals perpendicular to camera, 'color_parallel'=color to be used for normals parallel to camera
  178. void drawBehind(C Color &color_perp, C Color &color_parallel )C; // draw with current matrix
  179. void drawBehind(C Color &color_perp, C Color &color_parallel, C MatrixM &matrix )C; // draw with 'matrix' matrix
  180. void drawBehind(C Color &color_perp, C Color &color_parallel, C AnimatedSkeleton &anim_skel)C; // draw with 'anim_skel' matrixes
  181. // io
  182. void operator=(C Str &name) ; // load, Exit on fail
  183. Bool save (C Str &name)C; // save, false on fail
  184. Bool load (C Str &name) ; // load, false on fail
  185. Bool save ( File &f, CChar *path=null)C; // save, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  186. Bool load ( File &f, CChar *path=null) ; // load, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  187. #if EE_PRIVATE
  188. Bool saveTxt (C Str &name )C; // save text , false on fail
  189. Bool loadTxt (C Str &name ) ; // load text , false on fail
  190. Bool saveTxt (FileText &f, CChar *path=null)C; // save text , 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  191. Bool loadTxt (FileText &f, CChar *path=null) ; // load text , 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  192. Bool saveData(File &f, CChar *path=null)C; // save binary, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  193. Bool loadData(File &f, CChar *path=null) ; // load binary, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  194. #endif
  195. void operator*=(C Matrix3 &m ) {transform(m );} // transform by matrix
  196. void operator*=(C Matrix &m ) {transform(m );} // transform by matrix
  197. void operator+=(C MeshBase &mshb) {add (mshb);} // add MeshBase
  198. void operator+=(C MeshPart &part) {add (part);} // add MeshPart
  199. void operator+=(C Mesh &mesh) {add (mesh);} // add Mesh
  200. ~Mesh() {del();}
  201. Mesh();
  202. #if !EE_PRIVATE
  203. private:
  204. #endif
  205. struct Variations
  206. {
  207. #if EE_PRIVATE
  208. Bool is()C {return _variations>0;} // if has any data
  209. Int alloc(Int variations, Int name_size);
  210. Int nameSize ( )C; // get size needed for variation names
  211. Char8* nameStart( )C; // get start of the variation name memory
  212. CChar8* name (Int i)C; // get i-th variation name
  213. UInt id (Int i)C; // get i-th variation id
  214. Bool save(File &f)C;
  215. Bool load(File &f) ;
  216. struct Variation
  217. {
  218. UInt id;
  219. Int name_offset;
  220. };
  221. Variation *_variation; // right after '_variation' array, array of variation names is allocated (in Char8 mode)
  222. #else
  223. Ptr _variation;
  224. #endif
  225. Int _variations;
  226. void del();
  227. ~Variations() {del();}
  228. Variations() {_variation=null; _variations=0;}
  229. Variations(C Variations &src);
  230. void operator=(C Variations &src);
  231. };
  232. Skeleton *_skeleton;
  233. Enum *_draw_group_enum;
  234. Mems<MeshLod> _lods;
  235. BoneMap _bone_map;
  236. Variations _variations;
  237. };
  238. /******************************************************************************/
  239. DECLARE_CACHE(Mesh, Meshes, MeshPtr); // 'Meshes' cache storing 'Mesh' objects which can be accessed by 'MeshPtr' pointer
  240. inline Int Elms(C Mesh &mesh) {return mesh.parts.elms();}
  241. #if EE_PRIVATE
  242. void InitMesh();
  243. #endif
  244. /******************************************************************************/