put orientation back in avatar folder (this should be put in a more logical place at some point) - also did some work on avatar renderer

This commit is contained in:
Jeffrey Ventrella 2013-05-08 19:22:21 -07:00
parent 9e60c8a36e
commit 7a24c50063
7 changed files with 71 additions and 6 deletions

View file

@ -5,7 +5,6 @@
// Created by Philip Rosedale on 9/11/12.
// adapted by Jeffrey Ventrella
// Copyright (c) 2013 Physical, Inc.. All rights reserved.
//
#include <glm/glm.hpp>
#include <vector>

View file

@ -102,7 +102,10 @@ public:
void setLeanSideways(float dist);
void addLean(float x, float z);
const glm::vec3& getHeadPosition() const ;
const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].position; };
//const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].position; };
const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].springyPosition; };
const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); };
float getSpeed() const { return _speed; };
float getGirth();

View file

@ -15,5 +15,62 @@ AvatarRenderer::AvatarRenderer() {
}
// this method renders the avatar
void AvatarRenderer::render(Avatar *avatar, bool lookingInMirror) {
}
void AvatarRenderer::render(Avatar *avatarToRender, bool lookingInMirror, glm::vec3 cameraPosition) {
avatar = avatarToRender;
/*
// show avatar position
glColor4f(0.5f, 0.5f, 0.5f, 0.6);
glPushMatrix();
glm::vec3 j( avatar->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);
//renderBody();
}
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"
//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);
glPushMatrix();
glTranslatef(j.x, j.y, j.z);
glutSolidSphere(_joint[b].radius, 20.0f, 20.0f);
glPopMatrix();
}
}
// Render lines connecting the joint positions
glColor3f(0.4f, 0.5f, 0.6f);
glLineWidth(3.0);
for (int b = 1; b < NUM_AVATAR_JOINTS; b++) {
if (_joint[b].parent != AVATAR_JOINT_NULL)
if (b != AVATAR_JOINT_HEAD_TOP) {
glBegin(GL_LINE_STRIP);
glVertex3fv(&_joint[ _joint[ b ].parent ].springyPosition.x);
glVertex3fv(&_joint[ b ].springyPosition.x);
glEnd();
}
}
*/
}

View file

@ -16,10 +16,12 @@ class AvatarRenderer {
public:
AvatarRenderer();
void render(Avatar *avatar, bool lookingInMirror);
void render(Avatar *avatarToRender, bool lookingInMirror, glm::vec3 cameraPosition );
private:
Avatar *avatar;
void renderBody();
};
#endif

View file

@ -75,6 +75,7 @@
#include "ViewFrustum.h"
#include "HandControl.h"
#include "AvatarRenderer.h"
using namespace std;
@ -112,6 +113,8 @@ Avatar myAvatar(true); // The rendered avatar of oneself
Camera myCamera; // My view onto the world (sometimes on myself :)
Camera viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
AvatarRenderer avatarRenderer;
// Starfield information
char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
char starCacheFile[] = "cachedStars.txt";
@ -719,7 +722,8 @@ void displaySide(Camera& whichCamera) {
//Render my own avatar
myAvatar.render(::lookingInMirror, ::myCamera.getPosition());
avatarRenderer.render(&myAvatar, ::lookingInMirror, ::myCamera.getPosition());
glPopMatrix();
}