VTK  9.7.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 
61 #ifndef vtkGLTFImporter_h
62 #define vtkGLTFImporter_h
63 
64 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0 VTK_DEPRECATED_IN_9_6_0
65 #include "vtkIOImportModule.h" // For export macro
66 #include "vtkImporter.h"
67 #include "vtkSmartPointer.h" // For SmartPointer
68 #include "vtkURILoader.h" // For URILoader
69 
70 #include <map> // For map
71 #include <vector> // For vector
72 
73 VTK_ABI_NAMESPACE_BEGIN
74 
75 // Forward declarations
76 class vtkActor;
77 class vtkCamera;
79 class vtkTexture;
80 class vtkURILoader;
81 
82 class VTKIOIMPORT_EXPORT vtkGLTFImporter : public vtkImporter
83 {
84 public:
85  static vtkGLTFImporter* New();
86 
87  vtkTypeMacro(vtkGLTFImporter, vtkImporter);
88  void PrintSelf(ostream& os, vtkIndent indent) override;
89 
91 
95  vtkSetSmartPointerMacro(StreamURILoader, vtkURILoader);
96  vtkGetSmartPointerMacro(StreamURILoader, vtkURILoader);
98 
100 
105  VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
106  void SetStreamIsBinary(bool val);
107  VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
108  bool GetStreamIsBinary();
109  VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
110  void StreamIsBinaryOn();
111  VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
112  void StreamIsBinaryOff();
114 
116 
123  static bool CanReadFile(vtkResourceStream* stream);
124  static bool CanReadFile(const std::string& filename);
126 
132  vtkSmartPointer<vtkCamera> GetCamera(unsigned int id);
133 
137  std::string GetOutputsDescription() override { return this->OutputsDescription; }
138 
142  bool UpdateAtTimeValue(double timeValue) override;
143 
149 
153  vtkIdType GetNumberOfAnimations() override;
154 
158  std::string GetAnimationName(vtkIdType animationIndex) override;
159 
161 
164  void EnableAnimation(vtkIdType animationIndex) override;
165  void DisableAnimation(vtkIdType animationIndex) override;
166  bool IsAnimationEnabled(vtkIdType animationIndex) override;
168 
172  vtkIdType GetNumberOfCameras() override;
173 
177  std::string GetCameraName(vtkIdType camIndex) override;
178 
183  void SetCamera(vtkIdType camIndex) override;
184 
194  VTK_DEPRECATED_IN_9_6_0("Use GetTemporalInformation without framerate parameter instead.")
195  bool GetTemporalInformation(vtkIdType animationIndex, double frameRate, int& nbTimeSteps,
196  double timeRange[2], vtkDoubleArray* timeSteps) override;
197 
204  bool GetTemporalInformation(vtkIdType animationIndex, double timeRange[2], int& nbTimeSteps,
205  vtkDoubleArray* timeSteps) override;
206 
211  InterpolateAnimationSupportLevel GetInterpolateAnimationSupportLevel() override
212  {
214  }
215 
216 protected:
217  vtkGLTFImporter() = default;
218  ~vtkGLTFImporter() override = default;
219 
224  virtual void InitializeLoader();
225 
226  int ImportBegin() override;
227  void ImportActors(vtkRenderer* renderer) override;
228  void ImportCameras(vtkRenderer* renderer) override;
229  void ImportLights(vtkRenderer* renderer) override;
230  void ImportEnd() override;
231 
232  void ApplySkinningMorphing();
233 
240  virtual void ApplyArmatureProperties(vtkActor* actor);
241 
243 
244  VTK_DEPRECATED_IN_9_7_0("Do not use, binary stream is automatically detected")
245  bool StreamIsBinary = false;
246 
247  std::map<int, vtkSmartPointer<vtkCamera>> Cameras;
248  std::map<int, vtkSmartPointer<vtkTexture>> Textures;
249  std::map<int, std::vector<vtkSmartPointer<vtkActor>>> Actors;
251  std::string OutputsDescription;
252  std::vector<bool> EnabledAnimations;
253  vtkIdType EnabledCamera = -1;
254 
255 private:
256  vtkGLTFImporter(const vtkGLTFImporter&) = delete;
257  void operator=(const vtkGLTFImporter&) = delete;
258 
259  std::map<int, vtkSmartPointer<vtkActor>> ArmatureActors;
260 
265  void GuessCamerasFocalPoints();
266 };
267 
268 VTK_ABI_NAMESPACE_END
269 #endif
virtual bool IsAnimationEnabled(vtkIdType animationIndex)
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:178
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
Abstract class used for custom streams.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
InterpolateAnimationSupportLevel
Definition: vtkImporter.h:233
virtual void EnableAnimation(vtkIdType animationIndex)
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:176
virtual void ImportCameras(vtkRenderer *)
Definition: vtkImporter.h:282
abstract specification for renderers
Definition: vtkRenderer.h:63
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
int vtkIdType
Definition: vtkType.h:363
virtual vtkIdType GetNumberOfAnimations()
Get the number of available animations.
importer abstract class
Definition: vtkImporter.h:60
dynamic, self-adjusting array of double
virtual void ImportEnd()
Definition: vtkImporter.h:280
virtual int ImportBegin()
Definition: vtkImporter.h:279
virtual void DisableAnimation(vtkIdType animationIndex)
Enable/Disable/Get the status of specific animations.
Definition: vtkImporter.h:177
virtual std::string GetAnimationName(vtkIdType animationIndex)
Get the name of an animation.
Definition: vtkImporter.h:170
#define VTK_DEPRECATED_IN_9_6_0(reason)
a simple class to control print indentation
Definition: vtkIndent.h:28
a virtual camera for 3D rendering
Definition: vtkCamera.h:41
Import a GLTF file.
AnimationSupportLevel GetAnimationSupportLevel() override
Get the level of animation support in this importer, which is always AnimationSupportLevel::MULTI.
handles properties associated with a texture map
Definition: vtkTexture.h:58
virtual std::string GetCameraName(vtkIdType camIndex)
Get the name of a camera.
Definition: vtkImporter.h:191
virtual void ImportActors(vtkRenderer *)
Definition: vtkImporter.h:281
virtual vtkIdType GetNumberOfCameras()
Get the number of available cameras.
Definition: vtkImporter.h:185
virtual void ImportLights(vtkRenderer *)
Definition: vtkImporter.h:283
virtual bool UpdateAtTimeValue(double timeValue)
Import the actors, camera, lights and properties at a specific time value.
Definition: vtkImporter.h:231
Helper class for readers and importer that need to load more than one resource.
Definition: vtkURILoader.h:99
vtkSmartPointer< vtkURILoader > StreamURILoader
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 void SetCamera(vtkIdType camIndex)
Enable a specific camera.
Definition: vtkImporter.h:198
#define VTK_DEPRECATED_IN_9_7_0(reason)