VTK  9.3.1
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 
49 #ifndef vtkGLTFImporter_h
50 #define vtkGLTFImporter_h
51 
52 #include "vtkIOImportModule.h" // For export macro
53 #include "vtkImporter.h"
54 #include "vtkSmartPointer.h" // For SmartPointer
55 
56 #include <map> // For map
57 #include <vector> // For vector
58 
59 VTK_ABI_NAMESPACE_BEGIN
60 class vtkActor;
61 class vtkCamera;
63 class vtkTexture;
64 
65 class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
66 {
67 public:
68  static vtkGLTFImporter* New();
69 
70  vtkTypeMacro(vtkGLTFImporter, vtkImporter);
71  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
74 
77  vtkSetFilePathMacro(FileName);
78  vtkGetFilePathMacro(FileName);
80 
86  vtkSmartPointer<vtkCamera> GetCamera(unsigned int id);
87 
91  std::string GetOutputsDescription() override { return this->OutputsDescription; };
92 
96  void UpdateTimeStep(double timeValue) override;
97 
101  vtkIdType GetNumberOfAnimations() override;
102 
106  std::string GetAnimationName(vtkIdType animationIndex) override;
107 
109 
112  void EnableAnimation(vtkIdType animationIndex) override;
113  void DisableAnimation(vtkIdType animationIndex) override;
114  bool IsAnimationEnabled(vtkIdType animationIndex) override;
116 
120  vtkIdType GetNumberOfCameras() override;
121 
125  std::string GetCameraName(vtkIdType camIndex) override;
126 
131  void SetCamera(vtkIdType camIndex) override;
132 
141  bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
142  double timeRange[2], vtkDoubleArray* timeSteps) override;
143 
144 protected:
145  vtkGLTFImporter() = default;
146  ~vtkGLTFImporter() override;
147 
148  int ImportBegin() override;
149  void ImportActors(vtkRenderer* renderer) override;
150  void ImportCameras(vtkRenderer* renderer) override;
151  void ImportLights(vtkRenderer* renderer) override;
152 
153  void ApplySkinningMorphing();
154 
155  char* FileName = nullptr;
156 
157  std::map<int, vtkSmartPointer<vtkCamera>> Cameras;
158  std::map<int, vtkSmartPointer<vtkTexture>> Textures;
159  std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
162  std::vector<bool> EnabledAnimations;
163  vtkIdType EnabledCamera = -1;
164 
165 private:
166  vtkGLTFImporter(const vtkGLTFImporter&) = delete;
167  void operator=(const vtkGLTFImporter&) = delete;
168 };
169 
170 VTK_ABI_NAMESPACE_END
171 #endif
std::vector< bool > EnabledAnimations
std::string OutputsDescription
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
virtual void DisableAnimation(vtkIdType vtkNotUsed(animationIndex))
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:106
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::map< int, vtkSmartPointer< vtkCamera > > Cameras
virtual void ImportCameras(vtkRenderer *)
Definition: vtkImporter.h:155
abstract specification for renderers
Definition: vtkRenderer.h:61
virtual std::string GetCameraName(vtkIdType vtkNotUsed(camIndex))
Get the name of a camera.
Definition: vtkImporter.h:120
int vtkIdType
Definition: vtkType.h:315
virtual vtkIdType GetNumberOfAnimations()
Get the number of available animations.
virtual void SetCamera(vtkIdType vtkNotUsed(camIndex))
Enable a specific camera.
Definition: vtkImporter.h:127
importer abstract class
Definition: vtkImporter.h:48
dynamic, self-adjusting array of double
virtual int ImportBegin()
Definition: vtkImporter.h:152
virtual void EnableAnimation(vtkIdType vtkNotUsed(animationIndex))
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:105
a simple class to control print indentation
Definition: vtkIndent.h:28
a virtual camera for 3D rendering
Definition: vtkCamera.h:40
Import a GLTF file.
handles properties associated with a texture map
Definition: vtkTexture.h:57
std::map< int, std::vector< vtkSmartPointer< vtkActor > > > Actors
virtual void ImportActors(vtkRenderer *)
Definition: vtkImporter.h:154
virtual vtkIdType GetNumberOfCameras()
Get the number of available cameras.
Definition: vtkImporter.h:114
std::map< int, vtkSmartPointer< vtkTexture > > Textures
virtual std::string GetAnimationName(vtkIdType vtkNotUsed(animationIndex))
Get the name of an animation.
Definition: vtkImporter.h:99
virtual void ImportLights(vtkRenderer *)
Definition: vtkImporter.h:156
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
virtual void UpdateTimeStep(double timeValue)
Import the actors, camera, lights and properties at a specific time value.
Deserialize a GLTF model file.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int &nbTimeSteps, double timeRange[2], vtkDoubleArray *timeSteps)
Get temporal information for the provided animationIndex and frameRate.
virtual bool IsAnimationEnabled(vtkIdType vtkNotUsed(animationIndex))
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:107
std::string GetOutputsDescription() override
Get a printable string describing all outputs.