3DCoatScripting  4.8.31β
С помощью скриптинга можно управлять возможностями Коута и расширять его функционал.
Класс comms::cMeshContainer

General class for work with mesh. Подробнее...

Классы

struct  PlaneArgs
 See GenPlane. Подробнее...
 

Открытые типы

typedef cList< cVec3 > figure_t
 
typedef cList< int > figureI_t
 
typedef cList< figure_t > figures_t
 
typedef cList< figureI_t > figuresI_t
 
typedef DWORDS2 edgeI_t
 
typedef void MeshOpHook (cMeshContainer *mc, const char *filename)
 

Открытые члены

 cMeshContainer ()
 
 cMeshContainer (const figures_t &, float fusionDistance)
 Build a correct mesh by set of figures. Подробнее...
 
 cMeshContainer (const cMeshContainer &)
 
cMeshContaineroperator= (const cMeshContainer &)
 
bool operator== (const cMeshContainer &) const
 
bool IsValid (const bool ShowWarning=false) const
 
bool IsValidRawSequence () const
 Verify the error (from Blender by import OBJ): "the same vertex of face used multiple times". Подробнее...
 
void Clear ()
 
void Copy (const cMeshContainer &src)
 
const cStr & GetName () const
 
void SetName (const char *Name)
 
const cList< cVec3 > & GetPositions () const
 
cList< cVec3 > & GetPositions ()
 
const cVec3 & GetPosition (int vertex) const
 
void SetPosition (int vertex, const cVec3 &)
 
int GetVertex (const cVec3 &) const
 
const cList< DWORD > & GetVertexColor () const
 
cList< DWORD > & GetVertexColor ()
 
const cList< DWORD > & GetVertexSpecular () const
 
cList< DWORD > & GetVertexSpecular ()
 
const cList< DWORD > & GetVertexEmissive () const
 
cList< DWORD > & GetVertexEmissive ()
 
const cList< cVec2 > & GetTexCoords () const
 
cList< cVec2 > & GetTexCoords ()
 
const cList< cVec3 > & GetNormals () const
 
cList< cVec3 > & GetNormals ()
 
const cVec3 & GetNormal (int vertex) const
 
void SetNormal (int vertex, const cVec3 &)
 
const cList< cVec< cVec3, 2 > > & GetTangents () const
 
cList< cVec< cVec3, 2 > > & GetTangents ()
 
const cList< cVec3i > & GetRaw () const
 
cList< cVec3i > & GetRaw ()
 
const cList< cSurface > & GetMaterials () const
 
cList< cSurface > & GetMaterials ()
 
const cList< PtexQuad > & GetPtex () const
 
cList< PtexQuad > & GetPtex ()
 
const cList< cUVSet > & GetUVSets () const
 
cList< cUVSet > & GetUVSets ()
 
const cList< cObject > & GetObjects () const
 
cList< cObject > & GetObjects ()
 
const cList< cVMapElm > & GetVMaps () const
 
cList< cVMapElm > & GetVMaps ()
 
const cList< cVMapType > & GetVMTypes () const
 
cList< cVMapType > & GetVMTypes ()
 
int GetPolyCount () const
 
int GetTrisCount () const
 
cList< int > GetNeighboursForFace (int beginRawFigure, cVec3 *avgNormal=NULL, cVec3 *avgCenter=NULL) const
 
bool Contains (const cVec3 &) const
 
bool Contains (int a) const
 
bool Contains (const cVec3 &a, const cVec3 &b) const
 
bool Contains (int a, int b) const
 
bool Contains (const cList< cVec3 > &figure) const
 
bool Contains (const cList< int > &figure) const
 
bool IsTriangulated () const
 
void Triangulate (cList< cVec3i > &TriRaw) const
 
void Triangulate ()
 
void CalcNormals ()
 
void CalcSplitNormals (cList< int > &SeamsList)
 
void InvertRaw ()
 
void ConcateWith (const cMeshContainer *mc)
 
void Textures2VColor ()
 
void RemoveUnusedObjMtl ()
 
void RemoveUnusedVerts (cList< int > *encoding=NULL)
 
