mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:41:20 +02:00
Merge pull request #5247 from ericrius1/handRender
Fixed broken rendering of hydra visualization paraphernalia
This commit is contained in:
commit
af932fde29
9 changed files with 43 additions and 53 deletions
|
@ -3548,7 +3548,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
}
|
}
|
||||||
//Render the sixense lasers
|
//Render the sixense lasers
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) {
|
||||||
_myAvatar->renderLaserPointers();
|
_myAvatar->renderLaserPointers(*renderArgs->_batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selfAvatarOnly) {
|
if (!selfAvatarOnly) {
|
||||||
|
|
|
@ -449,7 +449,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, boo
|
||||||
getHead()->getFaceModel().renderJointCollisionShapes(0.7f);
|
getHead()->getFaceModel().renderJointCollisionShapes(0.7f);
|
||||||
}
|
}
|
||||||
if (renderBounding && shouldRenderHead(renderArgs)) {
|
if (renderBounding && shouldRenderHead(renderArgs)) {
|
||||||
_skeletonModel.renderBoundingCollisionShapes(0.7f);
|
_skeletonModel.renderBoundingCollisionShapes(*renderArgs->_batch, 0.7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is the avatar being looked at, render a little ball above their head
|
// If this is the avatar being looked at, render a little ball above their head
|
||||||
|
@ -1010,7 +1010,7 @@ int Avatar::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
int Avatar::_jointConesID = GeometryCache::UNKNOWN_ID;
|
int Avatar::_jointConesID = GeometryCache::UNKNOWN_ID;
|
||||||
|
|
||||||
// render a makeshift cone section that serves as a body part connecting joint spheres
|
// render a makeshift cone section that serves as a body part connecting joint spheres
|
||||||
void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
void Avatar::renderJointConnectingCone(gpu::Batch& batch, glm::vec3 position1, glm::vec3 position2,
|
||||||
float radius1, float radius2, const glm::vec4& color) {
|
float radius1, float radius2, const glm::vec4& color) {
|
||||||
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
@ -1057,7 +1057,7 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
||||||
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
|
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
|
||||||
// better if the avatars cached these buffers for each of the joints they are rendering
|
// better if the avatars cached these buffers for each of the joints they are rendering
|
||||||
geometryCache->updateVertices(_jointConesID, points, color);
|
geometryCache->updateVertices(_jointConesID, points, color);
|
||||||
geometryCache->renderVertices(gpu::TRIANGLES, _jointConesID);
|
geometryCache->renderVertices(batch, gpu::TRIANGLES, _jointConesID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ public:
|
||||||
|
|
||||||
virtual int parseDataAtOffset(const QByteArray& packet, int offset);
|
virtual int parseDataAtOffset(const QByteArray& packet, int offset);
|
||||||
|
|
||||||
static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
static void renderJointConnectingCone( gpu::Batch& batch, glm::vec3 position1, glm::vec3 position2,
|
||||||
float radius1, float radius2, const glm::vec4& color);
|
float radius1, float radius2, const glm::vec4& color);
|
||||||
|
|
||||||
virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { }
|
virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { }
|
||||||
|
|
|
@ -103,7 +103,8 @@ void Hand::resolvePenetrations() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hand::render(RenderArgs* renderArgs, bool isMine) {
|
void Hand::render(RenderArgs* renderArgs, bool isMine) {
|
||||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE &&
|
gpu::Batch& batch = *renderArgs->_batch;
|
||||||
|
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE &&
|
||||||
Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionShapes)) {
|
Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionShapes)) {
|
||||||
// draw a green sphere at hand joint location, which is actually near the wrist)
|
// draw a green sphere at hand joint location, which is actually near the wrist)
|
||||||
for (size_t i = 0; i < getNumPalms(); i++) {
|
for (size_t i = 0; i < getNumPalms(); i++) {
|
||||||
|
@ -112,31 +113,25 @@ void Hand::render(RenderArgs* renderArgs, bool isMine) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
glm::vec3 position = palm.getPosition();
|
glm::vec3 position = palm.getPosition();
|
||||||
glPushMatrix();
|
Transform transform = Transform();
|
||||||
glTranslatef(position.x, position.y, position.z);
|
transform.setTranslation(position);
|
||||||
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10, glm::vec3(0.0f, 1.0f, 0.0f));
|
batch.setModelTransform(transform);
|
||||||
glPopMatrix();
|
DependencyManager::get<GeometryCache>()->renderSphere(batch, PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHands)) {
|
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHands)) {
|
||||||
renderHandTargets(isMine);
|
renderHandTargets(renderArgs, isMine);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
}
|
||||||
glEnable(GL_RESCALE_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hand::renderHandTargets(bool isMine) {
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
|
void Hand::renderHandTargets(RenderArgs* renderArgs, bool isMine) {
|
||||||
|
gpu::Batch& batch = *renderArgs->_batch;
|
||||||
const float avatarScale = DependencyManager::get<AvatarManager>()->getMyAvatar()->getScale();
|
const float avatarScale = DependencyManager::get<AvatarManager>()->getMyAvatar()->getScale();
|
||||||
|
|
||||||
const float alpha = 1.0f;
|
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
|
const glm::vec3 handColor(1.0, 0.0, 0.0); // Color the hand targets red to be different than skin
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
|
|
||||||
if (isMine && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHandTargets)) {
|
if (isMine && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHandTargets)) {
|
||||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||||
|
@ -145,12 +140,12 @@ void Hand::renderHandTargets(bool isMine) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
glm::vec3 targetPosition = palm.getTipPosition();
|
glm::vec3 targetPosition = palm.getTipPosition();
|
||||||
glPushMatrix();
|
Transform transform = Transform();
|
||||||
glTranslatef(targetPosition.x, targetPosition.y, targetPosition.z);
|
transform.setTranslation(targetPosition);
|
||||||
|
batch.setModelTransform(transform);
|
||||||
|
|
||||||
const float collisionRadius = 0.05f;
|
const float collisionRadius = 0.05f;
|
||||||
DependencyManager::get<GeometryCache>()->renderSphere(collisionRadius, 10, 10, glm::vec4(0.5f,0.5f,0.5f, alpha), false);
|
DependencyManager::get<GeometryCache>()->renderSphere(batch, collisionRadius, 10, 10, glm::vec4(0.5f,0.5f,0.5f, alpha), false);
|
||||||
glPopMatrix();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,22 +160,19 @@ void Hand::renderHandTargets(bool isMine) {
|
||||||
if (palm.isActive()) {
|
if (palm.isActive()) {
|
||||||
glm::vec3 tip = palm.getTipPosition();
|
glm::vec3 tip = palm.getTipPosition();
|
||||||
glm::vec3 root = palm.getPosition();
|
glm::vec3 root = palm.getPosition();
|
||||||
|
Transform transform = Transform();
|
||||||
Avatar::renderJointConnectingCone(root, tip, PALM_FINGER_ROD_RADIUS, PALM_FINGER_ROD_RADIUS, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
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));
|
||||||
|
|
||||||
// Render sphere at palm/finger root
|
// Render sphere at palm/finger root
|
||||||
glm::vec3 offsetFromPalm = root + palm.getNormal() * PALM_DISK_THICKNESS;
|
glm::vec3 offsetFromPalm = root + palm.getNormal() * PALM_DISK_THICKNESS;
|
||||||
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
Avatar::renderJointConnectingCone(batch, root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||||
glPushMatrix();
|
transform = Transform();
|
||||||
glTranslatef(root.x, root.y, root.z);
|
transform.setTranslation(root);
|
||||||
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
batch.setModelTransform(transform);
|
||||||
glPopMatrix();
|
DependencyManager::get<GeometryCache>()->renderSphere(batch, PALM_BALL_RADIUS, 20.0f, 20.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ private:
|
||||||
|
|
||||||
Avatar* _owningAvatar;
|
Avatar* _owningAvatar;
|
||||||
|
|
||||||
void renderHandTargets(bool isMine);
|
void renderHandTargets(RenderArgs* renderArgs, bool isMine);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Hand_h
|
#endif // hifi_Hand_h
|
||||||
|
|
|
@ -1212,9 +1212,7 @@ void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bo
|
||||||
if (shouldRenderHead(renderArgs)) {
|
if (shouldRenderHead(renderArgs)) {
|
||||||
getHead()->render(renderArgs, 1.0f, renderFrustum, postLighting);
|
getHead()->render(renderArgs, 1.0f, renderFrustum, postLighting);
|
||||||
}
|
}
|
||||||
if (postLighting) {
|
getHand()->render(renderArgs, true);
|
||||||
getHand()->render(renderArgs, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visible) {
|
void MyAvatar::setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visible) {
|
||||||
|
@ -1588,7 +1586,7 @@ void MyAvatar::updateMotionBehavior() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Renders sixense laser pointers for UI selection with controllers
|
//Renders sixense laser pointers for UI selection with controllers
|
||||||
void MyAvatar::renderLaserPointers() {
|
void MyAvatar::renderLaserPointers(gpu::Batch& batch) {
|
||||||
const float PALM_TIP_ROD_RADIUS = 0.002f;
|
const float PALM_TIP_ROD_RADIUS = 0.002f;
|
||||||
|
|
||||||
//If the Oculus is enabled, we will draw a blue cursor ray
|
//If the Oculus is enabled, we will draw a blue cursor ray
|
||||||
|
@ -1601,8 +1599,10 @@ void MyAvatar::renderLaserPointers() {
|
||||||
|
|
||||||
//Scale the root vector with the avatar scale
|
//Scale the root vector with the avatar scale
|
||||||
scaleVectorRelativeToPosition(root);
|
scaleVectorRelativeToPosition(root);
|
||||||
|
Transform transform = Transform();
|
||||||
Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS, glm::vec4(0, 1, 1, 1));
|
transform.setTranslation(glm::vec3());
|
||||||
|
batch.setModelTransform(transform);
|
||||||
|
Avatar::renderJointConnectingCone(batch, root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS, glm::vec4(0, 1, 1, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ public:
|
||||||
bool allowDuplicates = false, bool useSaved = true);
|
bool allowDuplicates = false, bool useSaved = true);
|
||||||
|
|
||||||
/// Renders a laser pointer for UI picking
|
/// Renders a laser pointer for UI picking
|
||||||
void renderLaserPointers();
|
void renderLaserPointers(gpu::Batch& batch);
|
||||||
glm::vec3 getLaserPointerTipPosition(const PalmData* palm);
|
glm::vec3 getLaserPointerTipPosition(const PalmData* palm);
|
||||||
|
|
||||||
const RecorderPointer getRecorder() const { return _recorder; }
|
const RecorderPointer getRecorder() const { return _recorder; }
|
||||||
|
|
|
@ -776,24 +776,24 @@ void SkeletonModel::resetShapePositionsToDefaultPose() {
|
||||||
_boundingShape.setRotation(_rotation);
|
_boundingShape.setRotation(_rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) {
|
||||||
const int BALL_SUBDIVISIONS = 10;
|
const int BALL_SUBDIVISIONS = 10;
|
||||||
if (_shapes.isEmpty()) {
|
if (_shapes.isEmpty()) {
|
||||||
// the bounding shape has not been propery computed
|
// the bounding shape has not been propery computed
|
||||||
// so no need to render it
|
// so no need to render it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
Application::getInstance()->loadTranslatedViewMatrix(_translation);
|
Application::getInstance()->loadTranslatedViewMatrix(_translation);
|
||||||
|
|
||||||
// draw a blue sphere at the capsule endpoint
|
// draw a blue sphere at the capsule endpoint
|
||||||
glm::vec3 endPoint;
|
glm::vec3 endPoint;
|
||||||
_boundingShape.getEndPoint(endPoint);
|
_boundingShape.getEndPoint(endPoint);
|
||||||
endPoint = endPoint - _translation;
|
endPoint = endPoint - _translation;
|
||||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
Transform transform = Transform();
|
||||||
|
transform.setTranslation(endPoint);
|
||||||
|
batch.setModelTransform(transform);
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
|
geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
|
||||||
|
|
||||||
// draw a yellow sphere at the capsule startpoint
|
// draw a yellow sphere at the capsule startpoint
|
||||||
glm::vec3 startPoint;
|
glm::vec3 startPoint;
|
||||||
|
@ -805,9 +805,7 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
||||||
|
|
||||||
// draw a green cylinder between the two points
|
// draw a green cylinder between the two points
|
||||||
glm::vec3 origin(0.0f);
|
glm::vec3 origin(0.0f);
|
||||||
Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
|
Avatar::renderJointConnectingCone(batch, origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletonModel::hasSkeleton() {
|
bool SkeletonModel::hasSkeleton() {
|
||||||
|
|
|
@ -101,7 +101,7 @@ public:
|
||||||
const glm::vec3& getStandingOffset() const { return _standingOffset; }
|
const glm::vec3& getStandingOffset() const { return _standingOffset; }
|
||||||
|
|
||||||
void computeBoundingShape(const FBXGeometry& geometry);
|
void computeBoundingShape(const FBXGeometry& geometry);
|
||||||
void renderBoundingCollisionShapes(float alpha);
|
void renderBoundingCollisionShapes(gpu::Batch& batch, float alpha);
|
||||||
float getBoundingShapeRadius() const { return _boundingShape.getRadius(); }
|
float getBoundingShapeRadius() const { return _boundingShape.getRadius(); }
|
||||||
const CapsuleShape& getBoundingShape() const { return _boundingShape; }
|
const CapsuleShape& getBoundingShape() const { return _boundingShape; }
|
||||||
const glm::vec3 getBoundingShapeOffset() const { return _boundingShapeLocalOffset; }
|
const glm::vec3 getBoundingShapeOffset() const { return _boundingShapeLocalOffset; }
|
||||||
|
|
Loading…
Reference in a new issue