From 7f0d2e572ee43c223c8dfa90f503b22cc167e5d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 20 May 2013 07:38:00 -0700 Subject: [PATCH] some preliminary work on avatarRenderer --- interface/src/Application.cpp | 2 +- interface/src/Application.h | 3 ++ interface/src/Avatar.cpp | 20 ++++--------- interface/src/Avatar.h | 1 + interface/src/AvatarRenderer.cpp | 48 +++++++++++++++++++------------- interface/src/AvatarRenderer.h | 7 +++-- 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1f34ed3c09..7553ef2b1a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -302,7 +302,6 @@ void Application::paintGL() { _myCamera.setTargetRotation(_myAvatar.getBodyYaw() - 180.0f, 0.0f, 0.0f); - } else { if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { _myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition()); @@ -1635,6 +1634,7 @@ void Application::displaySide(Camera& whichCamera) { // Render my own Avatar _myAvatar.render(_lookingInMirror, _myCamera.getPosition()); + //_avatarRenderer.render(); } // Render the world box diff --git a/interface/src/Application.h b/interface/src/Application.h index 8a949fa183..a42ffccafd 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -186,6 +186,9 @@ private: Oscilloscope _audioScope; Avatar _myAvatar; // The rendered avatar of oneself + + //AvatarRenderer _avatarRenderer; + Camera _myCamera; // My view onto the world Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 2fe26f56eb..1eb252dcb5 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -58,6 +58,7 @@ bool usingBigSphereCollisionTest = true; float chatMessageScale = 0.0015; float chatMessageHeight = 0.45; + Avatar::Avatar(bool isMine) { _orientation.setToIdentity(); @@ -691,19 +692,6 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) { _cameraPosition = cameraPosition; // store this for use in various parts of the code - // render a simple round on the ground projected down from the avatar's position - renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f); - - /* - // show avatar position - glColor4f(0.5f, 0.5f, 0.5f, 0.6); - glPushMatrix(); - glTranslatef(_position.x, _position.y, _position.z); - glScalef(0.03, 0.03, 0.03); - glutSolidSphere(1, 10, 10); - glPopMatrix(); - */ - if (usingBigSphereCollisionTest) { // show TEST big sphere glColor4f(0.5f, 0.6f, 0.8f, 0.7); @@ -714,10 +702,12 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) { glPopMatrix(); } + // render a simple round on the ground projected down from the avatar's position + renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f); + //render body renderBody(lookingInMirror); - // if this is my avatar, then render my interactions with the other avatar if (_isMine) { _avatarTouch.render(_cameraPosition); @@ -1038,10 +1028,12 @@ void Avatar::updateBodySprings(float deltaTime) { _joint[b].springyVelocity = glm::vec3(0.0f, 0.0f, 0.0f); } + /* //apply forces from touch... if (_joint[b].touchForce > 0.0) { _joint[b].springyVelocity += _mouseRayDirection * _joint[b].touchForce * 0.7f; } + */ //update position by velocity... _joint[b].springyPosition += _joint[b].springyVelocity * deltaTime; diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index f7dcb8853c..fc4b6d123b 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -15,6 +15,7 @@ #include #include "world.h" #include "AvatarTouch.h" +#include "AvatarRenderer.h" #include "InterfaceConfig.h" #include "SerialInterface.h" #include "Balls.h" diff --git a/interface/src/AvatarRenderer.cpp b/interface/src/AvatarRenderer.cpp index 45ce46084f..45c10c4441 100644 --- a/interface/src/AvatarRenderer.cpp +++ b/interface/src/AvatarRenderer.cpp @@ -10,54 +10,61 @@ #include "AvatarRenderer.h" #include "InterfaceConfig.h" +/* AvatarRenderer::AvatarRenderer() { } // this method renders the avatar -void AvatarRenderer::render(Avatar *avatarToRender, bool lookingInMirror, glm::vec3 cameraPosition) { +void AvatarRenderer::render() { - avatar = avatarToRender; - /* // show avatar position glColor4f(0.5f, 0.5f, 0.5f, 0.6); glPushMatrix(); - glm::vec3 j( avatar->getJointPosition( AVATAR_JOINT_PELVIS ) ); + glm::vec3 j( getJointPosition( AVATAR_JOINT_PELVIS ) ); glTranslatef(j.x, j.y, j.z); glScalef(0.08, 0.08, 0.08); glutSolidSphere(1, 10, 10); glPopMatrix(); - */ - //renderDiskShadow(avatar->getJointPosition( AVATAR_JOINT_PELVIS ), glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f); + renderDiskShadow(getJointPosition( AVATAR_JOINT_PELVIS ), glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f); - //renderBody(); + //renderBody(lookingInMirror); } - - - - - void AvatarRenderer::renderBody() { -/* // Render joint positions as spheres for (int b = 0; b < NUM_AVATAR_JOINTS; b++) { - if (b != AVATAR_JOINT_HEAD_BASE) { // the head is rendered as a special case in "renderHead" + if (b == AVATAR_JOINT_HEAD_BASE) { // the head is rendered as a special case + if (_displayingHead) { + _head.render(lookingInMirror); + } + } else { //show direction vectors of the bone orientation //renderOrientationDirections(_joint[b].springyPosition, _joint[b].orientation, _joint[b].radius * 2.0); - glm::vec3 j( avatar->getJointPosition( AVATAR_JOINT_PELVIS ) ); - glColor3fv(skinColor); + glColor3fv(_avatar->skinColor); glPushMatrix(); - glTranslatef(j.x, j.y, j.z); - glutSolidSphere(_joint[b].radius, 20.0f, 20.0f); + glTranslatef(_avatar->[b].springyPosition.x, _avatar->_joint[b].springyPosition.y, _avatar->_joint[b].springyPosition.z); + glutSolidSphere(_avatar->_joint[b].radius, 20.0f, 20.0f); + glPopMatrix(); + } + + if (_joint[b].touchForce > 0.0f) { + + float alpha = _joint[b].touchForce * 0.2; + float r = _joint[b].radius * 1.1f + 0.005f; + glColor4f(0.5f, 0.2f, 0.2f, alpha); + glPushMatrix(); + glTranslatef(_joint[b].springyPosition.x, _joint[b].springyPosition.y, _joint[b].springyPosition.z); + glScalef(r, r, r); + glutSolidSphere(1, 20, 20); glPopMatrix(); } } - + // Render lines connecting the joint positions glColor3f(0.4f, 0.5f, 0.6f); glLineWidth(3.0); @@ -71,5 +78,6 @@ void AvatarRenderer::renderBody() { glEnd(); } } - */ } +*/ + diff --git a/interface/src/AvatarRenderer.h b/interface/src/AvatarRenderer.h index e0e9d7bbb3..36a4d58e0c 100644 --- a/interface/src/AvatarRenderer.h +++ b/interface/src/AvatarRenderer.h @@ -11,16 +11,17 @@ #include "Avatar.h" #include -class AvatarRenderer { +/* +class AvatarRenderer : public Avatar { public: AvatarRenderer(); - void render(Avatar *avatarToRender, bool lookingInMirror, glm::vec3 cameraPosition ); + void render(); private: - Avatar *avatar; void renderBody(); }; +*/ #endif