VTK  9.4.20250219
vtkGLTFImporter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
91#ifndef vtkGLTFImporter_h
92#define vtkGLTFImporter_h
93
94#include "vtkIOImportModule.h" // For export macro
95#include "vtkImporter.h"
96#include "vtkResourceStream.h" // For Stream
97#include "vtkSmartPointer.h" // For SmartPointer
98#include "vtkURILoader.h" // For URILoader
99
100#include <map> // For map
101#include <vector> // For vector
102
103VTK_ABI_NAMESPACE_BEGIN
104
105// Forward declarations
106class vtkActor;
107class vtkCamera;
109class vtkTexture;
110class vtkURILoader;
111
112class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
113{
114public:
116
118 void PrintSelf(ostream& os, vtkIndent indent) override;
119
121
127
129
138 vtkSetSmartPointerMacro(Stream, vtkResourceStream);
139 vtkGetSmartPointerMacro(Stream, vtkResourceStream);
141
143
147 vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
148 vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
150
152
157 vtkSetMacro(StreamIsBinary, bool);
158 vtkGetMacro(StreamIsBinary, bool);
159 vtkBooleanMacro(StreamIsBinary, bool);
161
168
172 std::string GetOutputsDescription() override { return this->OutputsDescription; }
173
177 bool UpdateAtTimeValue(double timeValue) override;
178
183
187 std::string GetAnimationName(vtkIdType animationIndex) override;
188
190
193 void EnableAnimation(vtkIdType animationIndex) override;
194 void DisableAnimation(vtkIdType animationIndex) override;
195 bool IsAnimationEnabled(vtkIdType animationIndex) override;
197
202
206 std::string GetCameraName(vtkIdType camIndex) override;
207
212 void SetCamera(vtkIdType camIndex) override;
213
222 bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
223 double timeRange[2], vtkDoubleArray* timeSteps) override;
224
225protected:
226 vtkGLTFImporter() = default;
228
233 virtual void InitializeLoader();
234
235 int ImportBegin() override;
236 void ImportActors(vtkRenderer* renderer) override;
237 void ImportCameras(vtkRenderer* renderer) override;
238 void ImportLights(vtkRenderer* renderer) override;
239
241
248 virtual void ApplyArmatureProperties(vtkActor* actor);
249
250 char* FileName = nullptr;
253 bool StreamIsBinary = false;
254
255 std::map<int, vtkSmartPointer<vtkCamera>> Cameras;
256 std::map<int, vtkSmartPointer<vtkTexture>> Textures;
257 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
260 std::vector<bool> EnabledAnimations;
261 vtkIdType EnabledCamera = -1;
262
263private:
264 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
265 void operator=(const vtkGLTFImporter&) = delete;
266
267 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
268};
269
270VTK_ABI_NAMESPACE_END
271#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
a virtual camera for 3D rendering
Definition vtkCamera.h:151
dynamic, self-adjusting array of double
Deserialize a GLTF model file.
Import a GLTF file.
void DisableAnimation(vtkIdType animationIndex) override
Enable/Disable/Get the status of specific animations.
vtkIdType GetNumberOfCameras() override
Get the number of available cameras.
std::map< int, vtkSmartPointer< vtkCamera > > Cameras
~vtkGLTFImporter() override
std::string OutputsDescription
std::map< int, vtkSmartPointer< vtkTexture > > Textures
bool UpdateAtTimeValue(double timeValue) override
update timestep
void ApplySkinningMorphing()
vtkSmartPointer< vtkResourceStream > Stream
std::string GetOutputsDescription() override
Get a printable string describing all outputs.
vtkSetFilePathMacro(FileName)
Specify the name of the file to read.
vtkGLTFImporter()=default
void ImportActors(vtkRenderer *renderer) override
bool IsAnimationEnabled(vtkIdType animationIndex) override
Enable/Disable/Get the status of specific animations.
vtkGetFilePathMacro(FileName)
Specify the name of the file to read.
vtkSmartPointer< vtkURILoader > StreamURILoader
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
void EnableAnimation(vtkIdType animationIndex) override
Enable/Disable/Get the status of specific animations.
void SetCamera(vtkIdType camIndex) override
Enable a specific camera.
int ImportBegin() override
std::string GetAnimationName(vtkIdType animationIndex) override
Return the name of the animation.
virtual void ApplyArmatureProperties(vtkActor *actor)
Apply properties on the armature actors.
std::map< int, std::vector< vtkSmartPointer< vtkActor > > > Actors
virtual void InitializeLoader()
Initialize the document loader.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer< vtkCamera > GetCamera(unsigned int id)
glTF defines multiple camera objects, but no default behavior for which camera should be used.
std::string GetCameraName(vtkIdType camIndex) override
Get the name of a camera.
void ImportLights(vtkRenderer *renderer) override
bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int &nbTimeSteps, double timeRange[2], vtkDoubleArray *timeSteps) override
Get temporal information for the provided animationIndex and frameRate.
std::vector< bool > EnabledAnimations
static vtkGLTFImporter * New()
vtkIdType GetNumberOfAnimations() override
Get the number of available animations.
void ImportCameras(vtkRenderer *renderer) override
importer abstract class
Definition vtkImporter.h:56
a simple class to control print indentation
Definition vtkIndent.h:108
abstract specification for renderers
Abstract class used for custom streams.
Hold a reference to a vtkObjectBase instance.
handles properties associated with a texture map
Definition vtkTexture.h:168
Helper class for readers and importer that need to load more than one resource.
int vtkIdType
Definition vtkType.h:315