template<bool withErase>
::std::pair< cVec3, cVec3 > Divide (int a, int b, float tAB, int c, int d, float tCD, int *beginRemovedRawBlock=NULL, int *sizeRemovedRawBlock=NULL,::std::pair< int, int > *changedBeginRawBlock=NULL)
 Divide a figure on two parts with declared line. Подробнее...
 
template<bool withErase>
void Divide (int a, int b, const cVec3 &m, int c, int d, const cVec3 &n, int *beginRemovedRawBlock=NULL, int *sizeRemovedRawBlock=NULL,::std::pair< int, int > *changedBeginRawBlock=NULL)
 
void Erase (int beginRawFigure, bool withOptimize=false)
 Remove a point / line / polygon (represent as raw-block) from this mesh. Подробнее...
 
void Erase (const cList< int > &beginRawFigures, bool withOptimize=false)
 
void EraseByCount (int n)
 Remove raw-blocks which a count of vertices is equal n.
 
void EraseByCount (int a, int b)
 Remove raw-blocks which a count of vertices in the diapason [a; b].
 
void EraseClearConfluent (float tolerance)
 Remove figures which all vertices are confluent to line. Подробнее...
 
void EraseClearConfluentByIndexOnly ()
 Verify only indices of vertices.
 
void Invert (int beginRawFigure)
 Invert a figure. Подробнее...
 
cList< int > Find (const cVec3 &nodeCoord) const
 
cList< int > Find (int nodeIndex) const
 
cList< int > Find (const cVec3 &edgeCoordA, const cVec3 &edgeCoordB) const
 
cList< int > Find (int ai, int bi) const
 
cList< int > Find (const edgeI_t &) const
 
cList< int > Find (const edgeI_t &, const edgeI_t &) const
 
int Find (const cList< cVec3 > &figure) const
 
int Find (const cList< int > &figure) const
 
cList< int > FindClearConfluent (float tolerance) const
 
void CorrectFaces (int beginRawBlockEtalon, uni_hash< bool, int > *fixed=NULL)
 Fixed a direction for every face by neighbours. Подробнее...
 
void CorrectRawSequence ()
 Fixed the error (from Blender by import OBJ): "the same vertex of face used multiple times". Подробнее...
 
void MergeFaces (float fusionDistance)
 Merge faces of mesh which side by side. Подробнее...
 
int Insert (int a, int b, float t, cList< int > *beginRawFigures=NULL, cList< int > *beginRawForRemoved=NULL)
 Insert vertext on the line 'ab' (as verticies). Подробнее...
 
int Insert (int a, int b, const cVec3 &m, cList< int > *beginRawFigures=NULL, cList< int > *beginRawForRemoved=NULL)
 
void Insert (const figureI_t &, int *beginRawFigure=NULL)
 Insert a figure (index of verticies) into the mesh.
 
figureI_t Insert (int a, int *beginRawFigure=NULL)
 Insert a point.
 
figureI_t Insert (int a, int b, int *beginRawFigure=NULL)
 Insert a line.
 
figureI_t Insert (int a, int b, int c, int *beginRawFigure=NULL)
 Insert a triangle.
 
figureI_t Insert (int a, int b, int c, int d, int *beginRawFigure=NULL)
 Insert a polygon with 4 vertices.
 
void Insert (const figures_t &, float fusionDistance=-FLT_MAX)
 Insert a set of figures (positions of verticies) into the mesh. Подробнее...
 
void Insert (const figure_t &, figureI_t *=NULL)
 Insert a figure (positions of verticies) into the mesh. Подробнее...
 
figure_t Insert (const cVec3 &a, int *ai=NULL)
 Insert a point.
 
figure_t Insert (const cVec3 &a, const cVec3 &b, int *ai=NULL, int *bi=NULL)
 Insert a line.
 
figure_t Insert (const cVec3 &a, const cVec3 &b, const cVec3 &c, int *ai=NULL, int *bi=NULL, int *ci=NULL)
 Insert a triangle.
 
figure_t Insert (const cVec3 &a, const cVec3 &b, const cVec3 &c, const cVec3 &d, int *ai=NULL, int *bi=NULL, int *ci=NULL, int *di=NULL)
 Insert a polygon with 4 vertices.
 
void Insert (const cMeshContainer &)
 Insert a mesh to this mesh. Подробнее...
 
