3ds Max USD API Reference
Loading...
Searching...
No Matches
MeshFacade.h
1//**************************************************************************/
2// Copyright (c) 2021 Autodesk, Inc.
3// All rights reserved.
4//
5// Use of this software is subject to the terms of the Autodesk license
6// agreement provided at the time of installation or download, or which
7// otherwise accompanies this software in either electronic or hard copy form.
8//**************************************************************************/
9// DESCRIPTION: A facade to work with the 3dsMax Mesh and MNMesh classes transparently.
10// AUTHOR: Autodesk Inc.
11//**************************************************************************/
12
13#pragma once
14
15#include <MeshNormalSpec.h>
16#include <mnmesh.h>
17#include <mesh.h>
18
19#include "MaxUsd/MaxUSDAPI.h"
20#include "MaxUsd.h"
21
22namespace MAXUSD_NS_DEF {
23
30{
31public:
32
33 MeshFacade() = delete;
34 MaxUSDAPI explicit MeshFacade(MNMesh*, bool ownMesh = false);
35 MaxUSDAPI explicit MeshFacade(Mesh*, bool ownMesh = false);
36
37 MaxUSDAPI ~MeshFacade();
38
39 // Mesh data :
40 MaxUSDAPI int VertexCount() const;
41 MaxUSDAPI const Point3& Vertex(int i) const;
42 MaxUSDAPI int FaceCount() const;
43 MaxUSDAPI int FaceDegree(int faceIdx) const;
44 MaxUSDAPI int FaceVertex(int faceIdx, int cornerIdx) const;
45 MaxUSDAPI bool FaceIsDead(int faceIdx) const;
46
47 MaxUSDAPI std::shared_ptr<std::vector<int>> FaceIndices();
48
49 // Returns the sum of all face's degrees.
50 MaxUSDAPI int FaceVertexIndicesCount();
51
52 MaxUSDAPI DWORD GetAllSmGroups() const;
53
54 MaxUSDAPI void LoadNormals();
55 MaxUSDAPI int NormalCount() const;
56 MaxUSDAPI const Point3* NormalData() const;
57 MaxUSDAPI const std::shared_ptr<std::vector<int>> NormalIndices() const;
58
59 // Map channel data :
60 MaxUSDAPI int MapCount() const;
61 MaxUSDAPI int MapFaceCount(int channel) const;
62 MaxUSDAPI int MapFaceDegree(int channel, int faceIdx) const;
63 MaxUSDAPI int MapFaceVertex(int channel, int faceIdx, int cornerIdx) const;
64 MaxUSDAPI const Point3* MapData(int channel) const;
65 MaxUSDAPI int MapDataCount(int channel) const;
66
67 // Material assignment.
68 MaxUSDAPI MtlID FaceMaterial(int faceIdx) const;
69
70 // Vertex and Edge creasing :
71 MaxUSDAPI bool HasCreaseSupport() const;
72 // Currently only properly implemented for MNMesh, Mesh doesn't maintain an
73 // edge list (although it can be computed separately).
74 MaxUSDAPI int EdgeCount() const;
75 MaxUSDAPI int EdgeVertex(int edgeIdx, bool start) const;
76 MaxUSDAPI const float* VertexCreaseData() const;
77 MaxUSDAPI const float* EdgeCreaseData() const;
78
79 MaxUSDAPI void Transform(Matrix3& transform) const;
80 MaxUSDAPI void MakePlanar(float planarTresh) const;
81 MaxUSDAPI void MakeConvex() const;
82 MaxUSDAPI void Cleanup() const;
83 MaxUSDAPI Box3 BoundingBox() const;
84 MaxUSDAPI void Triangulate() const;
85
86protected:
87 MNMesh* polyMesh = nullptr;
88 Mesh* triMesh = nullptr;
89 bool ownMesh = false;
90
91 // Cache..
92 std::shared_ptr<std::vector<int>> faceIndices;
93 std::shared_ptr<std::vector<int>> normalsIndices;
94 int faceVertexIndicesCountCache = -1;
95};
96
97}
A facade to work with the 3dsMax Mesh and MNMesh classes transparently. Does some caching internally ...
Definition: MeshFacade.h:30