mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
new class: SpatiallyNestable
This commit is contained in:
parent
4289d54bd9
commit
7977f4640d
2 changed files with 84 additions and 0 deletions
37
libraries/shared/src/SpatiallyNestable.cpp
Normal file
37
libraries/shared/src/SpatiallyNestable.cpp
Normal file
|
@ -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;
|
||||
}
|
47
libraries/shared/src/SpatiallyNestable.h
Normal file
47
libraries/shared/src/SpatiallyNestable.h
Normal file
|
@ -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 <QUuid>
|
||||
|
||||
#include "Transform.h"
|
||||
|
||||
|
||||
class SpatiallyNestable;
|
||||
typedef std::weak_ptr<SpatiallyNestable> SpatiallyNestableWeakPointer;
|
||||
typedef std::shared_ptr<SpatiallyNestable> 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<SpatiallyNestableWeakPointer> _children;
|
||||
};
|
||||
|
||||
|
||||
#endif // hifi_SpatiallyNestable_h
|
Loading…
Reference in a new issue