From 7977f4640dc53c8226dc6be969775acedee7c78b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sun, 18 Oct 2015 07:27:22 -0700 Subject: [PATCH] new class: SpatiallyNestable --- libraries/shared/src/SpatiallyNestable.cpp | 37 +++++++++++++++++ libraries/shared/src/SpatiallyNestable.h | 47 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 libraries/shared/src/SpatiallyNestable.cpp create mode 100644 libraries/shared/src/SpatiallyNestable.h diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp new file mode 100644 index 0000000000..5e14f398ea --- /dev/null +++ b/libraries/shared/src/SpatiallyNestable.cpp @@ -0,0 +1,37 @@ +// +// SpatiallyNestable.cpp +// libraries/shared/src/ +// +// Created by Seth Alves on 2015-10-18 +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "SpatiallyNestable.h" + +SpatiallyNestable::SpatiallyNestable() : + _transform() { +} + + +const glm::vec3& SpatiallyNestable::getPosition() const { + return _transform.getTranslation(); +} + +void SpatiallyNestable::setPosition(const glm::vec3& position) { + _transform.setTranslation(position); +} + +const glm::quat& SpatiallyNestable::getOrientation() const { + return _transform.getRotation(); +} + +void SpatiallyNestable::setOrientation(const glm::quat& orientation) { + _transform.setRotation(orientation); +} + +const Transform& SpatiallyNestable::getTransform() const { + return _transform; +} diff --git a/libraries/shared/src/SpatiallyNestable.h b/libraries/shared/src/SpatiallyNestable.h new file mode 100644 index 0000000000..dd57f27477 --- /dev/null +++ b/libraries/shared/src/SpatiallyNestable.h @@ -0,0 +1,47 @@ +// +// SpatiallyNestable.h +// libraries/shared/src/ +// +// Created by Seth Alves on 2015-10-18 +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_SpatiallyNestable_h +#define hifi_SpatiallyNestable_h + +#include + +#include "Transform.h" + + +class SpatiallyNestable; +typedef std::weak_ptr SpatiallyNestableWeakPointer; +typedef std::shared_ptr SpatiallyNestablePointer; + +class SpatiallyNestable { + +public: + SpatiallyNestable(); + virtual ~SpatiallyNestable() { } + + virtual const glm::vec3& getPosition() const; + virtual void setPosition(const glm::vec3& position); + virtual const glm::quat& getOrientation() const; + virtual void setOrientation(const glm::quat& orientation); + virtual const Transform& getTransform() const; + +protected: + Transform _transform; + + QUuid _parentID; // what is this thing's transform relative to? + int _parentJointIndex; // which joint of the parent is this relative to? + + SpatiallyNestableWeakPointer _parent; + QVector _children; +}; + + +#endif // hifi_SpatiallyNestable_h