mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
resolve conflicts on merge with upstream master
This commit is contained in:
commit
7c3f5264b5
6 changed files with 201 additions and 467 deletions
|
@ -86,9 +86,12 @@ Head::Head()
|
|||
noise = 0;
|
||||
|
||||
handBeingMoved = false;
|
||||
previousHandBeingMoved = false;
|
||||
movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
|
||||
sphere = NULL;
|
||||
|
||||
sphere = NULL;
|
||||
|
||||
usingSprings = false;
|
||||
|
||||
springForce = 6.0f;
|
||||
springToBodyTightness = 4.0f;
|
||||
|
@ -103,6 +106,12 @@ Head::Head()
|
|||
std::cout << "error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++)
|
||||
{
|
||||
DEBUG_otherAvatarListTimer[o] = 0.0f;
|
||||
DEBUG_otherAvatarListPosition[o] = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,18 +183,12 @@ Head::~Head()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
Head* Head::clone() const
|
||||
{
|
||||
return new Head(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
void Head::reset()
|
||||
{
|
||||
|
@ -194,8 +197,6 @@ void Head::reset()
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//this pertains to moving the head with the glasses
|
||||
//---------------------------------------------------
|
||||
void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity)
|
||||
|
@ -241,7 +242,6 @@ void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int hea
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
void Head::addLean(float x, float z) {
|
||||
// Add Body lean as impulse
|
||||
|
@ -249,37 +249,90 @@ void Head::addLean(float x, float z) {
|
|||
leanForward += z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
//------------------------------------
|
||||
void Head::setLeanForward(float dist){
|
||||
leanForward = dist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
//-------------------------------------
|
||||
void Head::setLeanSideways(float dist){
|
||||
leanSideways = dist;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------
|
||||
void Head::simulate(float deltaTime) {
|
||||
|
||||
//-------------------------------------
|
||||
// DEBUG - other avatars...
|
||||
//-------------------------------------
|
||||
closeEnoughToInteract = 2.0f;
|
||||
closestOtherAvatar = -1;
|
||||
float closestDistance = 10000.0f;
|
||||
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
|
||||
|
||||
//-------------------------------------
|
||||
// move the debug other avatars around...
|
||||
//-------------------------------------
|
||||
DEBUG_otherAvatarListTimer[o] += deltaTime;
|
||||
float x = 6.0f * sin( DEBUG_otherAvatarListTimer[o] * 0.07 + o * 129.0 );
|
||||
float z = 6.0f * sin( DEBUG_otherAvatarListTimer[o] * 0.10 + o * 12.0 );
|
||||
float y = 0.0f;
|
||||
DEBUG_otherAvatarListPosition[o] = glm::vec3( x, y, z );
|
||||
|
||||
//-------------------------------------
|
||||
// test other avs for proximity...
|
||||
//-------------------------------------
|
||||
glm::vec3 v( position );
|
||||
v -= DEBUG_otherAvatarListPosition[o];
|
||||
|
||||
float distance = glm::length( v );
|
||||
|
||||
if ( distance < closeEnoughToInteract ) {
|
||||
if ( distance < closestDistance ) {
|
||||
closestDistance = distance;
|
||||
closestOtherAvatar = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf( "closestOtherAvatar = %d \n", closestOtherAvatar );
|
||||
|
||||
|
||||
|
||||
|
||||
// Simulate the avatar over time
|
||||
//---------------------------------------------------
|
||||
void Head::simulate(float deltaTime)
|
||||
{
|
||||
//------------------------
|
||||
// update avatar skeleton
|
||||
//------------------------
|
||||
updateAvatarSkeleton();
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// update springy behavior:
|
||||
// reset hand and elbow position according to hand movement
|
||||
//------------------------------------------------------------------------
|
||||
updateAvatarSprings( deltaTime );
|
||||
if ( handBeingMoved ){
|
||||
if (! previousHandBeingMoved ){
|
||||
initializeAvatarSprings();
|
||||
usingSprings = true;
|
||||
//printf( "just started moving hand\n" );
|
||||
}
|
||||
}
|
||||
else{
|
||||
if ( previousHandBeingMoved ){
|
||||
usingSprings = false;
|
||||
//printf( "just stopped moving hand\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( handBeingMoved )
|
||||
{
|
||||
updateHandMovement();
|
||||
updateAvatarSprings( deltaTime );
|
||||
}
|
||||
|
||||
previousHandBeingMoved = handBeingMoved;
|
||||
handBeingMoved = false;
|
||||
|
||||
|
||||
|
||||
const float THRUST_MAG = 10.0;
|
||||
const float YAW_MAG = 300.0;
|
||||
|
||||
|
@ -467,16 +520,57 @@ void Head::simulate(float deltaTime)
|
|||
//---------------------------------------------------
|
||||
void Head::render(int faceToFace, int isMine)
|
||||
{
|
||||
//---------------------------------------------------
|
||||
// show avatar position
|
||||
//---------------------------------------------------
|
||||
glPushMatrix();
|
||||
glTranslatef( position.x, position.y, position.z );
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
|
||||
//---------------------------------------------------
|
||||
// show avatar orientation
|
||||
//---------------------------------------------------
|
||||
renderOrientationDirections(avatar.bone[ AVATAR_BONE_HEAD ].position, avatar.bone[ AVATAR_BONE_HEAD ].orientation, 0.2f );
|
||||
|
||||
//---------------------------------------------------
|
||||
// render body
|
||||
//---------------------------------------------------
|
||||
renderBody();
|
||||
|
||||
//---------------------------------------------------
|
||||
// render head
|
||||
//---------------------------------------------------
|
||||
renderHead( faceToFace, isMine );
|
||||
|
||||
//---------------------------------------------------
|
||||
// render other avatars (DEBUG TEST)
|
||||
//---------------------------------------------------
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++)
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef( DEBUG_otherAvatarListPosition[o].x, DEBUG_otherAvatarListPosition[o].y, DEBUG_otherAvatarListPosition[o].z );
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if ( usingSprings ) {
|
||||
if ( closestOtherAvatar != -1 ) {
|
||||
|
||||
glm::vec3 v1( avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
glm::vec3 v2( DEBUG_otherAvatarListPosition[ closestOtherAvatar ] );
|
||||
|
||||
glLineWidth( 5.0 );
|
||||
glColor4f( 0.9f, 0.5f, 0.2f, 0.6 );
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3f( v1.x, v1.y, v1.z );
|
||||
glVertex3f( v2.x, v2.y, v2.z );
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -697,6 +791,8 @@ void Head::initializeAvatar()
|
|||
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
avatar.orientation.setToIdentity();
|
||||
|
||||
closestOtherAvatar = 0;
|
||||
|
||||
avatar.yaw = -90.0;
|
||||
avatar.pitch = 0.0;
|
||||
avatar.roll = 0.0;
|
||||
|
@ -847,19 +943,19 @@ void Head::updateAvatarSkeleton()
|
|||
glm::vec3 rotatedBoneVector( xx, yy, zz );
|
||||
avatar.bone[b].position += rotatedBoneVector;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// reset hand and elbow position according to hand movement
|
||||
//------------------------------------------------------------------------
|
||||
if ( handBeingMoved )
|
||||
{
|
||||
updateHandMovement();
|
||||
handBeingMoved = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
void Head::initializeAvatarSprings() {
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
avatar.bone[b].springyPosition = avatar.bone[b].position;
|
||||
avatar.bone[b].springyVelocity = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
void Head::updateAvatarSprings( float deltaTime )
|
||||
|
@ -1057,87 +1153,57 @@ void Head::renderBody()
|
|||
//-----------------------------------------
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++)
|
||||
{
|
||||
glColor3fv( skinColor );
|
||||
//glColor4f( 1.0f, 0.8f, 0.6f, 0.4f );
|
||||
glPushMatrix();
|
||||
glTranslatef( avatar.bone[b].position.x, avatar.bone[b].position.y, avatar.bone[b].position.z );
|
||||
glutSolidSphere( 0.02f, 10.0f, 5.0f );
|
||||
glPopMatrix();
|
||||
|
||||
glColor4fv( lightBlue );
|
||||
glPushMatrix();
|
||||
glTranslatef( avatar.bone[b].springyPosition.x, avatar.bone[b].springyPosition.y, avatar.bone[b].springyPosition.z );
|
||||
glutSolidSphere( 0.01f, 10.0f, 5.0f );
|
||||
glPopMatrix();
|
||||
if ( usingSprings )
|
||||
{
|
||||
glColor3fv( lightBlue );
|
||||
glPushMatrix();
|
||||
glTranslatef( avatar.bone[b].springyPosition.x, avatar.bone[b].springyPosition.y, avatar.bone[b].springyPosition.z );
|
||||
glutSolidSphere( 0.02f, 10.0f, 5.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor3fv( skinColor );
|
||||
glPushMatrix();
|
||||
glTranslatef( avatar.bone[b].position.x, avatar.bone[b].position.y, avatar.bone[b].position.z );
|
||||
glutSolidSphere( 0.02f, 10.0f, 5.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Render lines connecting the bone positions
|
||||
//-----------------------------------------------------
|
||||
//glColor3f(1,1,1);
|
||||
glColor3fv( skinColor );
|
||||
//glColor4f( 1.0f, 0.8f, 0.6f, 0.4f );
|
||||
glLineWidth(3.0);
|
||||
|
||||
for (int b=1; b<NUM_AVATAR_BONES; b++)
|
||||
if ( usingSprings )
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].position.x );
|
||||
glVertex3fv( &avatar.bone[ b ].position.x);
|
||||
glEnd();
|
||||
glColor3f( 0.2f, 0.3f, 0.4f );
|
||||
glLineWidth(3.0);
|
||||
|
||||
for (int b=1; b<NUM_AVATAR_BONES; b++)
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].springyPosition.x );
|
||||
glVertex3fv( &avatar.bone[ b ].springyPosition.x );
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor3fv( skinColor );
|
||||
glLineWidth(3.0);
|
||||
|
||||
for (int b=1; b<NUM_AVATAR_BONES; b++)
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].position.x );
|
||||
glVertex3fv( &avatar.bone[ b ].position.x);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Render lines connecting the springy positions
|
||||
//-----------------------------------------------------
|
||||
glColor3f( 0.2f, 0.3f, 0.4f );
|
||||
glLineWidth(3.0);
|
||||
|
||||
for (int b=1; b<NUM_AVATAR_BONES; b++)
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].springyPosition.x );
|
||||
glVertex3fv( &avatar.bone[ b ].springyPosition.x );
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_NECK].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_SHOULDER].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_UPPER_ARM].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_FOREARM].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_HAND].position.x);
|
||||
glEnd();
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_SHOULDER].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_UPPER_ARM].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_FOREARM].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_HAND].position.x);
|
||||
glEnd();
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_MID_SPINE].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_PELVIS_SPINE].position.x);
|
||||
glEnd();
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_PELVIS_SPINE].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_PELVIS].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_THIGH].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_SHIN].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_FOOT].position.x);
|
||||
glEnd();
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_PELVIS_SPINE].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_PELVIS].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_THIGH].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_SHIN].position.x);
|
||||
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_FOOT].position.x);
|
||||
glEnd();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -1152,6 +1218,7 @@ int Head::getBroadcastData(char* data)
|
|||
// Copy data for transmission to the buffer, return length of data
|
||||
sprintf(data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
getRenderPitch() + Pitch, -getRenderYaw() + 180 -Yaw, Roll,
|
||||
//avatar.yaw, avatar.pitch, avatar.roll,
|
||||
position.x + leanSideways, position.y, position.z + leanForward,
|
||||
loudness, averageLoudness,
|
||||
//hand->getPos().x, hand->getPos().y, hand->getPos().z); //previous to Ventrella change
|
||||
|
@ -1170,6 +1237,7 @@ void Head::parseData(void *data, int size)
|
|||
(
|
||||
(char *)data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
&Pitch, &Yaw, &Roll,
|
||||
//&avatar.yaw, &avatar.pitch, &avatar.roll,
|
||||
&position.x, &position.y, &position.z,
|
||||
&loudness, &averageLoudness,
|
||||
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x,
|
||||
|
|
|
@ -30,6 +30,8 @@ enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
|||
#define ROT_RIGHT 7
|
||||
#define MAX_DRIVE_KEYS 8
|
||||
|
||||
#define NUM_OTHER_AVATARS 5
|
||||
|
||||
/*
|
||||
enum AvatarJoints
|
||||
{
|
||||
|
@ -237,7 +239,15 @@ class Head : public AgentData {
|
|||
//glm::vec3 velocity;
|
||||
//glm::vec3 thrust;
|
||||
|
||||
float closeEnoughToInteract;
|
||||
int closestOtherAvatar;
|
||||
glm::vec3 DEBUG_otherAvatarListPosition [ NUM_OTHER_AVATARS ];
|
||||
float DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ];
|
||||
|
||||
bool usingSprings;
|
||||
|
||||
bool handBeingMoved;
|
||||
bool previousHandBeingMoved;
|
||||
glm::vec3 movedHandOffset;
|
||||
//glm::vec3 movedHandPosition;
|
||||
|
||||
|
@ -255,6 +265,7 @@ class Head : public AgentData {
|
|||
|
||||
void initializeAvatar();
|
||||
void updateAvatarSkeleton();
|
||||
void initializeAvatarSprings();
|
||||
void updateAvatarSprings( float deltaTime );
|
||||
void calculateBoneLengths();
|
||||
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
#include "Orientation.h"
|
||||
#include "Util.h"
|
||||
|
||||
//------------------------
|
||||
Orientation::Orientation()
|
||||
{
|
||||
Orientation::Orientation() {
|
||||
right = glm::vec3( 1.0, 0.0, 0.0 );
|
||||
up = glm::vec3( 0.0, 1.0, 0.0 );
|
||||
front = glm::vec3( 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
//-------------------------------
|
||||
void Orientation::setToIdentity()
|
||||
{
|
||||
|
||||
void Orientation::setToIdentity() {
|
||||
right = glm::vec3( 1.0, 0.0, 0.0 );
|
||||
up = glm::vec3( 0.0, 1.0, 0.0 );
|
||||
front = glm::vec3( 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
void Orientation::set( Orientation o )
|
||||
{
|
||||
|
||||
void Orientation::set( Orientation o ) {
|
||||
right = o.getRight();
|
||||
up = o.getUp();
|
||||
front = o.getFront();
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
void Orientation::yaw( float angle )
|
||||
{
|
||||
|
||||
void Orientation::yaw( float angle ) {
|
||||
float r = angle * PI_OVER_180;
|
||||
float s = sin( r );
|
||||
float c = cos( r );
|
||||
|
@ -41,9 +36,8 @@ void Orientation::yaw( float angle )
|
|||
right = cosineRight - sineFront;
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
void Orientation::pitch( float angle )
|
||||
{
|
||||
|
||||
void Orientation::pitch( float angle ) {
|
||||
float r = angle * PI_OVER_180;
|
||||
float s = sin( r );
|
||||
float c = cos( r );
|
||||
|
@ -57,9 +51,8 @@ void Orientation::pitch( float angle )
|
|||
front = cosineFront - sineUp;
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
void Orientation::roll( float angle )
|
||||
{
|
||||
|
||||
void Orientation::roll( float angle ) {
|
||||
double r = angle * PI_OVER_180;
|
||||
double s = sin( r );
|
||||
double c = cos( r );
|
||||
|
@ -73,9 +66,8 @@ void Orientation::roll( float angle )
|
|||
right = cosineRight - sineUp;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
void Orientation::setRightUpFront( const glm::vec3 &r, const glm::vec3 &u, const glm::vec3 &f )
|
||||
{
|
||||
|
||||
void Orientation::setRightUpFront( const glm::vec3 &r, const glm::vec3 &u, const glm::vec3 &f ) {
|
||||
right = r;
|
||||
up = u;
|
||||
front = f;
|
||||
|
|
|
@ -1,267 +0,0 @@
|
|||
//-----------------------------------------------------------
|
||||
//
|
||||
// Created by Jeffrey Ventrella and added as a utility
|
||||
// class for High Fidelity Code base, April 2013
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
#include "Vector3D.h"
|
||||
#include <cmath> // "Math.h"
|
||||
|
||||
//---------------------------------------
|
||||
Vector3D::Vector3D()
|
||||
{
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
z = 0.0;
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
Vector3D::Vector3D( double x_, double y_, double z_ )
|
||||
{
|
||||
x = x_;
|
||||
y = y_;
|
||||
z = z_;
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
Vector3D::Vector3D( const Vector3D & v )
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::setXYZ( double x_, double y_, double z_ )
|
||||
{
|
||||
x = x_;
|
||||
y = y_;
|
||||
z = z_;
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
void Vector3D::clear()
|
||||
{
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
z = 0.0;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::addXYZ( double x_, double y_, double z_ )
|
||||
{
|
||||
x += x_;
|
||||
y += y_;
|
||||
z += z_;
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
void Vector3D::set( const Vector3D &v )
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
void Vector3D::add( const Vector3D &v )
|
||||
{
|
||||
x += v.x;
|
||||
y += v.y;
|
||||
z += v.z;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
void Vector3D::subtract ( const Vector3D &v )
|
||||
{
|
||||
x -= v.x;
|
||||
y -= v.y;
|
||||
z -= v.z;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::addScaled( const Vector3D &v, double s )
|
||||
{
|
||||
x += v.x * s;
|
||||
y += v.y * s;
|
||||
z += v.z * s;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::subtractScaled( const Vector3D &v, double s )
|
||||
{
|
||||
x -= v.x * s;
|
||||
y -= v.y * s;
|
||||
z -= v.z * s;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------
|
||||
void Vector3D::normalize()
|
||||
{
|
||||
double d = sqrt( x * x + y * y + z * z );
|
||||
|
||||
if ( d > 0.0 )
|
||||
{
|
||||
x /= d;
|
||||
y /= d;
|
||||
z /= d;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
void Vector3D::setX ( double x_ ) { x = x_; }
|
||||
void Vector3D::setY ( double y_ ) { y = y_; }
|
||||
void Vector3D::setZ ( double z_ ) { z = z_; }
|
||||
|
||||
void Vector3D::addX ( double x_ ) { x += x_; }
|
||||
void Vector3D::addY ( double y_ ) { y += y_; }
|
||||
void Vector3D::addZ ( double z_ ) { z += z_; }
|
||||
|
||||
double Vector3D::getX () { return x; }
|
||||
double Vector3D::getY () { return y; }
|
||||
double Vector3D::getZ () { return z; }
|
||||
|
||||
void Vector3D::scaleX ( double s ) { x *= s; }
|
||||
void Vector3D::scaleY ( double s ) { y *= s; }
|
||||
void Vector3D::scaleZ ( double s ) { z *= s; }
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::setToScaled( const Vector3D &v, double s )
|
||||
{
|
||||
Vector3D c;
|
||||
|
||||
x = v.x * s;
|
||||
y = v.y * s;
|
||||
z = v.z * s;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void Vector3D::setToAverage( const Vector3D &v1, const Vector3D &v2 )
|
||||
{
|
||||
x = v1.x + ( v2.x - v1.x ) * 0.5;
|
||||
y = v1.y + ( v2.y - v1.y ) * 0.5;
|
||||
z = v1.z + ( v2.z - v1.z ) * 0.5;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::setToDifference( const Vector3D &v1, const Vector3D &v2 )
|
||||
{
|
||||
x = v1.x - v2.x;
|
||||
y = v1.y - v2.y;
|
||||
z = v1.z - v2.z;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::scale( double s )
|
||||
{
|
||||
x *= s;
|
||||
y *= s;
|
||||
z *= s;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
double Vector3D::getMagnitude()
|
||||
{
|
||||
return sqrt( x * x + y * y + z * z );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
double Vector3D::getMagnitudeSquared()
|
||||
{
|
||||
return x * x + y * y + z * z ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
double Vector3D::getDistanceTo( const Vector3D &v )
|
||||
{
|
||||
double xx = v.x - x;
|
||||
double yy = v.y - y;
|
||||
double zz = v.z - z;
|
||||
|
||||
return sqrt( xx * xx + yy * yy + zz * zz );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
double Vector3D::getDistanceSquaredTo( const Vector3D &v )
|
||||
{
|
||||
double xx = v.x - x;
|
||||
double yy = v.y - y;
|
||||
double zz = v.z - z;
|
||||
|
||||
return xx * xx + yy * yy + zz * zz;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
double Vector3D::getDistance( const Vector3D &v1, const Vector3D &v2 )
|
||||
{
|
||||
double xx = v2.x - v1.x;
|
||||
double yy = v2.y - v1.y;
|
||||
double zz = v2.z - v1.z;
|
||||
|
||||
return sqrt( xx * xx + yy * yy + zz * zz );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
double Vector3D::getDistanceSquared( const Vector3D &v1, const Vector3D &v2 )
|
||||
{
|
||||
double xx = v2.x - v1.x;
|
||||
double yy = v2.y - v1.y;
|
||||
double zz = v2.z - v1.z;
|
||||
|
||||
return xx * xx + yy * yy + zz * zz;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
double Vector3D::dotWith( const Vector3D &v )
|
||||
{
|
||||
return
|
||||
x * v.x +
|
||||
y * v.y +
|
||||
z * v.z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
void Vector3D::setToCross( const Vector3D &v1, const Vector3D &v2 )
|
||||
{
|
||||
x = v1.z * v2.y - v1.y * v2.z;
|
||||
y = v1.x * v2.z - v1.z * v2.x;
|
||||
z = v1.y * v2.x - v1.x * v2.y;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void Vector3D::setToSum( const Vector3D &v1, const Vector3D &v2 )
|
||||
{
|
||||
x = v1.x + v2.x;
|
||||
y = v1.y + v2.y;
|
||||
z = v1.z + v2.z;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
void Vector3D::halve()
|
||||
{
|
||||
x *= 0.5;
|
||||
y *= 0.5;
|
||||
z *= 0.5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
//-----------------------------------------------------------
|
||||
//
|
||||
// Created by Jeffrey Ventrella and added as a utility
|
||||
// class for High Fidelity Code base, April 2013
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
#ifndef __interface__vector3D__
|
||||
#define __interface__vector3D__
|
||||
|
||||
class Vector3D
|
||||
{
|
||||
public:
|
||||
|
||||
//------------------
|
||||
// members
|
||||
//------------------
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
|
||||
//------------------
|
||||
// methods
|
||||
//------------------
|
||||
Vector3D();
|
||||
Vector3D( double, double, double );
|
||||
Vector3D( const Vector3D & );
|
||||
|
||||
void clear();
|
||||
void set ( const Vector3D & );
|
||||
void setToScaled ( const Vector3D &, double );
|
||||
void add ( const Vector3D & );
|
||||
void subtract ( const Vector3D & );
|
||||
void addScaled ( const Vector3D &, double );
|
||||
void subtractScaled ( const Vector3D &, double );
|
||||
void normalize ();
|
||||
void setToCross ( const Vector3D &, const Vector3D & );
|
||||
void setToAverage ( const Vector3D &, const Vector3D & );
|
||||
void setToSum ( const Vector3D &, const Vector3D & );
|
||||
void setXYZ ( double, double, double );
|
||||
void addXYZ ( double, double, double );
|
||||
void setX ( double );
|
||||
void setY ( double );
|
||||
void setZ ( double );
|
||||
void addX ( double );
|
||||
void addY ( double );
|
||||
void addZ ( double );
|
||||
void scaleX ( double );
|
||||
void scaleY ( double );
|
||||
void scaleZ ( double );
|
||||
void halve ();
|
||||
double getX ();
|
||||
double getY ();
|
||||
double getZ ();
|
||||
double getMagnitude ();
|
||||
double getMagnitudeSquared ();
|
||||
double getDistance ( const Vector3D &, const Vector3D & );
|
||||
double getDistanceSquared ( const Vector3D &, const Vector3D & );
|
||||
double getDistanceTo ( const Vector3D & );
|
||||
double getDistanceSquaredTo( const Vector3D & );
|
||||
double dotWith ( const Vector3D & );
|
||||
void scale ( double );
|
||||
void setToDifference ( const Vector3D &, const Vector3D & );
|
||||
};
|
||||
|
||||
#endif
|
|
@ -829,10 +829,8 @@ void display(void)
|
|||
AgentList *agentList = AgentList::getInstance();
|
||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin();
|
||||
agent != agentList->getAgents().end();
|
||||
agent++)
|
||||
{
|
||||
if (agent->getLinkedData() != NULL)
|
||||
{
|
||||
agent++) {
|
||||
if (agent->getLinkedData() != NULL) {
|
||||
Head *agentHead = (Head *)agent->getLinkedData();
|
||||
glPushMatrix();
|
||||
glm::vec3 pos = agentHead->getPos();
|
||||
|
@ -872,8 +870,7 @@ void display(void)
|
|||
if (audioScope.getState()) audioScope.render();
|
||||
#endif
|
||||
|
||||
if (displayHeadMouse && !displayHead && statsOn)
|
||||
{
|
||||
if (displayHeadMouse && !displayHead && statsOn) {
|
||||
// Display small target box at center or head mouse target that can also be used to measure LOD
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
@ -1028,8 +1025,7 @@ void shiftPaintingColor()
|
|||
::paintingVoxel.blue = (::dominantColor==2)?randIntInRange(200,255):randIntInRange(40,100);
|
||||
}
|
||||
|
||||
void setupPaintingVoxel()
|
||||
{
|
||||
void setupPaintingVoxel() {
|
||||
glm::vec3 avatarPos = myAvatar.getPos();
|
||||
|
||||
::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space
|
||||
|
|
Loading…
Reference in a new issue