bool IsClearConfluent (const figure_t &, float tolerance) const
 
bool IsClearConfluent (int beginRawFigure, float tolerance) const
 
bool IsClearConfluentByIndexOnly (int beginRawFigure) const
 Verify only indices of vertices. Подробнее...
 
bool IsClockwiseOrder (int beginRawFigure, const cVec3 &observer) const
 
bool PerformBooleanOp (cMeshContainer &src1, cMeshContainer &src2, int operation, cList< ::std::pair< comms::cVec3, comms::cVec3 > > *dividers=NULL)
 Build mesh from 'src1' and 'src2' to 'this'. Подробнее...
 
void CreateCube (const cVec3 &Sides)
 
void CreateQuadCylinder (const cMat4 &M, float quant, float rtop=1.0, float rbottom=1.0, float Height=2.0)
 
void CreateQuadCylinder (float quant, cVec3 PTop, cVec3 PBottom, float rTop, float rBottom)
 
void MakeShell (float Out, float In, float OutEdge, float InEdge, int ndiv=1, cList< cVec2 > *EdgeShape=NULL)
 
void MakeShellDir (float Out, float In, cVec3 Dir)
 
void LeaveBiggestPiece ()
 
void QuadQuantSubd (const cMat4 &M, float quant, float dotp)
 Try to divide all quads in approx equal sub-quads.
 
void TriSubd (int N, SubdSnapEdgeCallback *dive=NULL, SubdSnapMiddlePointCallback *divm=NULL, void *context=NULL)
 Divide triangular mesh on N^2 triangles.
 
void Transform (const cMat4 &M)
 
void SetDefaultObjMtl ()
 
void Symmetry (cVec3 pos, cVec3 n, bool Quads, bool RemoveOpp, float ToleranceCoef=0.0)
 
void WeldedSymmetry (cVec3 pos, cVec3 n, bool RemoveOpp, float ToleranceCoef=0.0, float WeldCoef=0.0)
 
void Smooth (float degree, bool tangent, int count=1, float sharpdot=0.3, UnlimitedBitset *pins=NULL, bool smoothedges=false)
 
void RelaxNormals (cList< cVec3 > &ResultNormals, int Count)
 
void SmoothFast (float degree, int count, UnlimitedBitset *pins, bool tangent)
 
void GetSharpEdges (cList< DWORDS2 > &List, float dotp)
 
void GetOpenEdges (cList< DWORDS2 > &List)
 
StaticMesh * CreateStaticMesh ()
 Creation for rendering. Подробнее...
 
StaticMesh * CreateStaticMeshMC ()
 Create mesh with smoothed normals and mcubes - like shader.
 
StaticMesh * CreateHardsurfaceStaticMesh ()
 Create faceted mesh. Shader mpreview1 used.
 
StaticMesh * CreateStaticMeshUV ()
 Create mstatic mesh with UV, skypreview shader used.
 
cVec3 GetFaceCoord (int pos) const
 
cVec3 GetFaceNormal (int pos) const
 
void SplitHardsurface (float angcos)
 
void SplitDisconnected (cList< cMeshContainer * > &res)
 
void CreateFone () const
 
void ClearFone () const
 
void CreateVnv (uni_hash< int, int > &vnv)
 
void FindCorners (cList< int > &corners)
 
void DrawDbg (const cMat4 &T, DWORD Color, DWORD FillColor=0, DWORD DetailColor=0)
 
void DbgDrawMeshWithUVGrid ()
 use this function within __thumbnail(...) section to visualuse mesh with UV, seek "__thumbnail(test1)" as example.
 
DWORD CalcGUID ()
 
float CalcVolume ()
 
float CalcSquare ()
 
cBounds CalcBoundBox ()
 
float CalcSquareMC ()
 
void CloseHoles (int MaxHoleSize, bool SkipMaximalHole)
 
void RemoveRedundantUV ()
 
void Weld (float distance, UnlimitedBitset *Selected=NULL)
 
void AutoWeldOpenEdges ()
 
void CutMesh (MeshCutter &mcut)
 
void CutByPlane (const cPlane &pl, cList< cVec3 > *cutverts=NULL)
 
void PlainSubdiv ()
 
