VTK  9.2.6
vtkGLTFImporter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGLTFImporter.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
61 #ifndef vtkGLTFImporter_h
62 #define vtkGLTFImporter_h
63 
64 #include "vtkIOImportModule.h" // For export macro
65 #include "vtkImporter.h"
66 #include "vtkSmartPointer.h" // For SmartPointer
67 
68 #include <map> // For map
69 #include <vector> // For vector
70 
71 class vtkActor;
72 class vtkCamera;
74 class vtkTexture;
75 
76 class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
77 {
78 public:
79  static vtkGLTFImporter* New();
80 
81  vtkTypeMacro(vtkGLTFImporter, vtkImporter);
82  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
85 
88  vtkSetFilePathMacro(FileName);
89  vtkGetFilePathMacro(FileName);
91 
97  vtkSmartPointer<vtkCamera> GetCamera(unsigned int id);
98 
102  std::string GetOutputsDescription() override { return this->OutputsDescription; };
103 
107  void UpdateTimeStep(double timestep) override;
108 
112  vtkIdType GetNumberOfAnimations() override;
113 
117  std::string GetAnimationName(vtkIdType animationIndex) override;
118 
120 
123  void EnableAnimation(vtkIdType animationIndex) override;
124  void DisableAnimation(vtkIdType animationIndex) override;
125  bool IsAnimationEnabled(vtkIdType animationIndex) override;
127 
131  vtkIdType GetNumberOfCameras() override;
132 
136  std::string GetCameraName(vtkIdType camIndex) override;
137 
142  void SetCamera(vtkIdType camIndex) override;
143 
149  bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
150  double timeRange[2], vtkDoubleArray* timeSteps) override;
151 
152 protected:
153  vtkGLTFImporter() = default;
154  ~vtkGLTFImporter() override;
155 
156  int ImportBegin() override;
157  void ImportActors(vtkRenderer* renderer) override;
158  void ImportCameras(vtkRenderer* renderer) override;
159  void ImportLights(vtkRenderer* renderer) override;
160 
161  void ApplySkinningMorphing();
162 
163  char* FileName = nullptr;
164 
165  std::map<int, vtkSmartPointer<vtkCamera>> Cameras;
166  std::map<int, vtkSmartPointer<vtkTexture>> Textures;
167  std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
170  std::vector<bool> EnabledAnimations;
171  vtkIdType EnabledCamera = -1;
172 
173 private:
174  vtkGLTFImporter(const vtkGLTFImporter&) = delete;
175  void operator=(const vtkGLTFImporter&) = delete;
176 };
177 
178 #endif
std::vector< bool > EnabledAnimations
std::string OutputsDescription
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
virtual void DisableAnimation(vtkIdType vtkNotUsed(animationIndex))
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:117
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:161
abstract specification for renderers
Definition: vtkRenderer.h:72
virtual std::string GetCameraName(vtkIdType vtkNotUsed(camIndex))
Get the name of a camera.
Definition: vtkImporter.h:131
int vtkIdType
Definition: vtkType.h:332
virtual vtkIdType GetNumberOfAnimations()
Get the number of available animations.
virtual void UpdateTimeStep(double timeStep)
Import the actors, camera, lights and properties at a specific timestep.
virtual void SetCamera(vtkIdType vtkNotUsed(camIndex))
Enable a specific camera.
Definition: vtkImporter.h:138
importer abstract class
Definition: vtkImporter.h:59
dynamic, self-adjusting array of double
virtual int ImportBegin()
Definition: vtkImporter.h:158
virtual void EnableAnimation(vtkIdType vtkNotUsed(animationIndex))
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:116
a simple class to control print indentation
Definition: vtkIndent.h:39
a virtual camera for 3D rendering
Definition: vtkCamera.h:51
Import a GLTF file.
handles properties associated with a texture map
Definition: vtkTexture.h:68
std::map< int, std::vector< vtkSmartPointer< vtkActor > > > Actors
virtual void ImportActors(vtkRenderer *)
Definition: vtkImporter.h:160
virtual vtkIdType GetNumberOfCameras()
Get the number of available cameras.
Definition: vtkImporter.h:125
std::map< int, vtkSmartPointer< vtkTexture > > Textures
virtual std::string GetAnimationName(vtkIdType vtkNotUsed(animationIndex))
Get the name of an animation.
Definition: vtkImporter.h:110
virtual void ImportLights(vtkRenderer *)
Definition: vtkImporter.h:162
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
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 informations for the currently enabled animations.
virtual bool IsAnimationEnabled(vtkIdType vtkNotUsed(animationIndex))
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:118
std::string GetOutputsDescription() override
Get a printable string describing all outputs.