mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 15:23:56 +02:00
improved debug render of hand coordinates
also cleaned up includes in Hand.h
This commit is contained in:
parent
f51f17b267
commit
8d5106b072
5 changed files with 53 additions and 75 deletions
|
@ -602,7 +602,10 @@ void Avatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, floa
|
|||
getHead()->render(renderArgs, 1.0f, renderFrustum);
|
||||
}
|
||||
|
||||
getHand()->render(renderArgs, false);
|
||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE ||
|
||||
!Menu::getInstance()->isOptionChecked(MenuOption::DisplayHandTargets)) {
|
||||
getHand()->renderHandTargets(renderArgs, false);
|
||||
}
|
||||
}
|
||||
getHead()->renderLookAts(renderArgs);
|
||||
}
|
||||
|
|
|
@ -8,22 +8,21 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QImage>
|
||||
#include "Hand.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <GeometryUtil.h>
|
||||
#include <NodeList.h>
|
||||
#include <RenderArgs.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
#include "AvatarManager.h"
|
||||
#include "Hand.h"
|
||||
#include "Menu.h"
|
||||
#include "MyAvatar.h"
|
||||
#include "Util.h"
|
||||
#include "world.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const float PALM_COLLISION_RADIUS = 0.03f;
|
||||
|
||||
|
||||
Hand::Hand(Avatar* owningAvatar) :
|
||||
HandData((AvatarData*)owningAvatar),
|
||||
_owningAvatar(owningAvatar)
|
||||
|
@ -40,76 +39,63 @@ void Hand::simulate(float deltaTime, bool isMine) {
|
|||
}
|
||||
}
|
||||
|
||||
void Hand::render(RenderArgs* renderArgs, bool isMine) {
|
||||
void Hand::renderHandTargets(RenderArgs* renderArgs, bool isMine) {
|
||||
const float avatarScale = DependencyManager::get<AvatarManager>()->getMyAvatar()->getScale();
|
||||
|
||||
const float alpha = 1.0f;
|
||||
const glm::vec3 redColor(1.0f, 0.0f, 0.0f); // Color the hand targets red to be different than skin
|
||||
const glm::vec3 greenColor(0.0f, 1.0f, 0.0f); // Color the hand targets red to be different than skin
|
||||
const glm::vec3 blueColor(0.0f, 0.0f, 1.0f); // Color the hand targets red to be different than skin
|
||||
const glm::vec3 grayColor(0.5f);
|
||||
const int NUM_FACETS = 10;
|
||||
const float SPHERE_RADIUS = 0.03f * avatarScale;
|
||||
|
||||
gpu::Batch& batch = *renderArgs->_batch;
|
||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE &&
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionShapes)) {
|
||||
// draw a green sphere at hand joint location, which is actually near the wrist)
|
||||
if (isMine) {
|
||||
for (size_t i = 0; i < getNumPalms(); i++) {
|
||||
PalmData& palm = getPalms()[i];
|
||||
if (!palm.isActive()) {
|
||||
continue;
|
||||
}
|
||||
// draw a gray sphere at the target position of the "Hand" joint
|
||||
glm::vec3 position = palm.getPosition();
|
||||
Transform transform = Transform();
|
||||
transform.setTranslation(position);
|
||||
batch.setModelTransform(transform);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(batch, PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(batch, SPHERE_RADIUS,
|
||||
NUM_FACETS, NUM_FACETS, grayColor);
|
||||
|
||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHands)) {
|
||||
renderHandTargets(renderArgs, isMine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Hand::renderHandTargets(RenderArgs* renderArgs, bool isMine) {
|
||||
gpu::Batch& batch = *renderArgs->_batch;
|
||||
const float avatarScale = DependencyManager::get<AvatarManager>()->getMyAvatar()->getScale();
|
||||
|
||||
const float alpha = 1.0f;
|
||||
const glm::vec3 handColor(1.0, 0.0, 0.0); // Color the hand targets red to be different than skin
|
||||
|
||||
if (isMine && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHandTargets)) {
|
||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||
PalmData& palm = getPalms()[i];
|
||||
if (!palm.isActive()) {
|
||||
continue;
|
||||
}
|
||||
glm::vec3 targetPosition = palm.getTipPosition();
|
||||
Transform transform = Transform();
|
||||
transform.setTranslation(targetPosition);
|
||||
// draw a green sphere at the old "finger tip"
|
||||
position = palm.getTipPosition();
|
||||
transform.setTranslation(position);
|
||||
batch.setModelTransform(transform);
|
||||
|
||||
const float collisionRadius = 0.05f;
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(batch, collisionRadius, 10, 10, glm::vec4(0.5f,0.5f,0.5f, alpha), false);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(batch, SPHERE_RADIUS,
|
||||
NUM_FACETS, NUM_FACETS, greenColor);
|
||||
}
|
||||
}
|
||||
|
||||
const float PALM_BALL_RADIUS = 0.03f * avatarScale;
|
||||
const float PALM_DISK_RADIUS = 0.06f * avatarScale;
|
||||
const float PALM_DISK_THICKNESS = 0.01f * avatarScale;
|
||||
const float PALM_FINGER_ROD_RADIUS = 0.003f * avatarScale;
|
||||
|
||||
// Draw the palm ball and disk
|
||||
const float AXIS_RADIUS = 0.1f * SPHERE_RADIUS;
|
||||
const float AXIS_LENGTH = 10.0f * SPHERE_RADIUS;
|
||||
|
||||
// Draw the coordinate frames of the hand targets
|
||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||
PalmData& palm = getPalms()[i];
|
||||
if (palm.isActive()) {
|
||||
glm::vec3 tip = palm.getTipPosition();
|
||||
glm::vec3 root = palm.getPosition();
|
||||
|
||||
const glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
|
||||
glm::quat palmRotation = palm.getRotation();
|
||||
Transform transform = Transform();
|
||||
transform.setTranslation(glm::vec3());
|
||||
batch.setModelTransform(transform);
|
||||
Avatar::renderJointConnectingCone(batch, root, tip, PALM_FINGER_ROD_RADIUS, PALM_FINGER_ROD_RADIUS, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||
glm::vec3 tip = root + palmRotation * glm::vec3(AXIS_LENGTH, 0.0f, 0.0f);
|
||||
Avatar::renderJointConnectingCone(batch, root, tip, AXIS_RADIUS, AXIS_RADIUS, glm::vec4(redColor.r, redColor.g, redColor.b, alpha));
|
||||
|
||||
// Render sphere at palm/finger root
|
||||
glm::vec3 offsetFromPalm = root + palm.getNormal() * PALM_DISK_THICKNESS;
|
||||
Avatar::renderJointConnectingCone(batch, root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||
transform = Transform();
|
||||
transform.setTranslation(root);
|
||||
batch.setModelTransform(transform);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(batch, PALM_BALL_RADIUS, 20.0f, 20.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||
tip = root + palmRotation * glm::vec3(0.0f, AXIS_LENGTH, 0.0f);
|
||||
Avatar::renderJointConnectingCone(batch, root, tip, AXIS_RADIUS, AXIS_RADIUS, glm::vec4(greenColor.r, greenColor.g, greenColor.b, alpha));
|
||||
|
||||
tip = root + palmRotation * glm::vec3(0.0f, 0.0f, AXIS_LENGTH);
|
||||
Avatar::renderJointConnectingCone(batch, root, tip, AXIS_RADIUS, AXIS_RADIUS, glm::vec4(blueColor.r, blueColor.g, blueColor.b, alpha));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,41 +11,26 @@
|
|||
#ifndef hifi_Hand_h
|
||||
#define hifi_Hand_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include <AvatarData.h>
|
||||
#include <AudioScriptingInterface.h>
|
||||
#include <HandData.h>
|
||||
#include <Model.h>
|
||||
|
||||
#include "world.h"
|
||||
|
||||
|
||||
class Avatar;
|
||||
class RenderArgs;
|
||||
|
||||
class Hand : public HandData {
|
||||
public:
|
||||
Hand(Avatar* owningAvatar);
|
||||
|
||||
void simulate(float deltaTime, bool isMine);
|
||||
void render(RenderArgs* renderArgs, bool isMine);
|
||||
void renderHandTargets(RenderArgs* renderArgs, bool isMine);
|
||||
|
||||
private:
|
||||
// disallow copies of the Hand, copy of owning Avatar is disallowed too
|
||||
Hand(const Hand&);
|
||||
Hand& operator= (const Hand&);
|
||||
|
||||
int _controllerButtons; /// Button states read from hand-held controllers
|
||||
int _controllerButtons; /// Button states read from hand-held controllers
|
||||
|
||||
Avatar* _owningAvatar;
|
||||
|
||||
void renderHandTargets(RenderArgs* renderArgs, bool isMine);
|
||||
Avatar* _owningAvatar;
|
||||
};
|
||||
|
||||
#endif // hifi_Hand_h
|
||||
|
|
|
@ -1232,7 +1232,10 @@ void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, fl
|
|||
getHead()->renderLookAts(renderArgs);
|
||||
}
|
||||
|
||||
getHand()->render(renderArgs, true);
|
||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE ||
|
||||
!Menu::getInstance()->isOptionChecked(MenuOption::DisplayHandTargets)) {
|
||||
getHand()->renderHandTargets(renderArgs, true);
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visible) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <NumericalConstants.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
class AvatarData;
|
||||
class PalmData;
|
||||
|
|
Loading…
Reference in a new issue