float PickObject (cSeg &Ray, const cMat4 &M)
 
cVec3 CalcMeshProjSquare ()
 
cVec3 CalcMeshProjSquare (const cMat4 &M)
 
void ConvertPicToPolygones (cImage &Img, float Thickness, bool Normalize)
 
void ConvertPicToGridPolygones (cImage &Img, float Thickness, int nDiv, bool Normalize, bool DefAlign)
 
void ConvertPicToGridPolygonesWithTapering (cImage &ImgT, cImage &ImgB, float Thickness, int nDiv, bool Normalize, float Angle, float Weight)
 
void DivideMesh (MeshDivider< int > &) const
 Divide the mesh on two meshes (harvest vertices).
 
bool FlipEdge (int V1, int V2, int *valence=NULL)
 flip edge, requires fone, requires 2 faces over the edge.
 
bool OptimizeTriangularMesh ()
 tries to set valence 6 whenever possible unsing edge-flip
 
void PutOnGround (cMat4 &M, cVec3 &p, cVec3 &c)
 
void PutOnGround (cMat4 &M)
 
void LayOnGround (cMat4 &M)
 
void SeparateObject (int ObjectIndex, cMeshContainer *dest)
 
void ImproveQuadsTopology ()
 

Открытые статические члены

static void SetLoadMeshHook (MeshOpHook *h)
 
static void SetSaveMeshHook (MeshOpHook *h)
 
static cMeshContainerGenPlane (PlaneArgs=PlaneArgs())
 
static cMeshContainerGenPlaneHexagonal (const float Lx, const float Ly, const float Cell, const bool Noisy)
 

Открытые атрибуты

cList< OneMorph * > Morphs
 
uni_hash< int, DWORDS2 > fone
 

Статические открытые данные

static MeshOpHook * ImportHook
 
static MeshOpHook * ExportHook
 

Защищенные данные

cStr m_Name
 
cList< cVec3 > m_Positions
 
cList< cVec2 > m_TexCoords
 
cList< cVec3 > m_Normals
 
cList< cUVSet > m_UVSets
 
cList< cVec< cVec3, 2 > > m_Tangents
 Tangent and BiTangent.
 
cList< cVec3i > m_Raw
 
cList< cSurface > m_Materials
 
cList< cObject > m_Objects
 
cList< cVMapElm > m_VMaps
 
cList< cVMapType > m_VmTypes
 
cList< PtexQuad > m_Ptex
 
cList< DWORD > m_VertexColor
 
cList< DWORD > m_VertexSpecular
 RGB - specular color, A - glossness.
 
cList< DWORD > m_VertexEmissive
 

Подробное описание

General class for work with mesh.

Конструктор(ы)

comms::cMeshContainer::cMeshContainer ( )
Предупреждения
Call CreateDefaultObjMtl() manually for create a defaul object and material.
comms::cMeshContainer::cMeshContainer ( const figures_t &  ,
float  fusionDistance 
)

Build a correct mesh by set of figures.

Аргументы
fusionDistanceSee MergeFaces() for details.
См. также
Insert( figures_t )Edge

Методы

bool comms::cMeshContainer::IsValid ( const bool  ShowWarning = false) const
Возвращает
true when mesh is correct.
Необходимо сделать:
fine Move ShowWarning to configure of project or set always true when a debug-mode.
bool comms::cMeshContainer::IsValidRawSequence ( ) const

Verify the error (from Blender by import OBJ): "the same vertex of face used multiple times".

См. также
cMeshContainerTest::CorrectRawSequence*()
CorrectRawSequence()
const cVec3& comms::cMeshContainer::GetPosition ( int  vertex) const
Возвращает
Coord (position) by vertex (index of position).

First vertex of mesh is 0.

