Conflicts:
	interface/src/Avatar.cpp
	interface/src/Avatar.h
	interface/src/main.cpp
This commit is contained in:
Andrzej Kapolka 2013-05-03 10:31:40 -07:00
commit 346f213e3b
11 changed files with 570 additions and 458 deletions

View file

@ -114,7 +114,7 @@ int main(int argc, const char* argv[]) {
// pick a random point inside a 10x10 grid
eve.setPosition(glm::vec3(randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION),
0.32, // this is the same as the pelvis standing height (as of 4/26/13)
1.33, // this should be the same as the avatar's pelvis standing height
randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION)));
// face any instance of eve down the z-axis
@ -122,7 +122,7 @@ int main(int argc, const char* argv[]) {
// put her hand out so somebody can shake it
eve.setHandPosition(glm::vec3(eve.getPosition()[0] - 0.2,
0.25,
0.5,
eve.getPosition()[2] + 0.1));
// read eve's audio data
AudioInjector eveAudioInjector("/etc/highfidelity/eve/resources/eve.raw");

File diff suppressed because it is too large Load diff

View file

@ -42,36 +42,38 @@ enum AvatarMode
NUM_AVATAR_MODES
};
enum AvatarBoneID
enum AvatarJointID
{
AVATAR_BONE_NULL = -1,
AVATAR_BONE_PELVIS_SPINE, // connects pelvis joint with torso joint (not supposed to be rotated)
AVATAR_BONE_MID_SPINE, // connects torso joint with chest joint
AVATAR_BONE_CHEST_SPINE, // connects chest joint with neckBase joint (not supposed to be rotated)
AVATAR_BONE_NECK, // connects neckBase joint with headBase joint
AVATAR_BONE_HEAD, // connects headBase joint with headTop joint
AVATAR_BONE_LEFT_CHEST, // connects chest joint with left clavicle joint (not supposed to be rotated)
AVATAR_BONE_LEFT_SHOULDER, // connects left clavicle joint with left shoulder joint
AVATAR_BONE_LEFT_UPPER_ARM, // connects left shoulder joint with left elbow joint
AVATAR_BONE_LEFT_FOREARM, // connects left elbow joint with left wrist joint
AVATAR_BONE_LEFT_HAND, // connects left wrist joint with left fingertips joint
AVATAR_BONE_RIGHT_CHEST, // connects chest joint with right clavicle joint (not supposed to be rotated)
AVATAR_BONE_RIGHT_SHOULDER, // connects right clavicle joint with right shoulder joint
AVATAR_BONE_RIGHT_UPPER_ARM, // connects right shoulder joint with right elbow joint
AVATAR_BONE_RIGHT_FOREARM, // connects right elbow joint with right wrist joint
AVATAR_BONE_RIGHT_HAND, // connects right wrist joint with right fingertips joint
AVATAR_BONE_LEFT_PELVIS, // connects pelvis joint with left hip joint (not supposed to be rotated)
AVATAR_BONE_LEFT_THIGH, // connects left hip joint with left knee joint
AVATAR_BONE_LEFT_SHIN, // connects left knee joint with left heel joint
AVATAR_BONE_LEFT_FOOT, // connects left heel joint with left toes joint
AVATAR_BONE_RIGHT_PELVIS, // connects pelvis joint with right hip joint (not supposed to be rotated)
AVATAR_BONE_RIGHT_THIGH, // connects right hip joint with right knee joint
AVATAR_BONE_RIGHT_SHIN, // connects right knee joint with right heel joint
AVATAR_BONE_RIGHT_FOOT, // connects right heel joint with right toes joint
AVATAR_JOINT_NULL = -1,
AVATAR_JOINT_PELVIS,
AVATAR_JOINT_TORSO,
AVATAR_JOINT_CHEST,
AVATAR_JOINT_NECK_BASE,
AVATAR_JOINT_HEAD_BASE,
AVATAR_JOINT_HEAD_TOP,
AVATAR_JOINT_LEFT_COLLAR,
AVATAR_JOINT_LEFT_SHOULDER,
AVATAR_JOINT_LEFT_ELBOW,
AVATAR_JOINT_LEFT_WRIST,
AVATAR_JOINT_LEFT_FINGERTIPS,
AVATAR_JOINT_RIGHT_COLLAR,
AVATAR_JOINT_RIGHT_SHOULDER,
AVATAR_JOINT_RIGHT_ELBOW,
AVATAR_JOINT_RIGHT_WRIST,
AVATAR_JOINT_RIGHT_FINGERTIPS,
AVATAR_JOINT_LEFT_HIP,
AVATAR_JOINT_LEFT_KNEE,
AVATAR_JOINT_LEFT_HEEL,
AVATAR_JOINT_LEFT_TOES,
AVATAR_JOINT_RIGHT_HIP,
AVATAR_JOINT_RIGHT_KNEE,
AVATAR_JOINT_RIGHT_HEEL,
AVATAR_JOINT_RIGHT_TOES,
NUM_AVATAR_BONES
NUM_AVATAR_JOINTS
};
class Avatar : public AvatarData {
public:
Avatar(bool isMine);
@ -99,11 +101,14 @@ public:
void setLeanSideways(float dist);
void addLean(float x, float z);
const glm::vec3& getHeadLookatDirection() const { return _orientation.getFront(); };
const glm::vec3& getHeadLookatDirectionUp() const { return _orientation.getUp(); };
const glm::vec3& getHeadLookatDirectionRight() const { return _orientation.getRight(); };
/*
const glm::vec3& getHeadRightDirection() const { return _orientation.getRight(); };
const glm::vec3& getHeadUpDirection () const { return _orientation.getUp (); };
const glm::vec3& getHeadFrontDirection() const { return _orientation.getFront(); };
*/
const glm::vec3& getHeadPosition() const ;
const glm::vec3& getBonePosition(AvatarBoneID b) const { return _bone[b].position; };
const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].position; };
const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); };
float getSpeed() const { return _speed; };
float getGirth();
@ -117,7 +122,6 @@ public:
void renderHead(bool lookingInMirror);
void simulate(float);
void setHandMovementValues( glm::vec3 movement );
void updateHandMovement( float deltaTime );
void updateArmIKAndConstraints( float deltaTime );
void setDisplayingHead( bool displayingHead );
@ -148,22 +152,22 @@ private:
void setHeadReturnToCenter(bool r) { _returnHeadToCenter = r; };
const bool getHeadReturnToCenter() const { return _returnHeadToCenter; };
struct AvatarBone
struct AvatarJoint
{
AvatarBoneID parent; // which bone is this bone connected to?
glm::vec3 position; // the position at the "end" of the bone - in global space
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
glm::vec3 springyVelocity; // used for special effects ( the velocity of the springy position)
float springBodyTightness; // how tightly the springy position tries to stay on the position
glm::quat rotation; // this will eventually replace yaw, pitch and roll (and maybe orientation)
float yaw; // the yaw Euler angle of the bone rotation off the parent
float pitch; // the pitch Euler angle of the bone rotation off the parent
float roll; // the roll Euler angle of the bone rotation off the parent
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
float length; // the length of the bone
float radius; // used for detecting collisions for certain physical effects
bool isCollidable; // when false, the bone position will not register a collision
AvatarJointID parent; // which joint is this joint connected to?
glm::vec3 position; // the position at the "end" of the joint - in global space
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
glm::vec3 springyVelocity; // used for special effects ( the velocity of the springy position)
float springBodyTightness; // how tightly the springy position tries to stay on the position
glm::quat rotation; // this will eventually replace yaw, pitch and roll (and maybe orientation)
float yaw; // the yaw Euler angle of the joint rotation off the parent
float pitch; // the pitch Euler angle of the joint rotation off the parent
float roll; // the roll Euler angle of the joint rotation off the parent
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
float length; // the length of vector connecting the joint and its parent
float radius; // used for detecting collisions for certain physical effects
bool isCollidable; // when false, the joint position will not register a collision
};
struct AvatarHead
@ -218,7 +222,7 @@ private:
bool _usingBodySprings;
glm::vec3 _movedHandOffset;
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
AvatarBone _bone[ NUM_AVATAR_BONES ];
AvatarJoint _joint[ NUM_AVATAR_JOINTS ];
AvatarMode _mode;
glm::vec3 _handHoldingPosition;
glm::vec3 _velocity;
@ -253,6 +257,7 @@ private:
void calculateBoneLengths();
void readSensors();
void updateHead( float deltaTime );
void updateHandMovementAndTouching(float deltaTime);
void updateCollisionWithSphere( glm::vec3 position, float radius, float deltaTime );
void updateCollisionWithOtherAvatar( Avatar * other, float deltaTime );
void setHeadFromGyros(glm::vec3 * eulerAngles, glm::vec3 * angularVelocity, float deltaTime, float smoothingTime);

