VTK  9.7.20260727
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
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
230 bool GetTemporalInformation(vtkIdType animationIndex, double timeRange[2], int& nbTimeSteps,
231 vtkDoubleArray* timeSteps) override;
232
241
242protected:
243 vtkGLTFImporter() = default;
244 ~vtkGLTFImporter() override = default;
245
250 virtual void InitializeLoader();
251
252 int ImportBegin() override;
253 void ImportActors(vtkRenderer* renderer) override;
254 void ImportCameras(vtkRenderer* renderer) override;
255 void ImportLights(vtkRenderer* renderer) override;
256 void ImportEnd() override;
257
259
266 virtual void ApplyArmatureProperties(vtkActor* actor);
267
269
270 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
271 bool StreamIsBinary = false;
272
275 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
278 std::vector<bool> EnabledAnimations;
280
281private:
282 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
283 void operator=(const vtkGLTFImporter&) = delete;
284
285 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
286
291 void GuessCamerasFocalPoints();
292};
293
294VTK_ABI_NAMESPACE_END
295#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.
bool GetTemporalInformation(vtkIdType animationIndex, double timeRange[2], int &nbTimeSteps, vtkDoubleArray *timeSteps) override
Get temporal information for the provided animationIndex.
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
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)
int vtkIdType
Definition vtkType.h:363