VTK  9.5.20250702
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
95#ifndef vtkGLTFImporter_h
96#define vtkGLTFImporter_h
97
98#include "vtkIOImportModule.h" // For export macro
99#include "vtkImporter.h"
100#include "vtkResourceStream.h" // For Stream
101#include "vtkSmartPointer.h" // For SmartPointer
102#include "vtkURILoader.h" // For URILoader
103
104#include <map> // For map
105#include <vector> // For vector
106
107VTK_ABI_NAMESPACE_BEGIN
108
109// Forward declarations
110class vtkActor;
111class vtkCamera;
113class vtkTexture;
114class vtkURILoader;
115
116class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
117{
118public:
120
122 void PrintSelf(ostream& os, vtkIndent indent) override;
123
125
131
133
142 vtkSetSmartPointerMacro(Stream, vtkResourceStream);
143 vtkGetSmartPointerMacro(Stream, vtkResourceStream);
145
147
151 vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
152 vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
154
156
161 vtkSetMacro(StreamIsBinary, bool);
162 vtkGetMacro(StreamIsBinary, bool);
163 vtkBooleanMacro(StreamIsBinary, bool);
165
172
176 std::string GetOutputsDescription() override { return this->OutputsDescription; }
177
181 bool UpdateAtTimeValue(double timeValue) override;
182
188
193
197 std::string GetAnimationName(vtkIdType animationIndex) override;
198
200
203 void EnableAnimation(vtkIdType animationIndex) override;
204 void DisableAnimation(vtkIdType animationIndex) override;
205 bool IsAnimationEnabled(vtkIdType animationIndex) override;
207
212
216 std::string GetCameraName(vtkIdType camIndex) override;
217
222 void SetCamera(vtkIdType camIndex) override;
223
232 bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
233 double timeRange[2], vtkDoubleArray* timeSteps) override;
234
235protected:
236 vtkGLTFImporter() = default;
238
243 virtual void InitializeLoader();
244
245 int ImportBegin() override;
246 void ImportActors(vtkRenderer* renderer) override;
247 void ImportCameras(vtkRenderer* renderer) override;
248 void ImportLights(vtkRenderer* renderer) override;
249
251
258 virtual void ApplyArmatureProperties(vtkActor* actor);
259
260 char* FileName = nullptr;
263 bool StreamIsBinary = false;
264
265 std::map<int, vtkSmartPointer<vtkCamera>> Cameras;
266 std::map<int, vtkSmartPointer<vtkTexture>> Textures;
267 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
270 std::vector<bool> EnabledAnimations;
271 vtkIdType EnabledCamera = -1;
272
273private:
274 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
275 void operator=(const vtkGLTFImporter&) = delete;
276
277 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
278};
279
280VTK_ABI_NAMESPACE_END
281#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
AnimationSupportLevel GetAnimationSupportLevel() override
Get the level of animation support in this importer, which is always AnimationSupportLevel::MULTI.
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:59
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:332