VTK  9.7.0
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0 VTK_DEPRECATED_IN_9_6_0
65#include "vtkIOImportModule.h" // For export macro
66#include "vtkImporter.h"
67#include "vtkSmartPointer.h" // For SmartPointer
68#include "vtkURILoader.h" // For URILoader
69
70#include <map> // For map
71#include <vector> // For vector
72
73VTK_ABI_NAMESPACE_BEGIN
74
75// Forward declarations
76class vtkActor;
77class vtkCamera;
79class vtkTexture;
80class vtkURILoader;
81
82class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
83{
84public:
86
88 void PrintSelf(ostream& os, vtkIndent indent) override;
89
91
95 vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
96 vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
98
100
105 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
106 void SetStreamIsBinary(bool val);
107 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
109 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
111 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
114
116
123 static bool CanReadFile(vtkResourceStream* stream);
124 static bool CanReadFile(const std::string& filename);
126
133
137 std::string GetOutputsDescription() override { return this->OutputsDescription; }
138
142 bool UpdateAtTimeValue(double timeValue) override;
143
149
154
158 std::string GetAnimationName(vtkIdType animationIndex) override;
159
161
164 void EnableAnimation(vtkIdType animationIndex) override;
165 void DisableAnimation(vtkIdType animationIndex) override;
166 bool IsAnimationEnabled(vtkIdType animationIndex) override;
168
173
177 std::string GetCameraName(vtkIdType camIndex) override;
178
183 void SetCamera(vtkIdType camIndex) override;
184
194 VTK_DEPRECATED_IN_9_6_0("Use GetTemporalInformation without framerate parameter instead.")
195 bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
196 double timeRange[2], vtkDoubleArray* timeSteps) override;
197
204 bool GetTemporalInformation(vtkIdType animationIndex, double timeRange[2], int& nbTimeSteps,
205 vtkDoubleArray* timeSteps) override;
206
212 {
214 }
215
216protected:
217 vtkGLTFImporter() = default;
218 ~vtkGLTFImporter() override = default;
219
224 virtual void InitializeLoader();
225
226 int ImportBegin() override;
227 void ImportActors(vtkRenderer* renderer) override;
228 void ImportCameras(vtkRenderer* renderer) override;
229 void ImportLights(vtkRenderer* renderer) override;
230 void ImportEnd() override;
231
233
240 virtual void ApplyArmatureProperties(vtkActor* actor);
241
243
244 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
245 bool StreamIsBinary = false;
246
249 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
252 std::vector<bool> EnabledAnimations;
254
255private:
256 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
257 void operator=(const vtkGLTFImporter&) = delete;
258
259 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
260
265 void GuessCamerasFocalPoints();
266};
267
268VTK_ABI_NAMESPACE_END
269#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 StreamIsBinaryOff()
Set/Get whether the input stream is binary.
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 SetStreamIsBinary(bool val)
Set/Get whether the input stream is binary.
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
bool GetStreamIsBinary()
Set/Get whether the input stream is binary.
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
static bool CanReadFile(vtkResourceStream *stream)
Return true if, after a quick check of file header, it looks like the provided stream can be read.
void StreamIsBinaryOn()
Set/Get whether the input stream is binary.
InterpolateAnimationSupportLevel
a simple class to control print indentation
Definition vtkIndent.h:29
abstract specification for renderers
Definition vtkRenderer.h:64
Abstract class used for custom streams.
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_7_0(reason)
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:363