Overte C++ Documentation
Model.h
1 //
2 // Model.h
3 // interface/src/renderer
4 //
5 // Created by Andrzej Kapolka on 10/18/13.
6 // Copyright 2013 High Fidelity, Inc.
7 // Copyright 2023 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 // SPDX-License-Identifier: Apache-2.0
12 //
13 
14 #ifndef hifi_Model_h
15 #define hifi_Model_h
16 
17 #include <QBitArray>
18 #include <QObject>
19 #include <QUrl>
20 #include <QMutex>
21 
22 #include <unordered_map>
23 #include <unordered_set>
24 #include <functional>
25 
26 #include <AABox.h>
27 #include <DependencyManager.h>
28 #include <GeometryUtil.h>
29 #include <gpu/Batch.h>
30 #include <render/Forward.h>
31 #include <render/Scene.h>
32 #include <graphics-scripting/Forward.h>
33 #include <Transform.h>
34 #include <SpatiallyNestable.h>
35 #include <TriangleSet.h>
36 #include <DualQuaternion.h>
37 
38 #include "RenderHifi.h"
39 #include "GeometryCache.h"
40 #include "TextureCache.h"
41 #include "Rig.h"
42 #include "PrimitiveMode.h"
43 #include "BillboardMode.h"
44 
45 // Use dual quaternion skinning!
46 // Must match define in Skinning.slh
47 #define SKIN_DQ
48 
50 
51 class ViewFrustum;
52 
53 namespace render {
54  class Scene;
55  class Transaction;
56  typedef unsigned int ItemID;
57 }
58 class MeshPartPayload;
59 class ModelMeshPartPayload;
60 class ModelRenderLocations;
61 
62 inline uint qHash(const std::shared_ptr<MeshPartPayload>& a, uint seed) {
63  return qHash(a.get(), seed);
64 }
65 
66 class Model;
67 using ModelPointer = std::shared_ptr<Model>;
68 using ModelWeakPointer = std::weak_ptr<Model>;
69 
70 struct SortedTriangleSet {
71  SortedTriangleSet(float distance, TriangleSet* triangleSet, int partIndex, int shapeID, int subMeshIndex) :
72  distance(distance), triangleSet(triangleSet), partIndex(partIndex), shapeID(shapeID), subMeshIndex(subMeshIndex) {}
73 
74  float distance;
75  TriangleSet* triangleSet;
76  int partIndex;
77  int shapeID;
78  int subMeshIndex;
79 };
80 
81 using BlendShapeOperator = std::function<void(int, const QVector<BlendshapeOffset>&, const QVector<int>&, const render::ItemIDs&)>;
82 
84 class Model : public QObject, public std::enable_shared_from_this<Model>, public scriptable::ModelProvider {
85  Q_OBJECT
86 
87 public:
88 
89  typedef RenderArgs::RenderMode RenderMode;
90 
91  static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
92 
93  Model(QObject* parent = nullptr, SpatiallyNestable* spatiallyNestableOverride = nullptr, uint64_t created = 0);
94  virtual ~Model();
95 
96  inline ModelPointer getThisPointer() const {
97  return std::static_pointer_cast<Model>(std::const_pointer_cast<Model>(shared_from_this()));
98  }
99 
101  // Should only be called from the model's rendering thread to avoid access violations of changed geometry.
102  Q_INVOKABLE virtual void setURL(const QUrl& url);
103  const QUrl& getURL() const { return _url; }
104 
105  // new Scene/Engine rendering support
106  void setVisibleInScene(bool isVisible, const render::ScenePointer& scene = nullptr);
107  bool isVisible() const;
108 
109  render::hifi::Tag getTagMask() const;
110  void setTagMask(uint8_t mask, const render::ScenePointer& scene = nullptr);
111 
112  bool isGroupCulled() const;
113  void setGroupCulled(bool isGroupCulled, const render::ScenePointer& scene = nullptr);
114 
115  bool canCastShadow() const;
116  void setCanCastShadow(bool canCastShadow, const render::ScenePointer& scene = nullptr);
117 
118  void setHifiRenderLayer(render::hifi::Layer layer, const render::ScenePointer& scene = nullptr);
119 
120  bool isCauterized() const { return _cauterized; }
121  void setCauterized(bool value, const render::ScenePointer& scene = nullptr);
122 
123  void setPrimitiveMode(PrimitiveMode primitiveMode, const render::ScenePointer& scene = nullptr);
124  PrimitiveMode getPrimitiveMode() const { return _primitiveMode; }
125 
126  void setBillboardMode(BillboardMode billboardMode, const render::ScenePointer& scene = nullptr);
127  BillboardMode getBillboardMode() const { return _billboardMode; }
128 
129  void setCullWithParent(bool value, const render::ScenePointer& scene = nullptr);
130 
131  void setRenderWithZones(const QVector<QUuid>& renderWithZones, const render::ScenePointer& scene = nullptr);
132  const QVector<QUuid>& getRenderWithZones() const { return _renderWithZones; }
133 
134  // Access the current RenderItemKey Global Flags used by the model and applied to the render items representing the parts of the model.
135  const render::ItemKey getRenderItemKeyGlobalFlags() const;
136 
137  bool needsFixupInScene() const;
138 
139  bool needsReload() const { return _needsReload; }
140  bool addToScene(const render::ScenePointer& scene,
141  render::Transaction& transaction) {
142  auto getters = render::Item::Status::Getters(0);
143  return addToScene(scene, transaction, getters);
144  }
145  bool addToScene(const render::ScenePointer& scene,
146  render::Transaction& transaction,
147  BlendShapeOperator modelBlendshapeOperator) {
148  auto getters = render::Item::Status::Getters(0);
149  return addToScene(scene, transaction, getters, modelBlendshapeOperator);
150  }
151  bool addToScene(const render::ScenePointer& scene,
152  render::Transaction& transaction,
153  render::Item::Status::Getters& statusGetters,
154  BlendShapeOperator modelBlendshapeOperator = nullptr);
155  void removeFromScene(const render::ScenePointer& scene, render::Transaction& transaction);
156  bool isRenderable() const;
157 
158  void updateRenderItemsKey(const render::ScenePointer& scene);
159 
160  virtual void updateRenderItems();
161  void setRenderItemsNeedUpdate();
162  bool getRenderItemsNeedUpdate() { return _renderItemsNeedUpdate; }
163  AABox getRenderableMeshBound() const;
164  const render::ItemIDs& fetchRenderItemIDs() const;
165 
166  bool maybeStartBlender();
167 
168  bool isLoaded() const { return (bool)_renderGeometry && _renderGeometry->isHFMModelLoaded(); }
169  bool isAddedToScene() const { return _addedToScene; }
170 
171  void reset();
172 
173  void setSnapModelToRegistrationPoint(bool snapModelToRegistrationPoint, const glm::vec3& registrationPoint);
174  bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; }
175  bool getSnappedToRegistrationPoint() { return _snappedToRegistrationPoint; }
176 
177  virtual void simulate(float deltaTime, bool fullUpdate = true);
178  virtual void updateClusterMatrices();
179  virtual void updateBlendshapes();
180 
182  const Geometry::Pointer& getGeometry() const { return _renderGeometry; }
183 
184  const QVariantMap getTextures() const { assert(isLoaded()); return _renderGeometry->getTextures(); }
185  Q_INVOKABLE virtual void setTextures(const QVariantMap& textures);
186 
188  // And so that getHFMModel() isn't chained everywhere
189  const HFMModel& getHFMModel() const { assert(isLoaded()); return _renderGeometry->getHFMModel(); }
190  const MaterialMapping& getMaterialMapping() const { assert(isLoaded()); return _renderGeometry->getMaterialMapping(); }
191 
192  bool didVisualGeometryRequestFail() const { return _visualGeometryRequestFailed; }
193 
194  glm::mat4 getWorldToHFMMatrix() const;
195 
196  QStringList getJointNames() const;
197 
199  void setJointState(int index, bool valid, const glm::quat& rotation, const glm::vec3& translation, float priority);
200  void setJointRotation(int index, bool valid, const glm::quat& rotation, float priority);
201  void setJointTranslation(int index, bool valid, const glm::vec3& translation, float priority);
202 
203  bool findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, const glm::vec3& viewFrustumPos,
204  float& distance, BoxFace& face, glm::vec3& surfaceNormal,
205  QVariantMap& extraInfo, bool pickAgainstTriangles = false, bool allowBackface = false);
206  bool findParabolaIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& velocity, const glm::vec3& acceleration,
207  const glm::vec3& viewFrustumPos, float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal,
208  QVariantMap& extraInfo, bool pickAgainstTriangles = false, bool allowBackface = false);
209 
210  void setOffset(const glm::vec3& offset);
211  const glm::vec3& getOffset() const { return _offset; }
212  glm::vec3 getOriginalOffset() const;
213 
214  void setScaleToFit(bool scaleToFit, float largestDimension = 0.0f, bool forceRescale = false);
215  void setScaleToFit(bool scaleToFit, const glm::vec3& dimensions, bool forceRescale = false);
216  bool getScaleToFit() const { return _scaleToFit; }
217 
218  void setSnapModelToCenter(bool snapModelToCenter) {
219  setSnapModelToRegistrationPoint(snapModelToCenter, glm::vec3(0.5f,0.5f,0.5f));
220  };
221  bool getSnapModelToCenter() {
222  return _snapModelToRegistrationPoint && _registrationPoint == glm::vec3(0.5f,0.5f,0.5f);
223  }
224 
226  int getJointStateCount() const { return (int)_rig.getJointStateCount(); }
227  bool getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const;
228  bool getJointRotationInWorldFrame(int jointIndex, glm::quat& rotation) const;
229 
233  bool getJointRotation(int jointIndex, glm::quat& rotation) const;
234  bool getJointTranslation(int jointIndex, glm::vec3& translation) const;
235 
236  // model frame
237  bool getAbsoluteJointRotationInRigFrame(int jointIndex, glm::quat& rotationOut) const;
238  bool getAbsoluteJointTranslationInRigFrame(int jointIndex, glm::vec3& translationOut) const;
239 
240  bool getRelativeDefaultJointRotation(int jointIndex, glm::quat& rotationOut) const;
241  bool getRelativeDefaultJointTranslation(int jointIndex, glm::vec3& translationOut) const;
242 
244  int getParentJointIndex(int jointIndex) const;
245 
247  Extents getBindExtents() const;
248 
250  Extents getMeshExtents() const;
251 
253  Extents getUnscaledMeshExtents() const;
254 
255  void setTranslation(const glm::vec3& translation);
256  void setRotation(const glm::quat& rotation);
257  void overrideModelTransformAndOffset(const Transform& transform, const glm::vec3& offset);
258  bool isOverridingModelTransformAndOffset() { return _overrideModelTransform; };
259  void stopTransformAndOffsetOverride() { _overrideModelTransform = false; };
260  void setTransformNoUpdateRenderItems(const Transform& transform); // temporary HACK
261 
262  const glm::vec3& getTranslation() const { return _translation; }
263  const glm::quat& getRotation() const { return _rotation; }
264  const glm::vec3& getOverrideTranslation() const { return _overrideTranslation; }
265  const glm::quat& getOverrideRotation() const { return _overrideRotation; }
266 
267  glm::vec3 getNaturalDimensions() const;
268 
269  Transform getTransform() const;
270 
271  void setScale(const glm::vec3& scale);
272  const glm::vec3& getScale() const { return _scale; }
273 
275  bool getIsScaledToFit() const { return _scaledToFit; }
276  glm::vec3 getScaleToFitDimensions() const;
277 
278  int getBlendshapeCoefficientsNum() const { return _blendshapeCoefficients.size(); }
279  float getBlendshapeCoefficient(int index) const {
280  return ((index < 0) && (index >= _blendshapeCoefficients.size())) ? 0.0f : _blendshapeCoefficients.at(index);
281  }
282 
283  Rig& getRig() { return _rig; }
284  const Rig& getRig() const { return _rig; }
285 
286  const glm::vec3& getRegistrationPoint() const { return _registrationPoint; }
287 
288  // returns 'true' if needs fullUpdate after geometry change
289  virtual bool updateGeometry();
290 
291  void setLoadingPriority(float priority) { _loadingPriority = priority; }
292 
293  size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; }
294  size_t getRenderInfoTextureSize();
295  int getRenderInfoTextureCount();
296  int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; }
297  bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; }
298 
299  class TransformDualQuaternion {
300  public:
301  TransformDualQuaternion() {}
302  TransformDualQuaternion(const glm::mat4& m) {
303  AnimPose p(m);
304  _scale.x = p.scale().x;
305  _scale.y = p.scale().y;
306  _scale.z = p.scale().z;
307  _scale.w = 0.0f;
308  _dq = DualQuaternion(p.rot(), p.trans());
309  }
310  TransformDualQuaternion(const glm::vec3& scale, const glm::quat& rot, const glm::vec3& trans) {
311  _scale.x = scale.x;
312  _scale.y = scale.y;
313  _scale.z = scale.z;
314  _scale.w = 0.0f;
315  _dq = DualQuaternion(rot, trans);
316  }
317  TransformDualQuaternion(const Transform& transform) {
318  _scale = glm::vec4(transform.getScale(), 0.0f);
319  _scale.w = 0.0f;
320  _dq = DualQuaternion(transform.getRotation(), transform.getTranslation());
321  }
322  glm::vec3 getScale() const { return glm::vec3(_scale); }
323  glm::quat getRotation() const { return _dq.getRotation(); }
324  glm::vec3 getTranslation() const { return _dq.getTranslation(); }
325  glm::mat4 getMatrix() const { return createMatFromScaleQuatAndPos(getScale(), getRotation(), getTranslation()); };
326 
327  void setCauterizationParameters(float cauterizationAmount, const glm::vec3& cauterizedPosition) {
328  _scale.w = cauterizationAmount;
329  _cauterizedPosition = glm::vec4(cauterizedPosition, 1.0f);
330  }
331  protected:
332  glm::vec4 _scale { 1.0f, 1.0f, 1.0f, 0.0f };
333  DualQuaternion _dq;
334  glm::vec4 _cauterizedPosition { 0.0f, 0.0f, 0.0f, 1.0f };
335  };
336 
337  class MeshState {
338  public:
339  std::vector<TransformDualQuaternion> clusterDualQuaternions;
340  std::vector<glm::mat4> clusterMatrices;
341  };
342 
343  const MeshState& getMeshState(int index) { return _meshStates.at(index); }
344 
345  const QMap<render::ItemID, render::PayloadPointer>& getRenderItems() const { return _modelMeshRenderItemsMap; }
346  BlendShapeOperator getModelBlendshapeOperator() const { return _modelBlendshapeOperator; }
347 
348  void renderDebugMeshBoxes(gpu::Batch& batch, bool forward);
349 
350  int getResourceDownloadAttempts() { return _renderWatcher.getResourceDownloadAttempts(); }
351  int getResourceDownloadAttemptsRemaining() { return _renderWatcher.getResourceDownloadAttemptsRemaining(); }
352 
353  Q_INVOKABLE MeshProxyList getMeshes() const;
354  virtual scriptable::ScriptableModelBase getScriptableModel() override;
355  virtual bool replaceScriptableModelMeshPart(scriptable::ScriptableModelBasePointer model, int meshIndex, int partIndex) override;
356 
357  void scaleToFit();
358  void snapToRegistrationPoint();
359  bool getUseDualQuaternionSkinning() const { return _useDualQuaternionSkinning; }
360  void setUseDualQuaternionSkinning(bool value);
361 
362  void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName);
363  void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName);
364 
365  void setBlendshapeCoefficients(const QVector<float>& coefficients) { _blendshapeCoefficients = coefficients; }
366 
367 public slots:
368  void loadURLFinished(bool success);
369 
370 signals:
371  void setURLFinished(bool success);
372  void setCollisionModelURLFinished(bool success);
373  void requestRenderUpdate();
374  void rigReady();
375  void rigReset();
376 
377 protected:
378 
379  std::unordered_map<unsigned int, quint16> _priorityMap; // only used for materialMapping
380  std::unordered_map<unsigned int, std::vector<graphics::MaterialLayer>> _materialMapping; // generated during applyMaterialMapping
381  std::mutex _materialMappingMutex;
382  void applyMaterialMapping();
383 
384  const QVector<float>& getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
385 
387  void clearJointState(int index);
388 
392  bool getJointPosition(int jointIndex, glm::vec3& position) const;
393 
394  Geometry::Pointer _renderGeometry; // only ever set by its watcher
395 
396  GeometryResourceWatcher _renderWatcher;
397 
398  SpatiallyNestable* _spatiallyNestableOverride;
399 
400  glm::vec3 _translation; // this is the translation in world coordinates to the model's registration point
401  glm::quat _rotation;
402  glm::vec3 _scale { 1.0f };
403 
404  glm::vec3 _overrideTranslation;
405  glm::quat _overrideRotation;
406 
407  // For entity models this is the translation for the minimum extent of the model (in original mesh coordinate space)
408  // to the model's registration point. For avatar models this is the translation from the avatar's hips, as determined
409  // by the default pose, to the origin.
410  glm::vec3 _offset;
411 
412  static float FAKE_DIMENSION_PLACEHOLDER;
413 
414  bool _scaleToFit;
417 
420  glm::vec3 _registrationPoint { glm::vec3(0.5f) };
421  bool _forceOffset { false };
422 
423  std::vector<MeshState> _meshStates;
424 
425  virtual void initJointStates();
426 
427  void setScaleInternal(const glm::vec3& scale);
428 
429  virtual void updateRig(float deltaTime, glm::mat4 parentTransform);
430 
433  _triangleSetsValid = false;
434  }
435 
436  // hook for derived classes to be notified when setUrl invalidates the current model.
437  virtual void onInvalidate() {};
438 
439  virtual void deleteGeometry();
440 
441  QUrl _url;
442 
443  BlendShapeOperator _modelBlendshapeOperator { nullptr };
444  QVector<float> _blendshapeCoefficients;
445  QVector<float> _blendedBlendshapeCoefficients;
446  int _blendNumber { 0 };
447 
448  mutable QRecursiveMutex _mutex;
449 
450  bool _overrideModelTransform { false };
451  bool _triangleSetsValid { false };
452  void calculateTriangleSets(const HFMModel& hfmModel);
453  std::vector<std::vector<TriangleSet>> _modelSpaceMeshTriangleSets; // model space triangles for all sub meshes
454 
455  virtual void createRenderItemSet();
456 
457  PrimitiveMode _primitiveMode { PrimitiveMode::SOLID };
458  BillboardMode _billboardMode { BillboardMode::NONE };
459  bool _useDualQuaternionSkinning { false };
460 
461  // debug rendering support
462  int _debugMeshBoxesID = GeometryCache::UNKNOWN_ID;
463 
464  static AbstractViewStateInterface* _viewState;
465 
466  QVector<std::shared_ptr<ModelMeshPartPayload>> _modelMeshRenderItems;
467  QMap<render::ItemID, render::PayloadPointer> _modelMeshRenderItemsMap;
468  render::ItemIDs _modelMeshRenderItemIDs;
469  using ShapeInfo = struct { int meshIndex; };
470  std::vector<ShapeInfo> _modelMeshRenderItemShapes;
471  std::vector<std::string> _modelMeshMaterialNames;
472 
473  bool _addedToScene { false }; // has been added to scene
474  bool _needsFixupInScene { true }; // needs to be removed/re-added to scene
475  bool _needsReload { true };
476  bool _needsUpdateClusterMatrices { true };
477  QVariantMap _pendingTextures { };
478 
479  friend class ModelMeshPartPayload;
480  Rig _rig;
481 
482  bool _visualGeometryRequestFailed { false };
483 
484  bool _renderItemsNeedUpdate { false };
485 
486  size_t _renderInfoVertexCount { 0 };
487  int _renderInfoTextureCount { 0 };
488  size_t _renderInfoTextureSize { 0 };
489  bool _hasCalculatedTextureInfo { false };
490  int _renderInfoDrawCalls { 0 };
491  int _renderInfoHasTransparent { false };
492 
493  // This Render ItemKey Global Flags capture the Model wide global set of flags that should be communicated to all the render items representing the Model.
494  // The flags concerned are:
495  // - isVisible: if true the Model is visible globally in the scene, regardless of the other flags in the item keys (tags or layer or shadow caster).
496  // - TagBits: the view mask defined through the TagBits telling in which view the Model is rendered if visible.
497  // - Layer: In which Layer this Model lives.
498  // - CastShadow: if true and visible and rendered in the view, the Model cast shadows if in a Light volume casting shadows.
499  // - CullGroup: if true, the render items representing the parts of the Model are culled by a single Meta render item that knows about them, they are not culled individually.
500  // For this to work, a Meta RI must exists and knows about the RIs of this Model.
501  //
502  render::ItemKey _renderItemKeyGlobalFlags;
503  bool _cauterized { false };
504  bool _cullWithParent { false };
505  QVector<QUuid> _renderWithZones;
506 
507  bool shouldInvalidatePayloadShapeKey(int meshIndex);
508 
509  uint64_t _created;
510 
511 private:
512  float _loadingPriority { 0.0f };
513 
514  void calculateTextureInfo();
515 
516  std::set<unsigned int> getMeshIDsFromMaterialID(QString parentMaterialName);
517 };
518 
519 Q_DECLARE_METATYPE(ModelPointer)
520 Q_DECLARE_METATYPE(Geometry::WeakPointer)
521 Q_DECLARE_METATYPE(BlendshapeOffset)
522 
523 class ModelBlender : public QObject, public Dependency {
525  Q_OBJECT
526  SINGLETON_DEPENDENCY
527 
528 public:
529 
531  void noteRequiresBlend(ModelPointer model);
532 
533  bool shouldComputeBlendshapes() { return _computeBlendshapes; }
534 
535 public slots:
536  void setBlendedVertices(ModelPointer model, int blendNumber, QVector<BlendshapeOffset> blendshapeOffsets, QVector<int> blendedMeshSizes);
537  void setComputeBlendshapes(bool computeBlendshapes) { _computeBlendshapes = computeBlendshapes; }
538 
539 private:
540  using Mutex = std::mutex;
541  using Lock = std::unique_lock<Mutex>;
542 
543  ModelBlender();
544  virtual ~ModelBlender();
545 
546  std::queue<ModelWeakPointer> _modelsRequiringBlendsQueue;
547  std::set<ModelWeakPointer, std::owner_less<ModelWeakPointer>> _modelsRequiringBlendsSet;
548  int _pendingBlenders;
549  Mutex _mutex;
550 
551  bool _computeBlendshapes { true };
552 };
553 
554 
555 #endif // hifi_Model_h
Interface provided by Application to other objects that need access to the current view state details...
Definition: AbstractViewStateInterface.h:31
A generic 3D model displaying geometry loaded from a URL.
Definition: Model.h:84
const HFMModel & getHFMModel() const
Provided as a convenience, will crash if !isLoaded()
Definition: Model.h:189
bool _snappedToRegistrationPoint
is the model's offset automatically adjusted to a registration point in model space
Definition: Model.h:419
glm::vec3 _scaleToFitDimensions
If you set scaleToFit, we will calculate scale based on MeshExtents.
Definition: Model.h:415
bool _forceOffset
the point in model space our center is snapped to
Definition: Model.h:421
Extents getBindExtents() const
Returns the extents of the model in its bind pose.
Definition: Model.cpp:1208
Extents getUnscaledMeshExtents() const
Returns the unscaled extents of the model's mesh.
Definition: Model.cpp:1227
bool getJointPosition(int jointIndex, glm::vec3 &position) const
Definition: Model.cpp:1322
void clearJointState(int index)
Clear the joint states.
Definition: Model.cpp:1243
glm::vec3 getScaleToFitDimensions() const
is model scaled to fit
Definition: Model.cpp:1402
bool getIsScaledToFit() const
enables/disables scale to fit behavior, the model will be automatically scaled to the specified large...
Definition: Model.h:275
const Geometry::Pointer & getGeometry() const
Returns a reference to the shared geometry.
Definition: Model.h:182
bool _snapModelToRegistrationPoint
have we scaled to fit
Definition: Model.h:418
Extents getMeshExtents() const
Returns the extents of the model's mesh.
Definition: Model.cpp:1222
int getBlendshapeCoefficientsNum() const
the dimensions model is scaled to, including inferred y/z
Definition: Model.h:278
void setJointState(int index, bool valid, const glm::quat &rotation, const glm::vec3 &translation, float priority)
Sets the joint state at the specified index.
Definition: Model.cpp:1247
glm::vec3 _registrationPoint
are we currently snapped to a registration point
Definition: Model.h:420
void setSnapModelToCenter(bool snapModelToCenter)
is scale to fit enabled
Definition: Model.h:218
bool getJointRotation(int jointIndex, glm::quat &rotation) const
Definition: Model.cpp:1330
int getJointStateCount() const
Returns the number of joint states in the model.
Definition: Model.h:226
void invalidCalculatedMeshBoxes()
Allow sub classes to force invalidating the bboxes.
Definition: Model.h:432
virtual Q_INVOKABLE void setURL(const QUrl &url)
Sets the URL of the model to render.
Definition: Model.cpp:1273
bool _scaledToFit
this is the dimensions that scale to fit will use
Definition: Model.h:416
int getParentJointIndex(int jointIndex) const
Returns the index of the parent of the indexed joint, or -1 if not found.
Definition: Model.cpp:1259
The runtime model format.
Definition: HFM.h:302