View file

@ -0,0 +1,32 @@
//
// AvatarRenderer.cpp
// interface
//
// Created by Jeffrey Ventrella
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#include <iostream>
#include <glm/glm.hpp>
#include <SharedUtil.h>
#include "AvatarRenderer.h"
#include "InterfaceConfig.h"
AvatarRenderer::AvatarRenderer() {
}
// this method renders the avatar
void AvatarRenderer::render(Avatar *avatar, bool lookingInMirror) {
/*
// show avatar position
glColor4f( 0.5f, 0.5f, 0.5f, 0.6 );
glPushMatrix();
glTranslatef(avatar->_position.x, avatar->_position.y, avatar->_position.z);
glScalef( 0.03, 0.03, 0.03 );
glutSolidSphere( 1, 10, 10 );
glPopMatrix();
*/
}

View file

@ -0,0 +1,25 @@
//
// AvatarRenderer.h
// interface
//
// Created by Jeffrey Ventrella
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__AvatarRenderer__
#define __interface__AvatarRenderer__
#include "Avatar.h"
#include <glm/glm.hpp>
class AvatarRenderer {
public:
AvatarRenderer();
void render(Avatar *avatar, bool lookingInMirror);
private:
};
#endif

View file

@ -433,7 +433,7 @@ void VoxelSystem::render() {
// draw the number of voxels we have
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesID);
glScalef(10, 10, 10);
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
glDrawElements(GL_TRIANGLES, 36 * _voxelsInArrays, GL_UNSIGNED_INT, 0);
// deactivate vertex and color arrays after drawing

