mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge pull request #3203 from Atlante45/laser_pointer_js
Laser pointer js
This commit is contained in:
commit
e272d0be75
6 changed files with 75 additions and 9 deletions
23
examples/laserPointer.js
Normal file
23
examples/laserPointer.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// laserPointer.js
|
||||
// examples
|
||||
//
|
||||
// Created by Clément Brisset on 7/18/14.
|
||||
// Copyright 2014 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
|
||||
//
|
||||
|
||||
var LEFT = 0;
|
||||
var RIGHT = 1;
|
||||
var LEFT_HAND_FLAG = 1;
|
||||
var RIGHT_HAND_FLAG = 2;
|
||||
|
||||
function update() {
|
||||
var state = ((Controller.getTriggerValue(LEFT) > 0.9) ? LEFT_HAND_FLAG : 0) +
|
||||
((Controller.getTriggerValue(RIGHT) > 0.9) ? RIGHT_HAND_FLAG : 0);
|
||||
MyAvatar.setHandState(state);
|
||||
}
|
||||
|
||||
Script.update.connect(update);
|
|
@ -218,6 +218,52 @@ static TextRenderer* textRenderer(TextRendererType type) {
|
|||
}
|
||||
|
||||
void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) {
|
||||
|
||||
if (glm::distance(Application::getInstance()->getAvatar()->getPosition(),
|
||||
_position) < 10.0f) {
|
||||
// render pointing lasers
|
||||
glm::vec3 laserColor = glm::vec3(1.0f, 0.0f, 1.0f);
|
||||
float laserLength = 50.0f;
|
||||
if (_handState == HAND_STATE_LEFT_POINTING ||
|
||||
_handState == HAND_STATE_BOTH_POINTING) {
|
||||
int leftIndex = _skeletonModel.getLeftHandJointIndex();
|
||||
glm::vec3 leftPosition;
|
||||
glm::quat leftRotation;
|
||||
_skeletonModel.getJointPositionInWorldFrame(leftIndex, leftPosition);
|
||||
_skeletonModel.getJointRotationInWorldFrame(leftIndex, leftRotation);
|
||||
glPushMatrix(); {
|
||||
glTranslatef(leftPosition.x, leftPosition.y, leftPosition.z);
|
||||
float angle = glm::degrees(glm::angle(leftRotation));
|
||||
glm::vec3 axis = glm::axis(leftRotation);
|
||||
glRotatef(angle, axis.x, axis.y, axis.z);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(laserColor.x, laserColor.y, laserColor.z);
|
||||
glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.0f, laserLength, 0.0f);
|
||||
glEnd();
|
||||
} glPopMatrix();
|
||||
}
|
||||
if (_handState == HAND_STATE_RIGHT_POINTING ||
|
||||
_handState == HAND_STATE_BOTH_POINTING) {
|
||||
int rightIndex = _skeletonModel.getRightHandJointIndex();
|
||||
glm::vec3 rightPosition;
|
||||
glm::quat rightRotation;
|
||||
_skeletonModel.getJointPositionInWorldFrame(rightIndex, rightPosition);
|
||||
_skeletonModel.getJointRotationInWorldFrame(rightIndex, rightRotation);
|
||||
glPushMatrix(); {
|
||||
glTranslatef(rightPosition.x, rightPosition.y, rightPosition.z);
|
||||
float angle = glm::degrees(glm::angle(rightRotation));
|
||||
glm::vec3 axis = glm::axis(rightRotation);
|
||||
glRotatef(angle, axis.x, axis.y, axis.z);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(laserColor.x, laserColor.y, laserColor.z);
|
||||
glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.0f, laserLength, 0.0f);
|
||||
glEnd();
|
||||
} glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
// simple frustum check
|
||||
float boundingRadius = getBillboardSize();
|
||||
ViewFrustum* frustum = (renderMode == Avatar::SHADOW_RENDER_MODE) ?
|
||||
|
|
|
@ -125,7 +125,7 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) {
|
|||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void Hand::renderHandTargets(bool isMine) {
|
||||
glPushMatrix();
|
||||
|
|
|
@ -137,9 +137,6 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
}
|
||||
_skeletonModel.setShowTrueJointTransforms(! Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll));
|
||||
|
||||
// no extra movement of the hand here any more ...
|
||||
_handState = HAND_STATE_NULL;
|
||||
|
||||
{
|
||||
PerformanceTimer perfTimer("transform");
|
||||
updateOrientation(deltaTime);
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
enum AvatarHandState
|
||||
{
|
||||
HAND_STATE_NULL = 0,
|
||||
HAND_STATE_OPEN,
|
||||
HAND_STATE_GRASPING,
|
||||
HAND_STATE_POINTING,
|
||||
HAND_STATE_LEFT_POINTING,
|
||||
HAND_STATE_RIGHT_POINTING,
|
||||
HAND_STATE_BOTH_POINTING,
|
||||
NUM_HAND_STATES
|
||||
};
|
||||
|
||||
|
|
|
@ -185,8 +185,8 @@ public:
|
|||
void setClampedTargetScale(float targetScale);
|
||||
|
||||
// Hand State
|
||||
void setHandState(char s) { _handState = s; }
|
||||
char getHandState() const { return _handState; }
|
||||
Q_INVOKABLE void setHandState(char s) { _handState = s; }
|
||||
Q_INVOKABLE char getHandState() const { return _handState; }
|
||||
|
||||
const QVector<JointData>& getJointData() const { return _jointData; }
|
||||
void setJointData(const QVector<JointData>& jointData) { _jointData = jointData; }
|
||||
|
|
Loading…
Reference in a new issue