См. также
GetVertex()
int comms::cMeshContainer::GetVertex ( const cVec3 &  ) const
Возвращает
Vertex (index of position) by coord (position).
См. также
GetPosition()
const cList<cVec3>& comms::cMeshContainer::GetNormals ( ) const
inline
См. также
GetNormal(), GetFaceNormal(), GetFaceCoord()
const cVec3& comms::cMeshContainer::GetNormal ( int  vertex) const
Возвращает
Normal by vertex (index of normal).
Предупреждения
Use CalcNormals() for correct result.
См. также
GetFaceNormal(), GetFaceCoord()
cList< int > comms::cMeshContainer::GetNeighboursForFace ( int  beginRawFigure,
cVec3 *  avgNormal = NULL,
cVec3 *  avgCenter = NULL 
) const
Возвращает
List of 'begin raw block' which blocks be adjacent to 'beginRawFigure'.
Also returns average normal and coord of center of neighbours of face.
См. также
Find()
bool comms::cMeshContainer::Contains ( const cVec3 &  ) const
Возвращает
Point has in the mesh.
bool comms::cMeshContainer::Contains ( const cVec3 &  a,
const cVec3 &  b 
) const
Возвращает
Edge ab has in the mesh.
bool comms::cMeshContainer::Contains ( const cList< cVec3 > &  figure) const
Возвращает
Figure has in the mesh. Verify by one direction only.
void comms::cMeshContainer::InvertRaw ( )
См. также
Invert()
template<bool withErase>
::std::pair< cVec3, cVec3 > comms::cMeshContainer::Divide ( int  a,
int  b,
float  tAB,
int  c,
int  d,
float  tCD,
int *  beginRemovedRawBlock = NULL,
int *  sizeRemovedRawBlock = NULL,
::std::pair< int, int > *  changedBeginRawBlock = NULL 
)

Divide a figure on two parts with declared line.

Возвращает
Coords for found points.
Template Parameters
withEraseTrue, when need delete a figure which divided.
Аргументы
a,b,c,dVertices of figure.
tAB,tCDNeppers of new vertices on the edges ab and cd.

When ab, cd are not of part of 1 (one!) figure, exception is throw.

template<bool withErase>
void comms::cMeshContainer::Divide ( int  a,
int  b,
const cVec3 &  m,
int  c,
int  d,
const cVec3 &  n,
int *  beginRemovedRawBlock = NULL,
int *  sizeRemovedRawBlock = NULL,
::std::pair< int, int > *  changedBeginRawBlock = NULL 
)
Аргументы
mPoint for insert between points ab.
nPoint for insert between points cd.
void comms::cMeshContainer::Erase ( int  beginRawFigure,
bool  withOptimize = false 
)

Remove a point / line / polygon (represent as raw-block) from this mesh.

Аргументы
beginRawFigureStart position of block in the GetRaw().
withOptimizeUnused coords of the mesh removed from the GetPositions().
См. также
Find() For example
Erase( Find( a, b ).GetFirst() );
void comms::cMeshContainer::EraseClearConfluent ( float  tolerance)

Remove figures which all vertices are confluent to line.

См. также
FindClearConfluent()
void comms::cMeshContainer::Invert ( int  beginRawFigure)

Invert a figure.

См. также
Find()
cList< int > comms::cMeshContainer::Find ( const cVec3 &  nodeCoord) const
Возвращает
Shifts in the GetRaw() of this mesh. This pointer consist of declared node or edge.
If node or edge is not found, when return an empty list.
См. также
GetNeighboursForFace(), Erase()
cList< int > comms::cMeshContainer::Find ( const edgeI_t &  ,
const edgeI_t &   
) const
Предупреждения
All defined edges must be parts of figure.
int comms::cMeshContainer::Find ( const cList< cVec3 > &  figure) const
Возвращает
See cList< int > Find(). If node or edge is not found, when return -1.
cList< int > comms::cMeshContainer::FindClearConfluent ( float  tolerance) const
Возвращает
List of raw-blocks which contains all fantom-figures (all vertices are confluent to line).
Аргументы
toleranceValue at angle for include a figure.
Предупреждения
All lines and points are confluent figure.
См. также
EraseClearConfluent()
void comms::cMeshContainer::CorrectFaces ( int  beginRawBlockEtalon,
uni_hash< bool, int > *  fixed = NULL 
)

Fixed a direction for every face by neighbours.

Возвращает
True, when any faces was corrected.
Аргументы
beginRawBlockEtalonStart of block for faces which was as etalon for "direction of all other face".
fixedList of 'beginRawFigure' when already fixed.
void comms::cMeshContainer::CorrectRawSequence ( )

Fixed the error (from Blender by import OBJ): "the same vertex of face used multiple times".

