mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Create TransformNodes for SpatiallyNestables, the mouse, and MyAvatar head
This commit is contained in:
parent
fcdbc6c6d2
commit
3167d3c0c7
7 changed files with 182 additions and 0 deletions
23
interface/src/avatar/MyAvatarHeadTransformNode.cpp
Normal file
23
interface/src/avatar/MyAvatarHeadTransformNode.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Copyright 2018 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 "MyAvatarHeadTransformNode.h"
|
||||
|
||||
#include "DependencyManager.h"
|
||||
#include "AvatarManager.h"
|
||||
#include "MyAvatar.h"
|
||||
|
||||
Transform MyAvatarHeadTransformNode::getTransform() {
|
||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
glm::vec3 pos = myAvatar->getHeadPosition();
|
||||
glm::quat headOri = myAvatar->getHeadOrientation();
|
||||
glm::quat ori = headOri * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT);
|
||||
|
||||
return Transform(ori, myAvatar->scaleForChildren(), pos);
|
||||
}
|
19
interface/src/avatar/MyAvatarHeadTransformNode.h
Normal file
19
interface/src/avatar/MyAvatarHeadTransformNode.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Copyright 2018 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_MyAvatarHeadTransformNode_h
|
||||
#define hifi_MyAvatarHeadTransformNode_h
|
||||
|
||||
#include "TransformNode.h"
|
||||
|
||||
class MyAvatarHeadTransformNode : public TransformNode {
|
||||
public:
|
||||
MyAvatarHeadTransformNode() { }
|
||||
Transform getTransform() override;
|
||||
};
|
||||
|
||||
#endif // hifi_MyAvatarHeadTransformNode_h
|
43
interface/src/raypick/MouseTransformNode.cpp
Normal file
43
interface/src/raypick/MouseTransformNode.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Copyright 2018 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 "MouseTransformNode.h"
|
||||
|
||||
#include "DependencyManager.h"
|
||||
#include "PickManager.h"
|
||||
#include "MouseRayPick.h"
|
||||
|
||||
const PickFilter MOUSE_TRANSFORM_NODE_PICK_FILTER(
|
||||
1 << PickFilter::PICK_ENTITIES |
|
||||
1 << PickFilter::PICK_AVATARS |
|
||||
1 << PickFilter::PICK_INCLUDE_NONCOLLIDABLE
|
||||
);
|
||||
const float MOUSE_TRANSFORM_NODE_MAX_DISTANCE = 1000.0f;
|
||||
|
||||
MouseTransformNode::MouseTransformNode() {
|
||||
_parentMouseRayPick = DependencyManager::get<PickManager>()->addPick(PickQuery::Ray,
|
||||
std::make_shared<MouseRayPick>(MOUSE_TRANSFORM_NODE_PICK_FILTER, MOUSE_TRANSFORM_NODE_MAX_DISTANCE, true));
|
||||
}
|
||||
|
||||
MouseTransformNode::~MouseTransformNode() {
|
||||
if (DependencyManager::isSet<PickManager>()) {
|
||||
auto pickManager = DependencyManager::get<PickManager>();
|
||||
if (pickManager) {
|
||||
pickManager->removePick(_parentMouseRayPick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform MouseTransformNode::getTransform() {
|
||||
Transform transform;
|
||||
std::shared_ptr<RayPickResult> rayPickResult = DependencyManager::get<PickManager>()->getPrevPickResultTyped<RayPickResult>(_parentMouseRayPick);
|
||||
if (rayPickResult) {
|
||||
transform.setTranslation(rayPickResult->intersection);
|
||||
}
|
||||
return transform;
|
||||
}
|
23
interface/src/raypick/MouseTransformNode.h
Normal file
23
interface/src/raypick/MouseTransformNode.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Copyright 2018 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_MouseTransformNode_h
|
||||
#define hifi_MouseTransformNode_h
|
||||
|
||||
#include "TransformNode.h"
|
||||
|
||||
class MouseTransformNode : public TransformNode {
|
||||
public:
|
||||
MouseTransformNode();
|
||||
~MouseTransformNode();
|
||||
Transform getTransform() override;
|
||||
|
||||
protected:
|
||||
unsigned int _parentMouseRayPick = 0;
|
||||
};
|
||||
|
||||
#endif // hifi_MouseTransformNode_h
|
31
libraries/shared/src/NestableTransformNode.cpp
Normal file
31
libraries/shared/src/NestableTransformNode.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Copyright 2018 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 "NestableTransformNode.h"
|
||||
|
||||
NestableTransformNode::NestableTransformNode(SpatiallyNestableWeakPointer spatiallyNestable, int jointIndex) :
|
||||
_spatiallyNestable(spatiallyNestable),
|
||||
_jointIndex(jointIndex)
|
||||
{
|
||||
}
|
||||
|
||||
Transform NestableTransformNode::getTransform() {
|
||||
auto nestable = _spatiallyNestable.lock();
|
||||
if (!nestable) {
|
||||
return Transform();
|
||||
}
|
||||
|
||||
bool success;
|
||||
Transform jointWorldTransform = nestable->getTransform(_jointIndex, success, 30);
|
||||
|
||||
if (success) {
|
||||
return jointWorldTransform;
|
||||
} else {
|
||||
return Transform();
|
||||
}
|
||||
}
|
25
libraries/shared/src/NestableTransformNode.h
Normal file
25
libraries/shared/src/NestableTransformNode.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Copyright 2018 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_NestableTransformNode_h
|
||||
#define hifi_NestableTransformNode_h
|
||||
|
||||
#include "TransformNode.h"
|
||||
|
||||
#include "SpatiallyNestable.h"
|
||||
|
||||
class NestableTransformNode : public TransformNode {
|
||||
public:
|
||||
NestableTransformNode(SpatiallyNestableWeakPointer spatiallyNestable, int jointIndex);
|
||||
Transform getTransform() override;
|
||||
|
||||
protected:
|
||||
SpatiallyNestableWeakPointer _spatiallyNestable;
|
||||
int _jointIndex;
|
||||
};
|
||||
|
||||
#endif // hifi_NestableTransformNode_h
|
18
libraries/shared/src/TransformNode.h
Normal file
18
libraries/shared/src/TransformNode.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Copyright 2018 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_TransformNode_h
|
||||
#define hifi_TransformNode_h
|
||||
|
||||
#include "Transform.h"
|
||||
|
||||
class TransformNode {
|
||||
public:
|
||||
virtual Transform getTransform() = 0;
|
||||
};
|
||||
|
||||
#endif // hifi_TransformNode_h
|
Loading…
Reference in a new issue