VTK  9.6.1
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
60
61#ifndef vtkGLTFImporter_h
62#define vtkGLTFImporter_h
63
64#include "vtkIOImportModule.h" // For export macro
65#include "vtkImporter.h"
66#include "vtkSmartPointer.h" // For SmartPointer
67#include "vtkURILoader.h" // For URILoader
68
69#include <map> // For map
70#include <vector> // For vector
71
72VTK_ABI_NAMESPACE_BEGIN
73
74// Forward declarations
75class vtkActor;
76class vtkCamera;
78class vtkTexture;
79class vtkURILoader;
80
81class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
82{
83public:
85
87 void PrintSelf(ostream& os, vtkIndent indent) override;
88
90
94 vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
95 vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
97
99
104 vtkSetMacro(StreamIsBinary, bool);
105 vtkGetMacro(StreamIsBinary, bool);
106 vtkBooleanMacro(StreamIsBinary, bool);
108
115
119 std::string GetOutputsDescription() override { return this->OutputsDescription; }
120
124 bool UpdateAtTimeValue(double timeValue) override;
125
131
136
140 std::string GetAnimationName(vtkIdType animationIndex) override;
141
143
146 void EnableAnimation(vtkIdType animationIndex) override;
147 void DisableAnimation(vtkIdType animationIndex) override;
148 bool IsAnimationEnabled(vtkIdType animationIndex) override;
150
155
159 std::string GetCameraName(vtkIdType camIndex) override;
160
165 void SetCamera(vtkIdType camIndex) override;
166
176 VTK_DEPRECATED_IN_9_6_0("Use GetTemporalInformation without framerate parameter instead.")
177 bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
178 double timeRange[2], vtkDoubleArray* timeSteps) override;
179
186 bool GetTemporalInformation(vtkIdType animationIndex, double timeRange[2], int& nbTimeSteps,
187 vtkDoubleArray* timeSteps) override;
188
197
198protected:
199 vtkGLTFImporter() = default;
200 ~vtkGLTFImporter() override = default;
201
206 virtual void InitializeLoader();
207
208 int ImportBegin() override;
209 void ImportActors(vtkRenderer* renderer) override;
210 void ImportCameras(vtkRenderer* renderer) override;
211 void ImportLights(vtkRenderer* renderer) override;
212 void ImportEnd() override;
213
215
222 virtual void ApplyArmatureProperties(vtkActor* actor);
223
225 bool StreamIsBinary = false;
226
227 std::map<int, vtkSmartPointer<vtkCamera>> Cameras;
228 std::map<int, vtkSmartPointer<vtkTexture>> Textures;
229 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
232 std::vector<bool> EnabledAnimations;
234
235private:
236 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
237 void operator=(const vtkGLTFImporter&) = delete;
238
239 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
240
245 void GuessCamerasFocalPoints();
246};
247
248VTK_ABI_NAMESPACE_END
249#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
a virtual camera for 3D rendering
Definition vtkCamera.h:42
dynamic, self-adjusting array of double
Deserialize a GLTF model 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
std::string OutputsDescription
std::map< int, vtkSmartPointer< vtkTexture > > Textures
bool UpdateAtTimeValue(double timeValue) override
update timestep
vtkIdType EnabledCamera
void ApplySkinningMorphing()
std::string GetOutputsDescription() override
Get a printable string describing all outputs.
vtkGLTFImporter()=default
void ImportActors(vtkRenderer *renderer) override
bool IsAnimationEnabled(vtkIdType animationIndex) override
Enable/Disable/Get the status of specific animations.
vtkSmartPointer< vtkURILoader > StreamURILoader
AnimationSupportLevel GetAnimationSupportLevel() override
Get the level of animation support in this importer, which is always AnimationSupportLevel::MULTI.
~vtkGLTFImporter() override=default
InterpolateAnimationSupportLevel GetInterpolateAnimationSupportLevel() override
Get the level of interpolation animation support in this importer, which is always InterpolationAnima...
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
void ImportEnd() override
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
DEPRECATED, use the version without framerate Get temporal information for the provided animationInde...
std::vector< bool > EnabledAnimations
static vtkGLTFImporter * New()
vtkIdType GetNumberOfAnimations() override
Get the number of available animations.
void ImportCameras(vtkRenderer *renderer) override
InterpolateAnimationSupportLevel
a simple class to control print indentation
Definition vtkIndent.h:29
abstract specification for renderers
Definition vtkRenderer.h:64
Hold a reference to a vtkObjectBase instance.
handles properties associated with a texture map
Definition vtkTexture.h:59
Helper class for readers and importer that need to load more than one resource.
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:368