mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:59:49 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into render_voxels_optimization
This commit is contained in:
commit
2b11cad1ab
8 changed files with 215 additions and 174 deletions
|
@ -122,7 +122,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
// put her hand out so somebody can shake it
|
// put her hand out so somebody can shake it
|
||||||
eve.setHandPosition(glm::vec3(eve.getPosition()[0] - 0.2,
|
eve.setHandPosition(glm::vec3(eve.getPosition()[0] - 0.2,
|
||||||
0.2,
|
0.25,
|
||||||
eve.getPosition()[2] + 0.1));
|
eve.getPosition()[2] + 0.1));
|
||||||
// read eve's audio data
|
// read eve's audio data
|
||||||
AudioInjector eveAudioInjector("/etc/highfidelity/eve/resources/eve.raw");
|
AudioInjector eveAudioInjector("/etc/highfidelity/eve/resources/eve.raw");
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
//
|
//
|
||||||
// Created by Philip Rosedale on 9/11/12.
|
// Created by Philip Rosedale on 9/11/12.
|
||||||
// adapted by Jeffrey Ventrella
|
// adapted by Jeffrey Ventrella
|
||||||
// Copyright (c) 2012 Physical, Inc.. All rights reserved.
|
// Copyright (c) 2013 Physical, Inc.. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
@ -20,11 +20,15 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
/*
|
||||||
const bool BALLS_ON = false;
|
const bool BALLS_ON = false;
|
||||||
|
|
||||||
const bool AVATAR_GRAVITY = true;
|
const bool AVATAR_GRAVITY = true;
|
||||||
const float DECAY = 0.1;
|
const float DECAY = 0.1;
|
||||||
const float THRUST_MAG = 1200.0;
|
|
||||||
|
//const float THRUST_MAG = 1200.0;
|
||||||
|
const float THRUST_MAG = 0.0;
|
||||||
|
|
||||||
const float YAW_MAG = 500.0; //JJV - changed from 300.0;
|
const float YAW_MAG = 500.0; //JJV - changed from 300.0;
|
||||||
const float TEST_YAW_DECAY = 5.0;
|
const float TEST_YAW_DECAY = 5.0;
|
||||||
const float LIN_VEL_DECAY = 5.0;
|
const float LIN_VEL_DECAY = 5.0;
|
||||||
|
@ -32,17 +36,13 @@ const float MY_HAND_HOLDING_PULL = 0.2;
|
||||||
const float YOUR_HAND_HOLDING_PULL = 1.0;
|
const float YOUR_HAND_HOLDING_PULL = 1.0;
|
||||||
const float BODY_SPRING_FORCE = 6.0f;
|
const float BODY_SPRING_FORCE = 6.0f;
|
||||||
const float BODY_SPRING_DECAY = 16.0f;
|
const float BODY_SPRING_DECAY = 16.0f;
|
||||||
//const float COLLISION_FRICTION = 0.5;
|
|
||||||
//const float COLLISION_RADIUS_SCALAR = 1.8;
|
|
||||||
//const float COLLISION_BALL_FORCE = 0.1;
|
|
||||||
//const float COLLISION_BODY_FORCE = 3.0;
|
|
||||||
|
|
||||||
const float COLLISION_RADIUS_SCALAR = 1.8;
|
const float COLLISION_RADIUS_SCALAR = 1.8;
|
||||||
const float COLLISION_BALL_FORCE = 0.6;
|
const float COLLISION_BALL_FORCE = 0.6;
|
||||||
const float COLLISION_BODY_FORCE = 6.0;
|
const float COLLISION_BODY_FORCE = 6.0;
|
||||||
const float COLLISION_BALL_FRICTION = 200.0;
|
const float COLLISION_BALL_FRICTION = 200.0;
|
||||||
const float COLLISION_BODY_FRICTION = 0.5;
|
const float COLLISION_BODY_FRICTION = 0.5;
|
||||||
|
*/
|
||||||
|
|
||||||
float skinColor[] = {1.0, 0.84, 0.66};
|
float skinColor[] = {1.0, 0.84, 0.66};
|
||||||
float lightBlue[] = { 0.7, 0.8, 1.0 };
|
float lightBlue[] = { 0.7, 0.8, 1.0 };
|
||||||
float browColor[] = {210.0/255.0, 105.0/255.0, 30.0/255.0};
|
float browColor[] = {210.0/255.0, 105.0/255.0, 30.0/255.0};
|
||||||
|
@ -140,7 +140,7 @@ Avatar::Avatar(bool isMine) {
|
||||||
_renderPitch = 0.0;
|
_renderPitch = 0.0;
|
||||||
_sphere = NULL;
|
_sphere = NULL;
|
||||||
_interactingOther = NULL;
|
_interactingOther = NULL;
|
||||||
_closeEnoughToHoldHands = false;
|
//_canReachToOtherAvatar = false;
|
||||||
_handHoldingPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
_handHoldingPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
@ -162,7 +162,7 @@ Avatar::Avatar(const Avatar &otherAvatar) {
|
||||||
_velocity = otherAvatar._velocity;
|
_velocity = otherAvatar._velocity;
|
||||||
_thrust = otherAvatar._thrust;
|
_thrust = otherAvatar._thrust;
|
||||||
_rotation = otherAvatar._rotation;
|
_rotation = otherAvatar._rotation;
|
||||||
_closeEnoughToHoldHands = otherAvatar._closeEnoughToHoldHands;
|
//_canReachToOtherAvatar = otherAvatar._canReachToOtherAvatar;
|
||||||
_bodyYaw = otherAvatar._bodyYaw;
|
_bodyYaw = otherAvatar._bodyYaw;
|
||||||
_bodyPitch = otherAvatar._bodyPitch;
|
_bodyPitch = otherAvatar._bodyPitch;
|
||||||
_bodyRoll = otherAvatar._bodyRoll;
|
_bodyRoll = otherAvatar._bodyRoll;
|
||||||
|
@ -231,7 +231,6 @@ Avatar::Avatar(const Avatar &otherAvatar) {
|
||||||
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
||||||
_head.noise = otherAvatar._head.noise;
|
_head.noise = otherAvatar._head.noise;
|
||||||
|
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
|
||||||
if (iris_texture.size() == 0) {
|
if (iris_texture.size() == 0) {
|
||||||
|
@ -322,7 +321,14 @@ void Avatar::setMousePressed( bool d ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Avatar::getIsNearInteractingOther() {
|
||||||
|
return _avatarTouch.getAbleToReachOtherAvatar();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime) {
|
void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
|
float nearestAvatarDistance = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
//keep this - I'm still using it to test things....
|
//keep this - I'm still using it to test things....
|
||||||
/*
|
/*
|
||||||
|
@ -342,18 +348,19 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
// reset hand and arm positions according to hand movement
|
// reset hand and arm positions according to hand movement
|
||||||
updateHandMovement( deltaTime );
|
updateHandMovement( deltaTime );
|
||||||
|
|
||||||
if ( !_closeEnoughToHoldHands ) {
|
if ( !_avatarTouch.getAbleToReachOtherAvatar() ) {
|
||||||
//initialize _handHolding
|
//initialize _handHolding
|
||||||
_handHoldingPosition = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
_handHoldingPosition = _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||||
}
|
}
|
||||||
|
|
||||||
_closeEnoughToHoldHands = false; // reset for the next go-round
|
//reset these for the next go-round
|
||||||
|
_avatarTouch.setAbleToReachOtherAvatar (false);
|
||||||
|
_avatarTouch.setHandsCloseEnoughToGrasp(false);
|
||||||
|
|
||||||
// if the avatar being simulated is mine, then loop through
|
// if the avatar being simulated is mine, then loop through
|
||||||
// all the other avatars for potential interactions...
|
// all the other avatars for potential interactions...
|
||||||
if ( _isMine )
|
if ( _isMine )
|
||||||
{
|
{
|
||||||
//float closestDistance = 10000.0f;
|
|
||||||
|
|
||||||
AgentList* agentList = AgentList::getInstance();
|
AgentList* agentList = AgentList::getInstance();
|
||||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
|
@ -365,21 +372,31 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
|
|
||||||
// test other avatar hand position for proximity
|
// test other avatar hand position for proximity
|
||||||
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
||||||
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_SHOULDER );
|
||||||
|
|
||||||
float distance = glm::length( v );
|
float distance = glm::length( v );
|
||||||
if ( distance < _maxArmLength + _maxArmLength ) {
|
if (distance < nearestAvatarDistance) { nearestAvatarDistance = distance; }
|
||||||
|
|
||||||
|
if (distance < _maxArmLength + _maxArmLength) {
|
||||||
|
|
||||||
//closestDistance = distance;
|
|
||||||
_interactingOther = otherAvatar;
|
_interactingOther = otherAvatar;
|
||||||
_closeEnoughToHoldHands = true;
|
_avatarTouch.setAbleToReachOtherAvatar(true);
|
||||||
|
|
||||||
|
glm::vec3 vectorBetweenHands( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||||
|
vectorBetweenHands -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||||
|
float distanceBetweenHands = glm::length(vectorBetweenHands);
|
||||||
|
|
||||||
|
if (distanceBetweenHands < _avatarTouch.HANDS_CLOSE_ENOUGH_TO_GRASP) {
|
||||||
|
_avatarTouch.setHandsCloseEnoughToGrasp(true);
|
||||||
|
}
|
||||||
|
|
||||||
// if I am holding hands with another avatar, a force is applied
|
// if I am holding hands with another avatar, a force is applied
|
||||||
if (( _handState == 1 ) || ( _interactingOther->_handState == 1 )) {
|
if (( _handState == 1 ) || ( _interactingOther->_handState == 1 )) {
|
||||||
|
|
||||||
// if the hands are close enough to grasp...
|
// if the hands are close enough to grasp...
|
||||||
//if (distance < 0.1)
|
if (distanceBetweenHands < _avatarTouch.HANDS_CLOSE_ENOUGH_TO_GRASP)
|
||||||
{
|
{
|
||||||
|
// apply the forces...
|
||||||
glm::vec3 vectorToOtherHand = _interactingOther->_handPosition - _handHoldingPosition;
|
glm::vec3 vectorToOtherHand = _interactingOther->_handPosition - _handHoldingPosition;
|
||||||
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHoldingPosition;
|
glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHoldingPosition;
|
||||||
|
|
||||||
|
@ -387,6 +404,7 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
_handHoldingPosition += vectorToMyHand * MY_HAND_HOLDING_PULL;
|
_handHoldingPosition += vectorToMyHand * MY_HAND_HOLDING_PULL;
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHoldingPosition;
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHoldingPosition;
|
||||||
|
|
||||||
|
// apply a force to the avatar body
|
||||||
if ( glm::length(vectorToOtherHand) > _maxArmLength * 0.9 ) {
|
if ( glm::length(vectorToOtherHand) > _maxArmLength * 0.9 ) {
|
||||||
_velocity += vectorToOtherHand;
|
_velocity += vectorToOtherHand;
|
||||||
}
|
}
|
||||||
|
@ -399,25 +417,23 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
// Set the vector we send for hand position to other people to be our right hand
|
// Set the vector we send for hand position to other people to be our right hand
|
||||||
setHandPosition(_bone[ AVATAR_BONE_RIGHT_HAND ].position);
|
setHandPosition(_bone[ AVATAR_BONE_RIGHT_HAND ].position);
|
||||||
|
|
||||||
//update the effects of touching another avatar
|
|
||||||
}//if ( _isMine )
|
}//if ( _isMine )
|
||||||
|
|
||||||
//constrain right arm length and re-adjust elbow position as it bends
|
//constrain right arm length and re-adjust elbow position as it bends
|
||||||
updateArmIKAndConstraints( deltaTime );
|
updateArmIKAndConstraints( deltaTime );
|
||||||
|
|
||||||
// set hand positions for _avatarTouch.setMyHandPosition AFTER calling updateArmIKAndConstraints
|
// set hand positions for _avatarTouch.setMyHandPosition AFTER calling updateArmIKAndConstraints
|
||||||
//if ( _interactingOther != NULL ) {
|
if ( _interactingOther ) {
|
||||||
if ( _interactingOther ) { // Brad recommended I use this method pof checking that a pointer is valid
|
|
||||||
if (_isMine) {
|
if (_isMine) {
|
||||||
_avatarTouch.setMyHandPosition ( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
_avatarTouch.setMyHandPosition ( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||||
_avatarTouch.setYourHandPosition( _interactingOther->_handPosition );
|
_avatarTouch.setYourHandPosition( _interactingOther->_bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||||
_avatarTouch.setMyHandState ( _handState );
|
_avatarTouch.setMyHandState ( _handState );
|
||||||
_avatarTouch.setYourHandState ( _interactingOther->_handState );
|
_avatarTouch.setYourHandState ( _interactingOther->_handState );
|
||||||
_avatarTouch.simulate(deltaTime);
|
_avatarTouch.simulate(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_closeEnoughToHoldHands) {
|
if (!_avatarTouch.getAbleToReachOtherAvatar() ) {
|
||||||
_interactingOther = NULL;
|
_interactingOther = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,6 +487,15 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
|
|
||||||
// decay velocity
|
// decay velocity
|
||||||
_velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime );
|
_velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime );
|
||||||
|
|
||||||
|
// If someone is near, damp velocity as a function of closeness
|
||||||
|
const float AVATAR_BRAKING_RANGE = 1.2f;
|
||||||
|
const float AVATAR_BRAKING_STRENGTH = 25.f;
|
||||||
|
if (_isMine && (nearestAvatarDistance < AVATAR_BRAKING_RANGE)) {
|
||||||
|
_velocity *=
|
||||||
|
(1.f - deltaTime * AVATAR_BRAKING_STRENGTH *
|
||||||
|
(AVATAR_BRAKING_RANGE - nearestAvatarDistance));
|
||||||
|
}
|
||||||
|
|
||||||
// update head information
|
// update head information
|
||||||
updateHead(deltaTime);
|
updateHead(deltaTime);
|
||||||
|
@ -488,7 +513,7 @@ _head.leanForward = 0.02 * sin( tt * 0.8 );
|
||||||
|
|
||||||
void Avatar::updateHead(float deltaTime) {
|
void Avatar::updateHead(float deltaTime) {
|
||||||
|
|
||||||
//apply the head lean values to the springy positions in the upper-spine...
|
//apply the head lean values to the springy position...
|
||||||
if ( fabs( _head.leanSideways + _head.leanForward ) > 0.0f ) {
|
if ( fabs( _head.leanSideways + _head.leanForward ) > 0.0f ) {
|
||||||
glm::vec3 headLean =
|
glm::vec3 headLean =
|
||||||
_orientation.getRight() * _head.leanSideways +
|
_orientation.getRight() * _head.leanSideways +
|
||||||
|
@ -722,7 +747,6 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( usingBigSphereCollisionTest ) {
|
if ( usingBigSphereCollisionTest ) {
|
||||||
|
|
||||||
// show TEST big sphere
|
// show TEST big sphere
|
||||||
glColor4f( 0.5f, 0.6f, 0.8f, 0.7 );
|
glColor4f( 0.5f, 0.6f, 0.8f, 0.7 );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -732,7 +756,7 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
// render body
|
//render body
|
||||||
renderBody();
|
renderBody();
|
||||||
|
|
||||||
// render head
|
// render head
|
||||||
|
@ -741,12 +765,11 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this is my avatar, then render my interactions with the other avatar
|
// if this is my avatar, then render my interactions with the other avatar
|
||||||
if (( _isMine ) && ( _closeEnoughToHoldHands )) {
|
if ( _isMine ) {
|
||||||
_avatarTouch.render();
|
_avatarTouch.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the balls
|
// Render the balls
|
||||||
|
|
||||||
if (_balls) {
|
if (_balls) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(_position.x, _position.y, _position.z);
|
glTranslatef(_position.x, _position.y, _position.z);
|
||||||
|
@ -1147,7 +1170,7 @@ void Avatar::updateSkeleton() {
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handPosition;
|
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the following will be replaced by a proper rotation...
|
// the following will be replaced by a proper rotation...close
|
||||||
float xx = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getRight() );
|
float xx = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getRight() );
|
||||||
float yy = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getUp () );
|
float yy = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getUp () );
|
||||||
float zz = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getFront() );
|
float zz = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getFront() );
|
||||||
|
@ -1353,7 +1376,9 @@ void Avatar::SetNewHeadTarget(float pitch, float yaw) {
|
||||||
_head.yawTarget = yaw;
|
_head.yawTarget = yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// Process UDP interface data from Android transmitter or Google Glass
|
// Process UDP interface data from Android transmitter or Google Glass
|
||||||
|
//
|
||||||
void Avatar::processTransmitterData(unsigned char* packetData, int numBytes) {
|
void Avatar::processTransmitterData(unsigned char* packetData, int numBytes) {
|
||||||
// Read a packet from a transmitter app, process the data
|
// Read a packet from a transmitter app, process the data
|
||||||
float
|
float
|
||||||
|
@ -1364,30 +1389,43 @@ void Avatar::processTransmitterData(unsigned char* packetData, int numBytes) {
|
||||||
rot1, rot2, rot3, rot4; // Rotation of device:
|
rot1, rot2, rot3, rot4; // Rotation of device:
|
||||||
// rot1 = roll, ranges from -1 to 1, 0 = flat on table
|
// rot1 = roll, ranges from -1 to 1, 0 = flat on table
|
||||||
// rot2 = pitch, ranges from -1 to 1, 0 = flat on table
|
// rot2 = pitch, ranges from -1 to 1, 0 = flat on table
|
||||||
// rot3 = yaw, ranges from -1 to 1
|
// rot3 = yaw, ranges from -1 to 1
|
||||||
|
char device[100]; // Device ID
|
||||||
|
|
||||||
const bool IS_GLASS = false; // Whether to assume this is a Google glass transmitting
|
enum deviceTypes { DEVICE_GLASS, DEVICE_ANDROID, DEVICE_IPHONE, DEVICE_UNKNOWN };
|
||||||
|
|
||||||
sscanf((char *)packetData, "tacc %f %f %f gra %f %f %f gyr %f %f %f lin %f %f %f rot %f %f %f %f",
|
sscanf((char *)packetData,
|
||||||
|
"tacc %f %f %f gra %f %f %f gyr %f %f %f lin %f %f %f rot %f %f %f %f dna \"%s",
|
||||||
&accX, &accY, &accZ,
|
&accX, &accY, &accZ,
|
||||||
&graX, &graY, &graZ,
|
&graX, &graY, &graZ,
|
||||||
&gyrX, &gyrY, &gyrZ,
|
&gyrX, &gyrY, &gyrZ,
|
||||||
&linX, &linY, &linZ,
|
&linX, &linY, &linZ,
|
||||||
&rot1, &rot2, &rot3, &rot4);
|
&rot1, &rot2, &rot3, &rot4, (char *)&device);
|
||||||
|
|
||||||
|
// decode transmitter device type
|
||||||
|
deviceTypes deviceType = DEVICE_UNKNOWN;
|
||||||
|
if (strcmp(device, "ADR")) {
|
||||||
|
deviceType = DEVICE_ANDROID;
|
||||||
|
} else {
|
||||||
|
deviceType = DEVICE_GLASS;
|
||||||
|
}
|
||||||
|
|
||||||
if (_transmitterPackets++ == 0) {
|
if (_transmitterPackets++ == 0) {
|
||||||
// If first packet received, note time, turn head spring return OFF, get start rotation
|
// If first packet received, note time, turn head spring return OFF, get start rotation
|
||||||
gettimeofday(&_transmitterTimer, NULL);
|
gettimeofday(&_transmitterTimer, NULL);
|
||||||
if (IS_GLASS) {
|
if (deviceType == DEVICE_GLASS) {
|
||||||
setHeadReturnToCenter(true);
|
setHeadReturnToCenter(true);
|
||||||
setHeadSpringScale(10.f);
|
setHeadSpringScale(10.f);
|
||||||
printLog("Using Google Glass to drive head, springs ON.\n");
|
printLog("Using Google Glass to drive head, springs ON.\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setHeadReturnToCenter(false);
|
setHeadReturnToCenter(false);
|
||||||
printLog("Using Transmitter to drive head, springs OFF.\n");
|
printLog("Using Transmitter %s to drive head, springs OFF.\n", device);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//printLog("Packet: [%s]\n", packetData);
|
||||||
|
//printLog("Version: %s\n", device);
|
||||||
|
|
||||||
_transmitterInitialReading = glm::vec3( rot3,
|
_transmitterInitialReading = glm::vec3( rot3,
|
||||||
rot2,
|
rot2,
|
||||||
rot1 );
|
rot1 );
|
||||||
|
@ -1413,7 +1451,7 @@ void Avatar::processTransmitterData(unsigned char* packetData, int numBytes) {
|
||||||
if (eulerAngles.x < -180.f) { eulerAngles.x += 360.f; }
|
if (eulerAngles.x < -180.f) { eulerAngles.x += 360.f; }
|
||||||
|
|
||||||
glm::vec3 angularVelocity;
|
glm::vec3 angularVelocity;
|
||||||
if (!IS_GLASS) {
|
if (deviceType != DEVICE_GLASS) {
|
||||||
angularVelocity = glm::vec3(glm::degrees(gyrZ), glm::degrees(-gyrX), glm::degrees(gyrY));
|
angularVelocity = glm::vec3(glm::degrees(gyrZ), glm::degrees(-gyrX), glm::degrees(gyrY));
|
||||||
setHeadFromGyros( &eulerAngles, &angularVelocity,
|
setHeadFromGyros( &eulerAngles, &angularVelocity,
|
||||||
(_transmitterHz == 0.f) ? 0.f : 1.f / _transmitterHz, 1.0);
|
(_transmitterHz == 0.f) ? 0.f : 1.f / _transmitterHz, 1.0);
|
||||||
|
@ -1424,7 +1462,6 @@ void Avatar::processTransmitterData(unsigned char* packetData, int numBytes) {
|
||||||
(_transmitterHz == 0.f) ? 0.f : 1.f / _transmitterHz, 1000.0);
|
(_transmitterHz == 0.f) ? 0.f : 1.f / _transmitterHz, 1000.0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::setHeadFromGyros(glm::vec3* eulerAngles, glm::vec3* angularVelocity, float deltaTime, float smoothingTime) {
|
void Avatar::setHeadFromGyros(glm::vec3* eulerAngles, glm::vec3* angularVelocity, float deltaTime, float smoothingTime) {
|
||||||
|
@ -1471,8 +1508,13 @@ glm::vec3 Avatar::getGravity(glm::vec3 pos) {
|
||||||
// For now, we'll test this with a simple global lookup, but soon we will add getting this
|
// For now, we'll test this with a simple global lookup, but soon we will add getting this
|
||||||
// from the domain/voxelserver (or something similar)
|
// from the domain/voxelserver (or something similar)
|
||||||
//
|
//
|
||||||
if (glm::length(pos) < 5.f) {
|
if ((pos.x > 0.f) &&
|
||||||
// If near the origin sphere, turn gravity ON
|
(pos.x < 10.f) &&
|
||||||
|
(pos.z > 0.f) &&
|
||||||
|
(pos.z < 10.f) &&
|
||||||
|
(pos.y > 0.f) &&
|
||||||
|
(pos.y < 3.f)) {
|
||||||
|
// If above ground plane, turn gravity on
|
||||||
return glm::vec3(0.f, -1.f, 0.f);
|
return glm::vec3(0.f, -1.f, 0.f);
|
||||||
} else {
|
} else {
|
||||||
// If flying in space, turn gravity OFF
|
// If flying in space, turn gravity OFF
|
||||||
|
|
|
@ -92,8 +92,8 @@ public:
|
||||||
float getBodyYaw() {return _bodyYaw;};
|
float getBodyYaw() {return _bodyYaw;};
|
||||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||||
|
|
||||||
bool getIsNearInteractingOther() { return _closeEnoughToHoldHands; }
|
bool getIsNearInteractingOther();
|
||||||
|
|
||||||
float getAbsoluteHeadYaw() const;
|
float getAbsoluteHeadYaw() const;
|
||||||
void setLeanForward(float dist);
|
void setLeanForward(float dist);
|
||||||
void setLeanSideways(float dist);
|
void setLeanSideways(float dist);
|
||||||
|
@ -144,6 +144,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
const bool BALLS_ON = false;
|
||||||
const bool AVATAR_GRAVITY = true;
|
const bool AVATAR_GRAVITY = true;
|
||||||
const float DECAY = 0.1;
|
const float DECAY = 0.1;
|
||||||
const float THRUST_MAG = 1200.0;
|
const float THRUST_MAG = 1200.0;
|
||||||
|
@ -226,45 +227,43 @@ private:
|
||||||
float returnSpringScale;
|
float returnSpringScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
AvatarHead _head;
|
AvatarHead _head;
|
||||||
bool _isMine;
|
bool _isMine;
|
||||||
glm::vec3 _TEST_bigSpherePosition;
|
glm::vec3 _TEST_bigSpherePosition;
|
||||||
float _TEST_bigSphereRadius;
|
float _TEST_bigSphereRadius;
|
||||||
bool _mousePressed;
|
bool _mousePressed;
|
||||||
float _bodyPitchDelta;
|
float _bodyPitchDelta;
|
||||||
float _bodyYawDelta;
|
float _bodyYawDelta;
|
||||||
float _bodyRollDelta;
|
float _bodyRollDelta;
|
||||||
bool _usingBodySprings;
|
bool _usingBodySprings;
|
||||||
glm::vec3 _movedHandOffset;
|
glm::vec3 _movedHandOffset;
|
||||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||||
AvatarMode _mode;
|
AvatarMode _mode;
|
||||||
glm::vec3 _handHoldingPosition;
|
glm::vec3 _handHoldingPosition;
|
||||||
glm::vec3 _velocity;
|
glm::vec3 _velocity;
|
||||||
glm::vec3 _thrust;
|
glm::vec3 _thrust;
|
||||||
float _speed;
|
float _speed;
|
||||||
float _maxArmLength;
|
float _maxArmLength;
|
||||||
Orientation _orientation;
|
Orientation _orientation;
|
||||||
int _driveKeys[MAX_DRIVE_KEYS];
|
int _driveKeys[MAX_DRIVE_KEYS];
|
||||||
GLUquadric* _sphere;
|
GLUquadric* _sphere;
|
||||||
float _renderYaw;
|
float _renderYaw;
|
||||||
float _renderPitch; // Pitch from view frustum when this is own head
|
float _renderPitch; // Pitch from view frustum when this is own head
|
||||||
bool _transmitterIsFirstData;
|
bool _transmitterIsFirstData;
|
||||||
timeval _transmitterTimeLastReceived;
|
timeval _transmitterTimeLastReceived;
|
||||||
timeval _transmitterTimer;
|
timeval _transmitterTimer;
|
||||||
float _transmitterHz;
|
float _transmitterHz;
|
||||||
int _transmitterPackets;
|
int _transmitterPackets;
|
||||||
glm::vec3 _transmitterInitialReading;
|
glm::vec3 _transmitterInitialReading;
|
||||||
Avatar* _interactingOther;
|
Avatar* _interactingOther;
|
||||||
bool _closeEnoughToHoldHands;
|
float _pelvisStandingHeight;
|
||||||
float _pelvisStandingHeight;
|
float _height;
|
||||||
float _height;
|
Balls* _balls;
|
||||||
Balls* _balls;
|
AvatarTouch _avatarTouch;
|
||||||
AvatarTouch _avatarTouch;
|
bool _displayingHead; // should be false if in first-person view
|
||||||
bool _displayingHead; // should be false if in first-person view
|
bool _returnHeadToCenter;
|
||||||
bool _returnHeadToCenter;
|
|
||||||
|
|
||||||
|
|
||||||
// private methods...
|
// private methods...
|
||||||
void initializeSkeleton();
|
void initializeSkeleton();
|
||||||
void updateSkeleton();
|
void updateSkeleton();
|
||||||
|
|
|
@ -11,15 +11,18 @@
|
||||||
#include "AvatarTouch.h"
|
#include "AvatarTouch.h"
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
const float THREAD_RADIUS = 0.007;
|
const float THREAD_RADIUS = 0.012;
|
||||||
|
|
||||||
AvatarTouch::AvatarTouch() {
|
AvatarTouch::AvatarTouch() {
|
||||||
|
|
||||||
_myHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
_myHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||||
_yourHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
_yourHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||||
_myHandState = 0;
|
_myHandState = 0;
|
||||||
_yourHandState = 0;
|
_yourHandState = 0;
|
||||||
|
|
||||||
|
_canReachToOtherAvatar = false;
|
||||||
|
_handsCloseEnoughToGrasp = false;
|
||||||
|
|
||||||
for (int p=0; p<NUM_POINTS; p++) {
|
for (int p=0; p<NUM_POINTS; p++) {
|
||||||
_point[p] = glm::vec3( 0.0, 0.0, 0.0 );
|
_point[p] = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
}
|
}
|
||||||
|
@ -45,43 +48,49 @@ void AvatarTouch::render() {
|
||||||
|
|
||||||
glm::vec3 v1( _myHandPosition );
|
glm::vec3 v1( _myHandPosition );
|
||||||
glm::vec3 v2( _yourHandPosition );
|
glm::vec3 v2( _yourHandPosition );
|
||||||
|
|
||||||
|
if (_canReachToOtherAvatar) {
|
||||||
|
// if my hand is grasping, show it...
|
||||||
|
if ( _myHandState == 1 ) {
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z);
|
||||||
|
glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f );
|
||||||
|
glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f );
|
||||||
|
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if your hand is grasping, show it...
|
||||||
|
if ( _yourHandState == 1 ) {
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(_yourHandPosition.x, _yourHandPosition.y, _yourHandPosition.z);
|
||||||
|
glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f );
|
||||||
|
glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f );
|
||||||
|
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if my hand is grasping, show it...
|
//show beam
|
||||||
if ( _myHandState == 1 ) {
|
if (_handsCloseEnoughToGrasp) {
|
||||||
glPushMatrix();
|
glLineWidth( 2.0 );
|
||||||
glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z);
|
glColor4f( 0.7f, 0.4f, 0.1f, 0.3 );
|
||||||
glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f );
|
glBegin( GL_LINE_STRIP );
|
||||||
glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f );
|
glVertex3f( v1.x, v1.y, v1.z );
|
||||||
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
glVertex3f( v2.x, v2.y, v2.z );
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
// if your hand is grasping, show it...
|
|
||||||
if ( _yourHandState == 1 ) {
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(_yourHandPosition.x, _yourHandPosition.y, _yourHandPosition.z);
|
|
||||||
glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f );
|
|
||||||
glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f );
|
|
||||||
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
glLineWidth( 2.0 );
|
|
||||||
glColor4f( 0.7f, 0.4f, 0.1f, 0.3 );
|
|
||||||
glBegin( GL_LINE_STRIP );
|
|
||||||
glVertex3f( v1.x, v1.y, v1.z );
|
|
||||||
glVertex3f( v2.x, v2.y, v2.z );
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glColor4f( 1.0f, 1.0f, 0.0f, 0.8 );
|
|
||||||
|
|
||||||
for (int p=0; p<NUM_POINTS; p++) {
|
|
||||||
glBegin(GL_POINTS);
|
|
||||||
glVertex3f(_point[p].x, _point[p].y, _point[p].z);
|
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
|
||||||
|
glColor4f( 1.0f, 1.0f, 0.0f, 0.8 );
|
||||||
|
|
||||||
|
for (int p=0; p<NUM_POINTS; p++) {
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
glVertex3f(_point[p].x, _point[p].y, _point[p].z);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AvatarTouch::simulate (float deltaTime) {
|
void AvatarTouch::simulate (float deltaTime) {
|
||||||
|
|
||||||
glm::vec3 v = _yourHandPosition - _myHandPosition;
|
glm::vec3 v = _yourHandPosition - _myHandPosition;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// interface
|
// interface
|
||||||
//
|
//
|
||||||
// Created by Jeffrey Ventrella
|
// Created by Jeffrey Ventrella
|
||||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef __interface__AvatarTouch__
|
#ifndef __interface__AvatarTouch__
|
||||||
|
@ -13,15 +13,25 @@
|
||||||
|
|
||||||
class AvatarTouch {
|
class AvatarTouch {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
const float HANDS_CLOSE_ENOUGH_TO_GRASP = 0.1;
|
||||||
|
|
||||||
AvatarTouch();
|
AvatarTouch();
|
||||||
|
|
||||||
|
void simulate(float deltaTime);
|
||||||
|
void render();
|
||||||
|
|
||||||
void setMyHandPosition ( glm::vec3 position );
|
void setMyHandPosition ( glm::vec3 position );
|
||||||
void setYourHandPosition( glm::vec3 position );
|
void setYourHandPosition( glm::vec3 position );
|
||||||
void setMyHandState ( int state );
|
void setMyHandState ( int state );
|
||||||
void setYourHandState ( int state );
|
void setYourHandState ( int state );
|
||||||
void simulate (float deltaTime);
|
|
||||||
void render();
|
|
||||||
|
|
||||||
|
void setAbleToReachOtherAvatar ( bool a ) { _canReachToOtherAvatar = a; }
|
||||||
|
void setHandsCloseEnoughToGrasp( bool h ) { _handsCloseEnoughToGrasp = h; }
|
||||||
|
|
||||||
|
bool getAbleToReachOtherAvatar () { return _canReachToOtherAvatar; }
|
||||||
|
bool getHandsCloseEnoughToGrasp() { return _handsCloseEnoughToGrasp; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static const int NUM_POINTS = 100;
|
static const int NUM_POINTS = 100;
|
||||||
|
@ -31,6 +41,8 @@ private:
|
||||||
glm::vec3 _yourHandPosition;
|
glm::vec3 _yourHandPosition;
|
||||||
int _myHandState;
|
int _myHandState;
|
||||||
int _yourHandState;
|
int _yourHandState;
|
||||||
|
bool _canReachToOtherAvatar;
|
||||||
|
bool _handsCloseEnoughToGrasp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -213,42 +213,28 @@ void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, gl
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawGroundPlaneGrid( float size, int resolution )
|
void drawGroundPlaneGrid(float size)
|
||||||
{
|
{
|
||||||
|
|
||||||
glColor3f( 0.4f, 0.5f, 0.3f );
|
glColor3f( 0.4f, 0.5f, 0.3f );
|
||||||
glLineWidth(2.0);
|
glLineWidth(2.0);
|
||||||
|
|
||||||
float gridSize = 10.0;
|
for (float x = 0; x <= size; x++) {
|
||||||
int gridResolution = 20;
|
glBegin(GL_LINES);
|
||||||
|
glVertex3f(x, 0.0f, 0);
|
||||||
for (int g=0; g<gridResolution; g++)
|
glVertex3f(x, 0.0f, size);
|
||||||
{
|
glVertex3f(0, 0.0f, x);
|
||||||
float fraction = (float)g / (float)( gridResolution - 1 );
|
glVertex3f(size, 0.0f, x);
|
||||||
float inc = -gridSize * ONE_HALF + fraction * gridSize;
|
glEnd();
|
||||||
glBegin( GL_LINE_STRIP );
|
}
|
||||||
glVertex3f( inc, 0.0f, -gridSize * ONE_HALF );
|
|
||||||
glVertex3f( inc, 0.0f, gridSize * ONE_HALF );
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int g=0; g<gridResolution; g++)
|
|
||||||
{
|
|
||||||
float fraction = (float)g / (float)( gridResolution - 1 );
|
|
||||||
float inc = -gridSize * ONE_HALF + fraction * gridSize;
|
|
||||||
glBegin( GL_LINE_STRIP );
|
|
||||||
glVertex3f( -gridSize * ONE_HALF, 0.0f, inc );
|
|
||||||
glVertex3f( gridSize * ONE_HALF, 0.0f, inc );
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a translucent quad just underneath the grid.
|
// Draw a translucent quad just underneath the grid.
|
||||||
glColor4f(0.5, 0.5, 0.5, 0.4);
|
glColor4f(0.5, 0.5, 0.5, 0.4);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex3f(-gridSize * ONE_HALF, 0, -gridSize * ONE_HALF);
|
glVertex3f(0, 0, 0);
|
||||||
glVertex3f(gridSize * ONE_HALF, 0, -gridSize * ONE_HALF);
|
glVertex3f(size, 0, 0);
|
||||||
glVertex3f(gridSize * ONE_HALF, 0, gridSize * ONE_HALF);
|
glVertex3f(size, 0, size);
|
||||||
glVertex3f(-gridSize * ONE_HALF, 0, gridSize * ONE_HALF);
|
glVertex3f(0, 0, size);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, gl
|
||||||
float r=1.0, float g=1.0, float b=1.0);
|
float r=1.0, float g=1.0, float b=1.0);
|
||||||
double diffclock(timeval *clock1,timeval *clock2);
|
double diffclock(timeval *clock1,timeval *clock2);
|
||||||
|
|
||||||
void drawGroundPlaneGrid( float size, int resolution );
|
void drawGroundPlaneGrid(float size);
|
||||||
|
|
||||||
void renderOrientationDirections( glm::vec3 position, Orientation orientation, float size );
|
void renderOrientationDirections( glm::vec3 position, Orientation orientation, float size );
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
// Welcome Aboard!
|
// Welcome Aboard!
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Keyboard Commands:
|
// Keyboard Commands:
|
||||||
//
|
//
|
||||||
// / = toggle stats display
|
// / = toggle stats display
|
||||||
// spacebar = reset gyros/head position
|
// spacebar = reset gyros/head position
|
||||||
|
@ -137,7 +137,7 @@ bool wantToKillLocalVoxels = false;
|
||||||
Audio audio(&audioScope, &myAvatar);
|
Audio audio(&audioScope, &myAvatar);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IDLE_SIMULATE_MSECS 8 // How often should call simulate and other stuff
|
#define IDLE_SIMULATE_MSECS 16 // How often should call simulate and other stuff
|
||||||
// in the idle loop?
|
// in the idle loop?
|
||||||
|
|
||||||
// Where one's own agent begins in the world (needs to become a dynamic thing passed to the program)
|
// Where one's own agent begins in the world (needs to become a dynamic thing passed to the program)
|
||||||
|
@ -226,37 +226,30 @@ void displayStats(void)
|
||||||
if (::menuOn == 0) {
|
if (::menuOn == 0) {
|
||||||
statsVerticalOffset = 8;
|
statsVerticalOffset = 8;
|
||||||
}
|
}
|
||||||
// bitmap chars are about 10 pels high
|
|
||||||
char legend[] = "/ - toggle this display, Q - exit, H - show head, M - show hand, T - test audio";
|
|
||||||
drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, legend);
|
|
||||||
|
|
||||||
char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
|
|
||||||
drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2);
|
|
||||||
|
|
||||||
glm::vec3 avatarPos = myAvatar.getPosition();
|
|
||||||
|
|
||||||
char stats[200];
|
char stats[200];
|
||||||
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ",
|
sprintf(stats, "%3.0f FPS, %d Pkts/sec, %3.2f Mbps",
|
||||||
FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z);
|
FPS, packetsPerSecond, (float)bytesPerSecond * 8.f / 1000000.f);
|
||||||
drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats);
|
drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);
|
||||||
|
|
||||||
std::stringstream voxelStats;
|
std::stringstream voxelStats;
|
||||||
voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered() << " Updated: " << voxels.getVoxelsUpdated();
|
voxelStats.precision(4);
|
||||||
drawtext(10, statsVerticalOffset + 70, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered() / 1000.f << "K Updated: " << voxels.getVoxelsUpdated()/1000.f << "K";
|
||||||
|
drawtext(10, statsVerticalOffset + 230, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
||||||
|
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() << " (" << voxels.getVoxelsCreatedPerSecondAverage()
|
voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() / 1000.f << "K (" << voxels.getVoxelsCreatedPerSecondAverage() / 1000.f
|
||||||
<< "/sec) ";
|
<< "Kps) ";
|
||||||
drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
||||||
|
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() << " (" << voxels.getVoxelsColoredPerSecondAverage()
|
voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() / 1000.f << "K (" << voxels.getVoxelsColoredPerSecondAverage() / 1000.f
|
||||||
<< "/sec) ";
|
<< "Kps) ";
|
||||||
drawtext(10, statsVerticalOffset + 270, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
drawtext(10, statsVerticalOffset + 270, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
||||||
|
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
voxelStats << "Voxels Bytes Read: " << voxels.getVoxelsBytesRead()
|
voxelStats << "Voxel Bits Read: " << voxels.getVoxelsBytesRead() * 8.f / 1000000.f
|
||||||
<< " (" << voxels.getVoxelsBytesReadPerSecondAverage() << " Bps)";
|
<< "M (" << voxels.getVoxelsBytesReadPerSecondAverage() * 8.f / 1000000.f << " Mbps)";
|
||||||
drawtext(10, statsVerticalOffset + 290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
drawtext(10, statsVerticalOffset + 290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
||||||
|
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
|
@ -264,13 +257,13 @@ void displayStats(void)
|
||||||
? ((float) voxels.getVoxelsBytesRead() / voxels.getVoxelsColored())
|
? ((float) voxels.getVoxelsBytesRead() / voxels.getVoxelsColored())
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
voxelStats << "Voxels Bytes per Colored: " << voxelsBytesPerColored;
|
voxelStats << "Voxels Bits per Colored: " << voxelsBytesPerColored * 8;
|
||||||
drawtext(10, statsVerticalOffset + 310, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
drawtext(10, statsVerticalOffset + 310, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
|
||||||
|
|
||||||
Agent *avatarMixer = AgentList::getInstance()->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER);
|
Agent *avatarMixer = AgentList::getInstance()->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER);
|
||||||
char avatarMixerStats[200];
|
char avatarMixerStats[200];
|
||||||
if (avatarMixer) {
|
if (avatarMixer) {
|
||||||
sprintf(avatarMixerStats, "Avatar Mixer - %.f kbps, %.f pps",
|
sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
|
||||||
roundf(avatarMixer->getAverageKilobitsPerSecond()),
|
roundf(avatarMixer->getAverageKilobitsPerSecond()),
|
||||||
roundf(avatarMixer->getAveragePacketsPerSecond()));
|
roundf(avatarMixer->getAveragePacketsPerSecond()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -859,7 +852,7 @@ void display(void)
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
//draw a grid ground plane....
|
//draw a grid ground plane....
|
||||||
drawGroundPlaneGrid( 5.0f, 9 );
|
drawGroundPlaneGrid(10.f);
|
||||||
|
|
||||||
// Draw voxels
|
// Draw voxels
|
||||||
if ( showingVoxels )
|
if ( showingVoxels )
|
||||||
|
|
Loading…
Reference in a new issue