VTK  9.6.20260216
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
99
100#ifndef vtkGLTFImporter_h
101#define vtkGLTFImporter_h
102
103#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0 VTK_DEPRECATED_IN_9_6_0
104#include "vtkIOImportModule.h" // For export macro
105#include "vtkImporter.h"
106#include "vtkSmartPointer.h" // For SmartPointer
107#include "vtkURILoader.h" // For URILoader
108
109#include <map> // For map
110#include <vector> // For vector
111
112VTK_ABI_NAMESPACE_BEGIN
113
114// Forward declarations
115class vtkActor;
116class vtkCamera;
118class vtkTexture;
119class vtkURILoader;
120
121class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
122{
123public:
125
127 void PrintSelf(ostream& os, vtkIndent indent) override;
128
130
134 vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
135 vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
137
139
144 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
145 void SetStreamIsBinary(bool val);
146 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
148 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
150 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
153
155
162 static bool CanReadFile(vtkResourceStream* stream);
163 static bool CanReadFile(const std::string& filename);
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
233 VTK_DEPRECATED_IN_9_6_0("Use GetTemporalInformation without framerate parameter instead.")
234 bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
235 double timeRange[2], vtkDoubleArray* timeSteps) override;
236
243 bool GetTemporalInformation(vtkIdType animationIndex, double timeRange[2], int& nbTimeSteps,
244 vtkDoubleArray* timeSteps) override;
245
254
255protected:
256 vtkGLTFImporter() = default;
257 ~vtkGLTFImporter() override = default;
258
263 virtual void InitializeLoader();
264
265 int ImportBegin() override;
266 void ImportActors(vtkRenderer* renderer) override;
267 void ImportCameras(vtkRenderer* renderer) override;
268 void ImportLights(vtkRenderer* renderer) override;
269 void ImportEnd() override;
270
272
279 virtual void ApplyArmatureProperties(vtkActor* actor);
280
282
283 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
284 bool StreamIsBinary = false;
285
288 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
291 std::vector<bool> EnabledAnimations;
293
294private:
295 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
296 void operator=(const vtkGLTFImporter&) = delete;
297
298 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
299
304 void GuessCamerasFocalPoints();
305};
306
307VTK_ABI_NAMESPACE_END
308#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.
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: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.
#define VTK_DEPRECATED_IN_9_7_0(reason)
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:363