View file

@ -69,6 +69,7 @@
#include "Camera.h"
#include "Avatar.h"
#include "AvatarRenderer.h"
#include "Texture.h"
#include <AgentList.h>
#include <AgentTypes.h>
@ -119,6 +120,9 @@ 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";
@ -714,6 +718,7 @@ void displaySide(Camera& whichCamera) {
if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) {
Avatar *avatar = (Avatar *)agent->getLinkedData();
avatar->render(0);
//avatarRenderer.render(avatar, 0); // this will replace the above call
}
}
agentList->unlock();
@ -726,6 +731,7 @@ void displaySide(Camera& whichCamera) {
//Render my own avatar
myAvatar.render(::lookingInMirror);
//avatarRenderer.render(&myAvatar, lookingInMirror); // this will replace the above call
glPopMatrix();
}
@ -1010,7 +1016,7 @@ void display(void)
float thirdPersonPitch = 0.0f;
float thirdPersonUpShift = -0.1f;
float thirdPersonDistance = 1.f;
float thirdPersonDistance = 1.2f;
float thirdPersonTightness = 8.0f;
if ( USING_FIRST_PERSON_EFFECT ) {
@ -1893,7 +1899,7 @@ int main(int argc, const char * argv[])
// field of view and near and far clip to make it interesting.
//viewFrustumOffsetCamera.setFieldOfView(90.0);
viewFrustumOffsetCamera.setNearClip(0.1);
viewFrustumOffsetCamera.setFarClip(500.0);
viewFrustumOffsetCamera.setFarClip(500.0*TREE_SCALE);
printLog( "Created Display Window.\n" );

View file

@ -15,6 +15,7 @@
typedef unsigned char colorPart;
typedef unsigned char nodeColor[4];
typedef unsigned char rgbColor[3];
class VoxelNode {
private:

View file

@ -25,7 +25,7 @@
using voxels_lib::printLog;
int boundaryDistanceForRenderLevel(unsigned int renderLevel) {
float voxelSizeScale = 5000.0;
float voxelSizeScale = 500.0*TREE_SCALE;
return voxelSizeScale / powf(2, renderLevel);
}
@ -444,6 +444,21 @@ void VoxelTree::createVoxel(float x, float y, float z, float s, unsigned char re
delete voxelData;
}
void VoxelTree::createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color) {
glm::vec3 distance = point2 - point1;
glm::vec3 items = distance / unitSize;
int maxItems = std::max(items.x, std::max(items.y, items.z));
glm::vec3 increment = distance * (1.0f/ maxItems);
glm::vec3 pointAt = point1;
for (int i = 0; i <= maxItems; i++ ) {
pointAt += increment;
unsigned char* voxelData = pointToVoxel(pointAt.x,pointAt.y,pointAt.z,unitSize,color[0],color[1],color[2]);
readCodeColorBufferToTree(voxelData);
delete voxelData;
}
}
void VoxelTree::createSphere(float r,float xc, float yc, float zc, float s, bool solid, bool wantColorRandomizer) {
// About the color of the sphere... we're going to make this sphere be a gradient
// between two RGB colors. We will do the gradient along the phi spectrum

View file

@ -47,6 +47,8 @@ public:
void loadVoxelsFile(const char* fileName, bool wantColorRandomizer);
void createSphere(float r,float xc, float yc, float zc, float s, bool solid, bool wantColorRandomizer);
void createVoxel(float x, float y, float z, float s, unsigned char red, unsigned char green, unsigned char blue);
void createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color);
void recurseTreeWithOperation(RecurseVoxelTreeOperation operation, void* extraData=NULL);

View file

@ -75,10 +75,36 @@ bool countVoxelsOperation(VoxelNode* node, void* extraData) {
}
void addSphereScene(VoxelTree * tree, bool wantColorRandomizer) {
printf("adding scene of spheres...\n");
printf("adding scene...\n");
float voxelSize = 1.f/32;
printf("creating corner points...\n");
tree->createVoxel(0 , 0 , 0 , voxelSize, 255, 255 ,255);
tree->createVoxel(1.0 - voxelSize, 0 , 0 , voxelSize, 255, 0 ,0 );
tree->createVoxel(0 , 1.0 - voxelSize, 0 , voxelSize, 0 , 255 ,0 );
tree->createVoxel(0 , 0 , 1.0 - voxelSize, voxelSize, 0 , 0 ,255);
tree->createVoxel(1.0 - voxelSize, 0 , 1.0 - voxelSize, voxelSize, 255, 0 ,255);
tree->createVoxel(0 , 1.0 - voxelSize, 1.0 - voxelSize, voxelSize, 0 , 255 ,255);
tree->createVoxel(1.0 - voxelSize, 1.0 - voxelSize, 0 , voxelSize, 255, 255 ,0 );
tree->createVoxel(1.0 - voxelSize, 1.0 - voxelSize, 1.0 - voxelSize, voxelSize, 255, 255 ,255);
printf("DONE creating corner points...\n");
printf("creating voxel lines...\n");
float lineVoxelSize = 0.99f/256;
rgbColor red = {255,0,0};
rgbColor green = {0,255,0};
rgbColor blue = {0,0,255};
tree->createLine(glm::vec3(0, 0, 0), glm::vec3(0, 0, 1), lineVoxelSize, blue);
tree->createLine(glm::vec3(0, 0, 0), glm::vec3(1, 0, 0), lineVoxelSize, red);
tree->createLine(glm::vec3(0, 0, 0), glm::vec3(0, 1, 0), lineVoxelSize, green);
printf("DONE creating lines...\n");
int sphereBaseSize = 512;
printf("creating spheres...\n");
tree->createSphere(0.25, 0.5, 0.5, 0.5, (1.0 / sphereBaseSize), true, wantColorRandomizer);
printf("one sphere added...\n");
tree->createSphere(0.030625, 0.5, 0.5, (0.25-0.06125), (1.0 / (sphereBaseSize * 2)), true, true);
@ -106,19 +132,7 @@ void addSphereScene(VoxelTree * tree, bool wantColorRandomizer) {
tree->createSphere(radius, 0.025, radius * 5.0f, 0.25, (1.0 / 4096), true, true);
printf("11 spheres added...\n");
float voxelSize = 0.99f/8;
printf("creating corner points...\n");
tree->createVoxel(0 , 0 , 0 , voxelSize, 255, 255 ,255);
tree->createVoxel(1.0 - voxelSize, 0 , 0 , voxelSize, 255, 0 ,0 );
tree->createVoxel(0 , 1.0 - voxelSize, 0 , voxelSize, 0 , 255 ,0 );
tree->createVoxel(0 , 0 , 1.0 - voxelSize, voxelSize, 0 , 0 ,255);
tree->createVoxel(1.0 - voxelSize, 0 , 1.0 - voxelSize, voxelSize, 255, 0 ,255);
tree->createVoxel(0 , 1.0 - voxelSize, 1.0 - voxelSize, voxelSize, 0 , 255 ,255);
tree->createVoxel(1.0 - voxelSize, 1.0 - voxelSize, 1.0 - voxelSize, voxelSize, 255, 255 ,255);
tree->createVoxel(1.0 - voxelSize, 1.0 - voxelSize, 0 , voxelSize, 255, 255 ,0 );
printf("DONE creating corner points...\n");
printf("DONE creating spheres...\n");
_nodeCount=0;
tree->recurseTreeWithOperation(countVoxelsOperation);