VTK  9.5.20251025
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
100#ifndef vtkGLTFImporter_h
101#define vtkGLTFImporter_h
102
103#include "vtkIOImportModule.h" // For export macro
104#include "vtkImporter.h"
105#include "vtkSmartPointer.h" // For SmartPointer
106#include "vtkURILoader.h" // For URILoader
107
108#include <map> // For map
109#include <vector> // For vector
110
111VTK_ABI_NAMESPACE_BEGIN
112
113// Forward declarations
114class vtkActor;
115class vtkCamera;
117class vtkTexture;
118class vtkURILoader;
119
120class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
121{
122public:
124
126 void PrintSelf(ostream& os, vtkIndent indent) override;
127
129
133 vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
134 vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
136
138
143 vtkSetMacro(StreamIsBinary, bool);
144 vtkGetMacro(StreamIsBinary, bool);
145 vtkBooleanMacro(StreamIsBinary, bool);
147
154
158 std::string GetOutputsDescription() override { return this->OutputsDescription; }
159
163 bool UpdateAtTimeValue(double timeValue) override;
164
170
175
179 std::string GetAnimationName(vtkIdType animationIndex) override;
180
182
185 void EnableAnimation(vtkIdType animationIndex) override;
186 void DisableAnimation(vtkIdType animationIndex) override;
187 bool IsAnimationEnabled(vtkIdType animationIndex) override;
189
194
198 std::string GetCameraName(vtkIdType camIndex) override;
199
204 void SetCamera(vtkIdType camIndex) override;
205
214 bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
215 double timeRange[2], vtkDoubleArray* timeSteps) override;
216
217protected:
218 vtkGLTFImporter() = default;
219 ~vtkGLTFImporter() override = default;
220
225 virtual void InitializeLoader();
226
227 int ImportBegin() override;
228 void ImportActors(vtkRenderer* renderer) override;
229 void ImportCameras(vtkRenderer* renderer) override;
230 void ImportLights(vtkRenderer* renderer) override;
231
233
240 virtual void ApplyArmatureProperties(vtkActor* actor);
241
243 bool StreamIsBinary = false;
244
245 std::map<int, vtkSmartPointer<vtkCamera>> Cameras;
246 std::map<int, vtkSmartPointer<vtkTexture>> Textures;
247 std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
250 std::vector<bool> EnabledAnimations;
251 vtkIdType EnabledCamera = -1;
252
253private:
254 vtkGLTFImporter(const vtkGLTFImporter&) = delete;
255 void operator=(const vtkGLTFImporter&) = delete;
256
257 std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
258};
259
260VTK_ABI_NAMESPACE_END
261#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.
Import a GLTF 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
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
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
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
Get temporal information for the provided animationIndex and frameRate.
std::vector< bool > EnabledAnimations
static vtkGLTFImporter * New()
vtkIdType GetNumberOfAnimations() override
Get the number of available animations.
void ImportCameras(vtkRenderer *renderer) override
importer abstract class
Definition vtkImporter.h:60
a simple class to control print indentation
Definition vtkIndent.h:108
abstract specification for renderers
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.
int vtkIdType
Definition vtkType.h:367