См. также
cMeshContainerTest::CorrectRawSequence*()
IsValidRawSequence()
void comms::cMeshContainer::MergeFaces ( float  fusionDistance)

Merge faces of mesh which side by side.

Аргументы
fusionDistanceDistance between vertex and edge when initiate a merge.
См. также
cMeshContainerTest.jpg, "K" or "H"
int comms::cMeshContainer::Insert ( int  a,
int  b,
float  t,
cList< int > *  beginRawFigures = NULL,
cList< int > *  beginRawForRemoved = NULL 
)

Insert vertext on the line 'ab' (as verticies).

Возвращает
Added vertex.
Аргументы
tDistance on the line as a nepper.
[ 0.0 (a) .. 0.5 (half of length 'ab') .. 1.0 (b) ]
beginRawFigureStarts of blocks when point or figure was inserted.
beginRawForRemovedStarts of blocks which clear confluented.
Необходимо сделать:
fine Change 'int' to 'typedef int vertex_t'.
int comms::cMeshContainer::Insert ( int  a,
int  b,
const cVec3 &  m,
cList< int > *  beginRawFigures = NULL,
cList< int > *  beginRawForRemoved = NULL 
)
Аргументы
mPoint for insert between points ab.
void comms::cMeshContainer::Insert ( const figures_t &  ,
float  fusionDistance = -FLT_MAX 
)

Insert a set of figures (positions of verticies) into the mesh.

Аргументы
fusionDistanceCall MergeFaces() when this param is positive or zero.
См. также
construct( figures_t )
void comms::cMeshContainer::Insert ( const figure_t &  ,
figureI_t *  = NULL 
)

Insert a figure (positions of verticies) into the mesh.

Added coords are not containes dublicates.
Use MergeFaces() for fixed faces after insert positions.

Аргументы
figureI_tAccumulte indices of vertices when defined.
ai,bi,...By analogy of 'figureI_t'.
void comms::cMeshContainer::Insert ( const cMeshContainer )

Insert a mesh to this mesh.

Vertices are not dublicate.

См. также
ConcateWith()
bool comms::cMeshContainer::IsClearConfluent ( const figure_t &  ,
float  tolerance 
) const
Возвращает
True when 'beginRawFigure' contains a figure which all vertices are confluent to line.
Аргументы
toleranceValue at angle for detect figure as confluent to line.
Предупреждения
All lines and points are confluent figure.
См. также
FindClearConfluent(), EraseClearConfluent()
bool comms::cMeshContainer::IsClearConfluentByIndexOnly ( int  beginRawFigure) const

Verify only indices of vertices.

См. также
IsClearConfluent()
bool comms::cMeshContainer::IsClockwiseOrder ( int  beginRawFigure,
const cVec3 &  observer 
) const
Возвращает
true when line / face is clockwise order.
false when 'beginRawFigure' aim to point.
bool comms::cMeshContainer::PerformBooleanOp ( cMeshContainer src1,
cMeshContainer src2,
int  operation,
cList< ::std::pair< comms::cVec3, comms::cVec3 > > *  dividers = NULL 
)

Build mesh from 'src1' and 'src2' to 'this'.

Аргументы
operationVariants:
  • 0 - add
  • 1 - subtract src1 - src2
  • 2 - intersect src1 & src2
StaticMesh* comms::cMeshContainer::CreateStaticMesh ( )

Creation for rendering.

Create mesh with smoothed normals. Shader mpreview1 used.

cVec3 comms::cMeshContainer::GetFaceCoord ( int  pos) const
См. также
GetNormal()
void comms::cMeshContainer::DrawDbg ( const cMat4 &  T,
DWORD  Color,
DWORD  FillColor = 0,
DWORD  DetailColor = 0 
)
Предупреждения
If mesh is not triangulated when DrawDbg() is incorrect.

Данные класса

cList<cVec3i> comms::cMeshContainer::m_Raw
protected

Polygon info or 3 references to the arrays of positions, texture coordinates, and normals with tangents (optional) respectively.

Info0 = { Count0, idMtl, idObj } idMtl =
Indices_0 = { iPosition, iTexCoord, iNormal (iTangent) }
...
Indices_(Count0 - 1)
Info1
...