MaterialX 1.38.9
Loading...
Searching...
No Matches
GeometryHandler.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_GEOMETRYHANDLER_H
7#define MATERIALX_GEOMETRYHANDLER_H
8
11
14
16
17#include <map>
18
19MATERIALX_NAMESPACE_BEGIN
20
22using GeometryLoaderPtr = std::shared_ptr<class GeometryLoader>;
23
27class MX_RENDER_API GeometryLoader
28{
29 public:
31 {
32 }
33 virtual ~GeometryLoader() { }
34
38 {
39 return _extensions;
40 }
41
47 virtual bool load(const FilePath& filePath, MeshList& meshList, bool texcoordVerticalFlip = false) = 0;
48
49 protected:
50 // List of supported string extensions
51 StringSet _extensions;
52};
53
55using GeometryHandlerPtr = std::shared_ptr<class GeometryHandler>;
56
58using GeometryLoaderMap = std::multimap<string, GeometryLoaderPtr>;
59
63class MX_RENDER_API GeometryHandler
64{
65 public:
67 {
68 }
69 virtual ~GeometryHandler() { }
70
73 {
74 return std::make_shared<GeometryHandler>();
75 }
76
79 void addLoader(GeometryLoaderPtr loader);
80
82 void supportedExtensions(StringSet& extensions);
83
85 void clearGeometry();
86
87 // Determine if any meshes have been loaded from a given location
88 bool hasGeometry(const string& location);
89
90 // Find all meshes loaded from a given location
91 void getGeometry(MeshList& meshes, const string& location);
92
96 bool loadGeometry(const FilePath& filePath, bool texcoordVerticalFlip = false);
97
99 const MeshList& getMeshes() const
100 {
101 return _meshes;
102 }
103
106 MeshPtr findParentMesh(MeshPartitionPtr part);
107
110 {
111 return _minimumBounds;
112 }
113
116 {
117 return _maximumBounds;
118 }
119
121 static MeshPtr createQuadMesh(const Vector2& uvMin = Vector2(0.0f, 0.0f),
122 const Vector2& uvMax = Vector2(1.0f, 1.0f),
123 bool flipTexCoordsHorizontally = false);
124
125 protected:
126 // Recompute bounds for all stored geometry
127 void computeBounds();
128
129 protected:
130 GeometryLoaderMap _geometryLoaders;
131 MeshList _meshes;
132 Vector3 _minimumBounds;
133 Vector3 _maximumBounds;
134};
135
136MATERIALX_NAMESPACE_END
137
138#endif
Cross-platform support for file and search paths.
std::multimap< string, GeometryLoaderPtr > GeometryLoaderMap
Map of extensions to image loaders.
Definition: GeometryHandler.h:58
std::shared_ptr< class GeometryLoader > GeometryLoaderPtr
Shared pointer to a GeometryLoader.
Definition: GeometryHandler.h:22
std::shared_ptr< class GeometryHandler > GeometryHandlerPtr
Shared pointer to an GeometryHandler.
Definition: GeometryHandler.h:55
std::set< string > StringSet
A set of strings.
Definition: Library.h:61
Macros for declaring imported and exported symbols.
Mesh interfaces.
vector< MeshPtr > MeshList
List of meshes.
Definition: Mesh.h:233
shared_ptr< class MeshPartition > MeshPartitionPtr
Shared pointer to a mesh partition.
Definition: Mesh.h:146
shared_ptr< class Mesh > MeshPtr
Shared pointer to a mesh.
Definition: Mesh.h:230
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:27
Class which holds a set of geometry loaders.
Definition: GeometryHandler.h:64
const MeshList & getMeshes() const
Get list of meshes.
Definition: GeometryHandler.h:99
const Vector3 & getMaximumBounds() const
Return the minimum bounds for all meshes.
Definition: GeometryHandler.h:115
static GeometryHandlerPtr create()
Create a new geometry handler.
Definition: GeometryHandler.h:72
const Vector3 & getMinimumBounds() const
Return the minimum bounds for all meshes.
Definition: GeometryHandler.h:109
Base class representing a geometry loader.
Definition: GeometryHandler.h:28
const StringSet & supportedExtensions() const
Returns a list of supported extensions.
Definition: GeometryHandler.h:37
virtual bool load(const FilePath &filePath, MeshList &meshList, bool texcoordVerticalFlip=false)=0
Load geometry from disk.
A vector of two floating-point values.
Definition: Types.h:286
A vector of three floating-point values.
Definition: Types.h:306