VTK  9.7.20260917
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
101
102#ifndef vtkGLTFImporter_h
103#define vtkGLTFImporter_h
104
105#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
106#include "vtkIOImportModule.h" // For export macro
107#include "vtkImporter.h"
108#include "vtkSmartPointer.h" // For SmartPointer
109#include "vtkURILoader.h" // For URILoader
110
111#include <map> // For map
112#include <vector> // For vector
113
114VTK_ABI_NAMESPACE_BEGIN
115
116// Forward declarations
117class vtkActor;
118class vtkCamera;
120class vtkTexture;
121class vtkURILoader;
122
123class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
124{
125public:
127
129 void PrintSelf(ostream& os, vtkIndent indent) override;
130
132
136 vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
137 vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
139
141
146 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
147 void SetStreamIsBinary(bool val);
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")
152 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
155
157
164 static bool CanReadFile(vtkResourceStream* stream);
165 static bool CanReadFile(const std::string& filename);
167
174
178 std::string GetOutputsDescription() override { return this->OutputsDescription; }
179
183 bool UpdateAtTimeValue(double timeValue) override;
184
190
195
199 std::string GetAnimationName(vtkIdType animationIndex) override;
200
202
205 void EnableAnimation(vtkIdType animationIndex) override;
206 void DisableAnimation(vtkIdType animationIndex) override;
207 bool IsAnimationEnabled(vtkIdType animationIndex) override;
209
214
218 std::string GetCameraName(vtkIdType camIndex) override;
219
224 void SetCamera(vtkIdType camIndex) override;
225
232 bool GetTemporalInformation(vtkIdType animationIndex, double timeRange[2], int& nbTimeSteps,
233 vtkDoubleArray* timeSteps) override;
234
243
244protected:
245 vtkGLTFImporter() = default;
246 ~vtkGLTFImporter() override = default;
247
252 virtual void InitializeLoader();
253
254 int ImportBegin() override;
255 void ImportActors(vtkRenderer* renderer) override;
256 void ImportCameras(vtkRenderer* renderer) override;
257 void ImportLights(vtkRenderer* renderer) override;
258 void ImportEnd() override;
259
261
268 virtual void ApplyArmatureProperties(vtkActor* actor);
269
271
272 VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
273 bool StreamIsBinary = false;
274
277 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
280 std::vector<bool> EnabledAnimations;
282
283private:
284 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
285 void operator=(const vtkGLTFImporter&) = delete;
286
287 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
288
293 void GuessCamerasFocalPoints();
294};
295
296VTK_ABI_NAMESPACE_END
297#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