mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:51:17 +02:00
Added pointing behaviour
This commit is contained in:
parent
f8772e10a1
commit
35caef1882
3 changed files with 49 additions and 3 deletions
|
@ -215,6 +215,52 @@ static TextRenderer* textRenderer(TextRendererType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) {
|
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_RIGTH_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
|
// simple frustum check
|
||||||
float boundingRadius = getBillboardSize();
|
float boundingRadius = getBillboardSize();
|
||||||
ViewFrustum* frustum = (renderMode == Avatar::SHADOW_RENDER_MODE) ?
|
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_DEPTH_TEST);
|
||||||
glEnable(GL_RESCALE_NORMAL);
|
glEnable(GL_RESCALE_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hand::renderHandTargets(bool isMine) {
|
void Hand::renderHandTargets(bool isMine) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
|
@ -185,8 +185,8 @@ public:
|
||||||
void setClampedTargetScale(float targetScale);
|
void setClampedTargetScale(float targetScale);
|
||||||
|
|
||||||
// Hand State
|
// Hand State
|
||||||
void setHandState(char s) { _handState = s; }
|
Q_INVOKABLE void setHandState(char s) { _handState = s; }
|
||||||
char getHandState() const { return _handState; }
|
Q_INVOKABLE char getHandState() const { return _handState; }
|
||||||
|
|
||||||
const QVector<JointData>& getJointData() const { return _jointData; }
|
const QVector<JointData>& getJointData() const { return _jointData; }
|
||||||
void setJointData(const QVector<JointData>& jointData) { _jointData = jointData; }
|
void setJointData(const QVector<JointData>& jointData) { _jointData = jointData; }
|
||||||
|
|
Loading…
Reference in a new issue