iMSTK
Interactive Medical Simulation Toolkit
imstkSceneObjectController.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "imstkSceneObjectController.h"
8 #include "imstkCollidingObject.h"
9 #include "imstkDeviceClient.h"
10 #include "imstkGeometry.h"
11 #include "imstkLogger.h"
12 
13 namespace imstk
14 {
15 SceneObjectController::SceneObjectController(const std::string& name) :
16  TrackingDeviceControl(name)
17 {
18 }
19 
20 void
22 {
23  if (!updateTrackingData(dt))
24  {
25  LOG(WARNING) << "warning: could not update tracking info.";
26  return;
27  }
28 
29  if (m_sceneObject == nullptr)
30  {
31  return;
32  }
33 
34  if (!m_deviceClient->getTrackingEnabled())
35  {
36  return;
37  }
38 
39  this->postEvent(Event(SceneObjectController::modified()));
40 
41  // Update geometry
42  // \todo revisit this; what if we need to move a group of objects
43  m_sceneObject->getVisualGeometry()->setTranslation(getPosition());
44  m_sceneObject->getVisualGeometry()->setRotation(getOrientation());
45  m_sceneObject->getVisualGeometry()->postModified();
46 }
47 } // namespace imstk
std::shared_ptr< SceneObject > m_sceneObject
SceneObject controlled by the Tracker.
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
virtual bool updateTrackingData(const double dt)
Update tracking data.
Compound Geometry.
const Quatd & getOrientation() const
Set/Get the orientation of the tracker.
void update(const double &dt) override
Update controlled scene object using latest tracking information.
const Vec3d & getPosition() const
Set/Get the position of the tracker.
void postEvent(const T &e)
Emits the event Direct observers will be immediately called, in sync Queued observers will receive th...