mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 04:03:59 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into view_frustum_work
Conflicts: voxel-server/CMakeLists.txt
This commit is contained in:
commit
1b52bb4e20
12 changed files with 277 additions and 96 deletions
|
@ -5,6 +5,7 @@ project(hifi)
|
|||
add_subdirectory(avatar-mixer)
|
||||
add_subdirectory(audio-mixer)
|
||||
add_subdirectory(domain-server)
|
||||
add_subdirectory(eve)
|
||||
add_subdirectory(interface)
|
||||
add_subdirectory(injector)
|
||||
add_subdirectory(space-server)
|
||||
|
|
20
eve/CMakeLists.txt
Normal file
20
eve/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(ROOT_DIR ..)
|
||||
set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME eve)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME})
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
# link the required hifi libraries
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR})
|
128
eve/src/main.cpp
Normal file
128
eve/src/main.cpp
Normal file
|
@ -0,0 +1,128 @@
|
|||
//
|
||||
// main.cpp
|
||||
// eve
|
||||
//
|
||||
// Created by Stephen Birarda on 4/22/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <AgentTypes.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <AgentList.h>
|
||||
#include <AvatarData.h>
|
||||
|
||||
const int EVE_AGENT_LIST_PORT = 55441;
|
||||
const float DATA_SEND_INTERVAL_MSECS = 10;
|
||||
|
||||
bool stopReceiveAgentDataThread;
|
||||
|
||||
void *receiveAgentData(void *args)
|
||||
{
|
||||
sockaddr senderAddress;
|
||||
ssize_t bytesReceived;
|
||||
unsigned char incomingPacket[MAX_PACKET_SIZE];
|
||||
|
||||
AgentList *agentList = AgentList::getInstance();
|
||||
Agent *avatarMixer = NULL;
|
||||
|
||||
while (!::stopReceiveAgentDataThread) {
|
||||
if (agentList->getAgentSocket().receive(&senderAddress, incomingPacket, &bytesReceived)) {
|
||||
switch (incomingPacket[0]) {
|
||||
case PACKET_HEADER_BULK_AVATAR_DATA:
|
||||
// this is the positional data for other agents
|
||||
// eve doesn't care about this for now, so let's just update the receive time for the
|
||||
// avatar mixer - this makes sure it won't be killed during silent agent removal
|
||||
avatarMixer = agentList->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER);
|
||||
|
||||
if (avatarMixer != NULL) {
|
||||
avatarMixer->setLastRecvTimeUsecs(usecTimestampNow());
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
// have the agentList handle list of agents from DS, replies from other agents, etc.
|
||||
agentList->processAgentData(&senderAddress, incomingPacket, bytesReceived);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pthread_exit(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// create an AgentList instance to handle communication with other agents
|
||||
AgentList *agentList = AgentList::createInstance(AGENT_TYPE_AVATAR, EVE_AGENT_LIST_PORT);
|
||||
|
||||
// start telling the domain server that we are alive
|
||||
agentList->startDomainServerCheckInThread();
|
||||
|
||||
// start the agent list thread that will kill off agents when they stop talking
|
||||
agentList->startSilentAgentRemovalThread();
|
||||
|
||||
// start the ping thread that hole punches to create an active connection to other agents
|
||||
agentList->startPingUnknownAgentsThread();
|
||||
|
||||
pthread_t receiveAgentDataThread;
|
||||
pthread_create(&receiveAgentDataThread, NULL, receiveAgentData, NULL);
|
||||
|
||||
// create an AvatarData object, "eve"
|
||||
AvatarData eve = AvatarData();
|
||||
|
||||
// move eve away from the origin
|
||||
eve.setBodyPosition(glm::vec3(3, 0, -3));
|
||||
|
||||
// turn her back towards the origin
|
||||
eve.setBodyYaw(-45);
|
||||
|
||||
// put her hand out so somebody can shake it
|
||||
eve.setHandPosition(glm::vec3(eve.getBodyPosition()[0] - 0.2,
|
||||
0.25,
|
||||
eve.getBodyPosition()[2] + 0.1));
|
||||
|
||||
unsigned char broadcastPacket[MAX_PACKET_SIZE];
|
||||
broadcastPacket[0] = PACKET_HEADER_HEAD_DATA;
|
||||
|
||||
int numBytesToSend = 0;
|
||||
|
||||
timeval thisSend;
|
||||
double numMicrosecondsSleep = 0;
|
||||
|
||||
while (true) {
|
||||
// update the thisSend timeval to the current time
|
||||
gettimeofday(&thisSend, NULL);
|
||||
|
||||
// find the current avatar mixer
|
||||
Agent *avatarMixer = agentList->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER);
|
||||
|
||||
// make sure we actually have an avatar mixer with an active socket
|
||||
if (avatarMixer != NULL && avatarMixer->getActiveSocket() != NULL) {
|
||||
// use the getBroadcastData method in the AvatarData class to populate the broadcastPacket buffer
|
||||
numBytesToSend = eve.getBroadcastData((broadcastPacket + 1));
|
||||
|
||||
|
||||
// use the UDPSocket instance attached to our agent list to send avatar data to mixer
|
||||
agentList->getAgentSocket().send(avatarMixer->getActiveSocket(), broadcastPacket, numBytesToSend);
|
||||
}
|
||||
|
||||
// sleep for the correct amount of time to have data send be consistently timed
|
||||
if ((numMicrosecondsSleep = (DATA_SEND_INTERVAL_MSECS * 1000) - (usecTimestampNow() - usecTimestamp(&thisSend))) > 0) {
|
||||
usleep(numMicrosecondsSleep);
|
||||
}
|
||||
}
|
||||
|
||||
// stop the receive agent data thread
|
||||
stopReceiveAgentDataThread = true;
|
||||
pthread_join(receiveAgentDataThread, NULL);
|
||||
|
||||
// stop the agent list's threads
|
||||
agentList->stopDomainServerCheckInThread();
|
||||
agentList->stopPingUnknownAgentsThread();
|
||||
agentList->stopSilentAgentRemovalThread();
|
||||
}
|
||||
|
||||
|
|
@ -8,7 +8,6 @@ project(${TARGET_NAME})
|
|||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
set(GLM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||
set(LODEPNG_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/LodePNG)
|
||||
set(PORTAUDIO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/portaudio)
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ unsigned int iris_texture_height = 256;
|
|||
|
||||
Head::Head(bool isMine) {
|
||||
|
||||
_orientation.setToIdentity();
|
||||
_orientation.setToIdentity();
|
||||
|
||||
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
|
@ -56,13 +57,14 @@ Head::Head(bool isMine) {
|
|||
_bodyPitch = 0.0;
|
||||
_bodyRoll = 0.0;
|
||||
_bodyYawDelta = 0.0;
|
||||
_triggeringAction = false;
|
||||
_mousePressed = false;
|
||||
_mode = AVATAR_MODE_STANDING;
|
||||
_isMine = isMine;
|
||||
_maxArmLength = 0.0;
|
||||
//_transmitterTimer = 0;
|
||||
_transmitterHz = 0.0;
|
||||
_transmitterPackets = 0;
|
||||
_numOtherAvatarsInView = 0;
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
|
@ -113,7 +115,8 @@ Head::Head(bool isMine) {
|
|||
_head.noise = 0;
|
||||
|
||||
_movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_usingBodySprings = false;
|
||||
_usingBodySprings = true;
|
||||
//_usingBodySprings = false;
|
||||
_springForce = 6.0f;
|
||||
_springVelocityDecay = 16.0f;
|
||||
_renderYaw = 0.0;
|
||||
|
@ -132,11 +135,11 @@ Head::Head(bool isMine) {
|
|||
//--------------------------------------------------
|
||||
// test... just slam them into random positions...
|
||||
//--------------------------------------------------
|
||||
_DEBUG_otherAvatarListPosition[ 0 ] = glm::vec3( 0.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 1 ] = glm::vec3( 4.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 2 ] = glm::vec3( 2.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 3 ] = glm::vec3( 1.0f, 0.3f, -4.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 4 ] = glm::vec3( -2.0f, 0.3f, -2.0f );
|
||||
_otherAvatarHandPosition[ 0 ] = glm::vec3( 0.0f, 0.3f, 2.0f );
|
||||
_otherAvatarHandPosition[ 1 ] = glm::vec3( 4.0f, 0.3f, 2.0f );
|
||||
_otherAvatarHandPosition[ 2 ] = glm::vec3( 2.0f, 0.3f, 2.0f );
|
||||
_otherAvatarHandPosition[ 3 ] = glm::vec3( 1.0f, 0.3f, -4.0f );
|
||||
_otherAvatarHandPosition[ 4 ] = glm::vec3( -2.0f, 0.3f, -2.0f );
|
||||
}
|
||||
|
||||
Head::Head(const Head &otherAvatar) {
|
||||
|
@ -149,7 +152,7 @@ Head::Head(const Head &otherAvatar) {
|
|||
_bodyPitch = otherAvatar._bodyPitch;
|
||||
_bodyRoll = otherAvatar._bodyRoll;
|
||||
_bodyYawDelta = otherAvatar._bodyYawDelta;
|
||||
_triggeringAction = otherAvatar._triggeringAction;
|
||||
_mousePressed = otherAvatar._mousePressed;
|
||||
_mode = otherAvatar._mode;
|
||||
_isMine = otherAvatar._isMine;
|
||||
_renderYaw = otherAvatar._renderYaw;
|
||||
|
@ -163,8 +166,7 @@ Head::Head(const Head &otherAvatar) {
|
|||
_movedHandOffset = otherAvatar._movedHandOffset;
|
||||
_usingBodySprings = otherAvatar._usingBodySprings;
|
||||
_springForce = otherAvatar._springForce;
|
||||
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
||||
|
||||
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
||||
_orientation.set( otherAvatar._orientation );
|
||||
|
||||
//for (int o=0;o<NUM_OTHER_AVATARS; o++) {
|
||||
|
@ -305,8 +307,8 @@ void Head::setLeanSideways(float dist){
|
|||
_head.leanSideways = dist;
|
||||
}
|
||||
|
||||
void Head::setTriggeringAction( bool d ) {
|
||||
_triggeringAction = d;
|
||||
void Head::setMousePressed( bool d ) {
|
||||
_mousePressed = d;
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,21 +327,38 @@ void Head::simulate(float deltaTime) {
|
|||
_closestOtherAvatar = -1;
|
||||
float closestDistance = 10000.0f;
|
||||
|
||||
/*
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
|
||||
_numOtherAvatarsInView =0;
|
||||
|
||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin();
|
||||
agent != agentList->getAgents().end();
|
||||
agent++) {
|
||||
if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_INTERFACE ) )) {
|
||||
if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) {
|
||||
Head *otherAvatar = (Head *)agent->getLinkedData();
|
||||
|
||||
// when this is working, I will grab the position here...
|
||||
//glm::vec3 otherAvatarPosition = otherAvatar->getBodyPosition();
|
||||
|
||||
if ( _numOtherAvatarsInView < MAX_OTHER_AVATARS ) {
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// test other avatar hand position for proximity...
|
||||
//-----------------------------------------------------------
|
||||
_otherAvatarHandPosition[ _numOtherAvatarsInView ] = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
||||
v -= _otherAvatarHandPosition[ _numOtherAvatarsInView ];
|
||||
|
||||
float distance = glm::length( v );
|
||||
if ( distance < _maxArmLength ) {
|
||||
if ( distance < closestDistance ) {
|
||||
closestDistance = distance;
|
||||
_closestOtherAvatar = _numOtherAvatarsInView;
|
||||
_numOtherAvatarsInView++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
///for testing only (prior to having real avs working)
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
|
||||
//-------------------------------------
|
||||
|
@ -357,16 +376,17 @@ void Head::simulate(float deltaTime) {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ( usingBigSphereCollisionTest ) {
|
||||
//--------------------------------------------------------------
|
||||
// test for avatar collision response (using a big sphere :)
|
||||
//--------------------------------------------------------------
|
||||
updateBigSphereCollisionTest(deltaTime);
|
||||
}
|
||||
|
||||
}//if ( _isMine )
|
||||
|
||||
|
||||
if ( usingBigSphereCollisionTest ) {
|
||||
//--------------------------------------------------------------
|
||||
// test for avatar collision response (using a big sphere :)
|
||||
//--------------------------------------------------------------
|
||||
updateBigSphereCollisionTest(deltaTime);
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// update avatar skeleton
|
||||
//------------------------
|
||||
|
@ -385,7 +405,7 @@ void Head::simulate(float deltaTime) {
|
|||
// this handles the avatar being driven around...
|
||||
//-------------------------------------------------
|
||||
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
|
||||
|
||||
if (_driveKeys[FWD]) {
|
||||
glm::vec3 front( _orientation.getFront().x, _orientation.getFront().y, _orientation.getFront().z );
|
||||
_thrust += front * THRUST_MAG;
|
||||
|
@ -592,13 +612,6 @@ void Head::updateBigSphereCollisionTest( float deltaTime ) {
|
|||
_usingBodySprings = true;
|
||||
initializeBodySprings();
|
||||
}
|
||||
/*
|
||||
else {
|
||||
if (_usingSprings) {
|
||||
_usingSprings = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------
|
||||
// add gravity to velocity
|
||||
|
@ -669,9 +682,9 @@ void Head::render(int faceToFace) {
|
|||
//---------------------------------------------------
|
||||
// render other avatars (DEBUG TEST)
|
||||
//---------------------------------------------------
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
|
||||
for (int o=0; o<_numOtherAvatarsInView; o++) {
|
||||
glPushMatrix();
|
||||
glTranslatef( _DEBUG_otherAvatarListPosition[o].x, _DEBUG_otherAvatarListPosition[o].y, _DEBUG_otherAvatarListPosition[o].z );
|
||||
glTranslatef( _otherAvatarHandPosition[o].x, _otherAvatarHandPosition[o].y, _otherAvatarHandPosition[o].z );
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
|
@ -681,10 +694,10 @@ void Head::render(int faceToFace) {
|
|||
if ( _closestOtherAvatar != -1 ) {
|
||||
|
||||
glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
glm::vec3 v2( _DEBUG_otherAvatarListPosition[ _closestOtherAvatar ] );
|
||||
glm::vec3 v2( _otherAvatarHandPosition[ _closestOtherAvatar ] );
|
||||
|
||||
glLineWidth( 5.0 );
|
||||
glColor4f( 0.9f, 0.5f, 0.2f, 0.6 );
|
||||
glLineWidth( 8.0 );
|
||||
glColor4f( 0.7f, 0.4f, 0.1f, 0.6 );
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3f( v1.x, v1.y, v1.z );
|
||||
glVertex3f( v2.x, v2.y, v2.z );
|
||||
|
@ -871,7 +884,7 @@ void Head::startHandMovement() {
|
|||
}
|
||||
|
||||
void Head::stopHandMovement() {
|
||||
_usingBodySprings = false;
|
||||
//_usingBodySprings = false;
|
||||
}
|
||||
|
||||
void Head::setHandMovementValues( glm::vec3 handOffset ) {
|
||||
|
@ -1005,19 +1018,13 @@ void Head::updateSkeleton() {
|
|||
//----------------------------------
|
||||
_orientation.setToIdentity();
|
||||
_orientation.yaw( _bodyYaw );
|
||||
|
||||
//test! - make sure this does what expected: st rotation to be identity PLUS _bodyYaw
|
||||
//_rotation = glm::angleAxis( _bodyYaw, _orientation.up );
|
||||
|
||||
//glm::quat yaw_rotation = glm::angleAxis( _bodyYaw, _orientation.up );
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// calculate positions of all bones by traversing the skeleton tree:
|
||||
//------------------------------------------------------------------------
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
||||
_bone[b].orientation.set( _orientation );
|
||||
_bone[b].orientation.set( _orientation );
|
||||
_bone[b].position = _bodyPosition;
|
||||
}
|
||||
else {
|
||||
|
@ -1070,7 +1077,7 @@ void Head::updateBodySprings( float deltaTime ) {
|
|||
|
||||
float force = ( length - _bone[b].length ) * _springForce * deltaTime;
|
||||
|
||||
_bone[ b ].springyVelocity -= springDirection * force;
|
||||
_bone[b].springyVelocity -= springDirection * force;
|
||||
|
||||
if ( _bone[b].parent != AVATAR_BONE_NULL ) {
|
||||
_bone[ _bone[b].parent ].springyVelocity += springDirection * force;
|
||||
|
@ -1095,27 +1102,27 @@ void Head::updateBodySprings( float deltaTime ) {
|
|||
glm::vec3 Head::getHeadLookatDirection() {
|
||||
return glm::vec3
|
||||
(
|
||||
_orientation.getFront().x,
|
||||
_orientation.getFront().y,
|
||||
_orientation.getFront().z
|
||||
_orientation.getFront().x,
|
||||
_orientation.getFront().y,
|
||||
_orientation.getFront().z
|
||||
);
|
||||
}
|
||||
|
||||
glm::vec3 Head::getHeadLookatDirectionUp() {
|
||||
return glm::vec3
|
||||
(
|
||||
_orientation.getUp().x,
|
||||
_orientation.getUp().y,
|
||||
_orientation.getUp().z
|
||||
_orientation.getUp().x,
|
||||
_orientation.getUp().y,
|
||||
_orientation.getUp().z
|
||||
);
|
||||
}
|
||||
|
||||
glm::vec3 Head::getHeadLookatDirectionRight() {
|
||||
return glm::vec3
|
||||
(
|
||||
_orientation.getRight().x,
|
||||
_orientation.getRight().y,
|
||||
_orientation.getRight().z
|
||||
_orientation.getRight().x,
|
||||
_orientation.getRight().y,
|
||||
_orientation.getRight().z
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1129,21 +1136,26 @@ glm::vec3 Head::getHeadPosition() {
|
|||
}
|
||||
|
||||
|
||||
glm::vec3 Head::getBonePosition( AvatarBones b ) {
|
||||
return _bone[b].position;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Head::updateHandMovement() {
|
||||
glm::vec3 transformedHandMovement;
|
||||
|
||||
|
||||
transformedHandMovement
|
||||
= _orientation.getRight() * _movedHandOffset.x
|
||||
+ _orientation.getUp() * -_movedHandOffset.y * 0.5f
|
||||
+ _orientation.getUp() * -_movedHandOffset.y * 0.5f
|
||||
+ _orientation.getFront() * -_movedHandOffset.y;
|
||||
|
||||
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position += transformedHandMovement;
|
||||
|
||||
//if holding hands, add a pull to the hand...
|
||||
if ( _usingBodySprings ) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
if ( _triggeringAction ) {
|
||||
if ( _mousePressed ) {
|
||||
|
||||
/*
|
||||
glm::vec3 handShakePull( DEBUG_otherAvatarListPosition[ closestOtherAvatar ]);
|
||||
|
@ -1154,7 +1166,7 @@ void Head::updateHandMovement() {
|
|||
transformedHandMovement += handShakePull;
|
||||
*/
|
||||
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _DEBUG_otherAvatarListPosition[ _closestOtherAvatar ];
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _otherAvatarHandPosition[ _closestOtherAvatar ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1207,6 +1219,7 @@ void Head::updateHandMovement() {
|
|||
//-----------------------------------------------------------------------------
|
||||
glm::vec3 newElbowPosition = _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position;
|
||||
newElbowPosition += armVector * ONE_HALF;
|
||||
//glm::vec3 perpendicular = glm::cross( frontDirection, armVector );
|
||||
glm::vec3 perpendicular = glm::cross( _orientation.getFront(), armVector );
|
||||
|
||||
newElbowPosition += perpendicular * ( 1.0f - ( _maxArmLength / distance ) ) * ONE_HALF;
|
||||
|
@ -1233,6 +1246,18 @@ void Head::renderBody() {
|
|||
// Render bone positions as spheres
|
||||
//-----------------------------------------
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
|
||||
/*
|
||||
if ( _isMine )
|
||||
{
|
||||
printf( "my avatar: %d\n", _usingBodySprings );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "other avatar: %d\n", _usingBodySprings );
|
||||
}
|
||||
*/
|
||||
|
||||
if ( _usingBodySprings ) {
|
||||
glColor3fv( lightBlue );
|
||||
glPushMatrix();
|
||||
|
@ -1280,7 +1305,7 @@ void Head::renderBody() {
|
|||
}
|
||||
|
||||
|
||||
if (( _usingBodySprings ) && ( _triggeringAction )) {
|
||||
if (( _usingBodySprings ) && ( _mousePressed )) {
|
||||
glColor4f( 1.0, 1.0, 0.5, 0.5 );
|
||||
glPushMatrix();
|
||||
glTranslatef
|
||||
|
|
|
@ -34,7 +34,7 @@ enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
|||
#define ROT_RIGHT 7
|
||||
#define MAX_DRIVE_KEYS 8
|
||||
|
||||
#define NUM_OTHER_AVATARS 5 // temporary - for testing purposes!
|
||||
#define MAX_OTHER_AVATARS 50 // temporary - for testing purposes!
|
||||
|
||||
enum AvatarMode
|
||||
{
|
||||
|
@ -172,7 +172,7 @@ class Head : public AvatarData {
|
|||
|
||||
AvatarMode getMode();
|
||||
|
||||
void setTriggeringAction( bool trigger );
|
||||
void setMousePressed( bool pressed );
|
||||
|
||||
void render(int faceToFace);
|
||||
|
||||
|
@ -214,27 +214,30 @@ class Head : public AvatarData {
|
|||
bool _isMine;
|
||||
glm::vec3 _TEST_bigSpherePosition;
|
||||
float _TEST_bigSphereRadius;
|
||||
glm::vec3 _DEBUG_otherAvatarListPosition[ NUM_OTHER_AVATARS ];
|
||||
bool _triggeringAction;
|
||||
glm::vec3 _otherAvatarHandPosition[ MAX_OTHER_AVATARS ];
|
||||
bool _mousePressed;
|
||||
float _bodyYawDelta;
|
||||
float _closeEnoughToInteract;
|
||||
//float _closeEnoughToInteract;
|
||||
int _closestOtherAvatar;
|
||||
bool _usingBodySprings;
|
||||
glm::vec3 _movedHandOffset;
|
||||
float _springVelocityDecay;
|
||||
float _springForce;
|
||||
glm::quat _rotation; // the rotation of the avatar body as a whole
|
||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
||||
AvatarMode _mode;
|
||||
glm::dvec3 _velocity;
|
||||
glm::vec3 _thrust;
|
||||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
int _numOtherAvatarsInView;
|
||||
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
GLUquadric* _sphere;
|
||||
float _renderYaw;
|
||||
float _renderPitch; // Pitch from view frustum when this is own head.
|
||||
|
||||
|
||||
//
|
||||
// Related to getting transmitter UDP data used to animate the avatar hand
|
||||
//
|
||||
|
|
|
@ -209,7 +209,6 @@ void initializeHandController() {
|
|||
handController.rampUpRate = 0.05;
|
||||
handController.rampDownRate = 0.02;
|
||||
handController.envelope = 0.0f;
|
||||
|
||||
}
|
||||
|
||||
void updateHandController( int x, int y ) {
|
||||
|
@ -239,7 +238,8 @@ void updateHandController( int x, int y ) {
|
|||
handController.startX = WIDTH / 2;
|
||||
handController.startY = HEIGHT / 2;
|
||||
handController.envelope = 0.0;
|
||||
myAvatar.stopHandMovement();
|
||||
//prototype
|
||||
//myAvatar.stopHandMovement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -935,6 +935,9 @@ void display(void)
|
|||
if (agent->getLinkedData() != NULL) {
|
||||
Head *avatar = (Head *)agent->getLinkedData();
|
||||
//glPushMatrix();
|
||||
|
||||
//printf( "rendering remote avatar\n" );
|
||||
|
||||
avatar->render(0);
|
||||
//glPopMatrix();
|
||||
}
|
||||
|
@ -1000,11 +1003,18 @@ void display(void)
|
|||
menu.render(WIDTH,HEIGHT);
|
||||
}
|
||||
|
||||
// Draw number of nearby people always
|
||||
// Stats at upper right of screen about who domain server is telling us about
|
||||
glPointSize(1.0f);
|
||||
char agents[100];
|
||||
sprintf(agents, "Agents: %ld\n", AgentList::getInstance()->getAgents().size());
|
||||
drawtext(WIDTH-100,20, 0.10, 0, 1.0, 0, agents, 1, 0, 0);
|
||||
|
||||
int totalAgents = AgentList::getInstance()->getAgents().size();
|
||||
int totalAvatars = 0, totalServers = 0;
|
||||
for (int i = 0; i < totalAgents; i++) {
|
||||
(AgentList::getInstance()->getAgents()[i].getType() == AGENT_TYPE_AVATAR)
|
||||
? totalAvatars++ : totalServers++;
|
||||
}
|
||||
sprintf(agents, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars);
|
||||
drawtext(WIDTH-150,20, 0.10, 0, 1.0, 0, agents, 1, 0, 0);
|
||||
|
||||
if (::paintOn) {
|
||||
|
||||
|
@ -1407,7 +1417,6 @@ void key(unsigned char k, int x, int y)
|
|||
{
|
||||
myAvatar.setNoise(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (k == 'h') {
|
||||
|
@ -1484,13 +1493,12 @@ void idle(void) {
|
|||
// update behaviors for avatar hand movement
|
||||
updateHandController( mouseX, mouseY );
|
||||
|
||||
// when the mouse is being pressed, an 'action' is being
|
||||
// triggered in the avatar. The action is context-based.
|
||||
// tell my avatar if the mouse is being pressed...
|
||||
if ( mousePressed == 1 ) {
|
||||
myAvatar.setTriggeringAction( true );
|
||||
myAvatar.setMousePressed( true );
|
||||
}
|
||||
else {
|
||||
myAvatar.setTriggeringAction( false );
|
||||
myAvatar.setMousePressed( false );
|
||||
}
|
||||
|
||||
// walking triggers the handController to stop
|
||||
|
@ -1503,7 +1511,6 @@ void idle(void) {
|
|||
//
|
||||
updateAvatar( 1.f/FPS );
|
||||
|
||||
|
||||
//loop through all the other avatars and simulate them.
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); agent++)
|
||||
|
@ -1511,11 +1518,13 @@ void idle(void) {
|
|||
if (agent->getLinkedData() != NULL)
|
||||
{
|
||||
Head *avatar = (Head *)agent->getLinkedData();
|
||||
|
||||
//printf( "simulating remote avatar\n" );
|
||||
|
||||
avatar->simulate(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//updateAvatarHand(1.f/FPS);
|
||||
|
||||
field.simulate (deltaTime);
|
||||
|
@ -1623,8 +1632,6 @@ void mouseoverFunc( int x, int y)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
void attachNewHeadToAgent(Agent *newAgent) {
|
||||
if (newAgent->getLinkedData() == NULL) {
|
||||
newAgent->setLinkedData(new Head(false));
|
||||
|
@ -1649,7 +1656,7 @@ int main(int argc, const char * argv[])
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
AgentList::createInstance(AGENT_TYPE_INTERFACE);
|
||||
AgentList::createInstance(AGENT_TYPE_AVATAR);
|
||||
|
||||
gettimeofday(&applicationStartupTime, NULL);
|
||||
const char* domainIP = getCmdOption(argc, argv, "--domain");
|
||||
|
|
|
@ -132,7 +132,7 @@ const char* Agent::getTypeName() const {
|
|||
case AGENT_TYPE_VOXEL:
|
||||
name = AGENT_TYPE_NAME_VOXEL;
|
||||
break;
|
||||
case AGENT_TYPE_INTERFACE:
|
||||
case AGENT_TYPE_AVATAR:
|
||||
name = AGENT_TYPE_NAME_INTERFACE;
|
||||
break;
|
||||
case AGENT_TYPE_AUDIO_MIXER:
|
||||
|
|
|
@ -228,7 +228,6 @@ bool AgentList::addOrUpdateAgent(sockaddr *publicSocket, sockaddr *localSocket,
|
|||
|
||||
if (agent == agents.end()) {
|
||||
// we didn't have this agent, so add them
|
||||
|
||||
Agent newAgent = Agent(publicSocket, localSocket, agentType, agentId);
|
||||
|
||||
if (socketMatch(publicSocket, localSocket)) {
|
||||
|
@ -281,7 +280,7 @@ void AgentList::broadcastToAgents(unsigned char *broadcastData, size_t dataBytes
|
|||
void AgentList::handlePingReply(sockaddr *agentAddress) {
|
||||
for(std::vector<Agent>::iterator agent = agents.begin(); agent != agents.end(); agent++) {
|
||||
// check both the public and local addresses for each agent to see if we find a match
|
||||
// prioritize the private address so that we prune erroneous local matches
|
||||
// prioritize the private address so that we prune erroneous local matches
|
||||
if (socketMatch(agent->getPublicSocket(), agentAddress)) {
|
||||
agent->activatePublicSocket();
|
||||
break;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// Agent Type Codes
|
||||
const char AGENT_TYPE_DOMAIN = 'D';
|
||||
const char AGENT_TYPE_VOXEL = 'V';
|
||||
const char AGENT_TYPE_INTERFACE = 'I'; // could also be injector???
|
||||
const char AGENT_TYPE_AVATAR = 'I'; // could also be injector???
|
||||
const char AGENT_TYPE_AUDIO_MIXER = 'M';
|
||||
const char AGENT_TYPE_AVATAR_MIXER = 'W';
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
|||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
set(GLM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||
|
||||
# set up the external glm library
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
|
|
|
@ -373,7 +373,7 @@ int main(int argc, const char * argv[])
|
|||
|
||||
// Now send this to the connected agents so they know to delete
|
||||
printf("rebroadcasting delete voxel message to connected agents... agentList.broadcastToAgents()\n");
|
||||
agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_INTERFACE, 1);
|
||||
agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_AVATAR, 1);
|
||||
|
||||
}
|
||||
if (packetData[0] == PACKET_HEADER_Z_COMMAND) {
|
||||
|
@ -401,14 +401,14 @@ int main(int argc, const char * argv[])
|
|||
|
||||
// Now send this to the connected agents so they can also process these messages
|
||||
printf("rebroadcasting Z message to connected agents... agentList.broadcastToAgents()\n");
|
||||
agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_INTERFACE, 1);
|
||||
agentList->broadcastToAgents(packetData,receivedBytes, &AGENT_TYPE_AVATAR, 1);
|
||||
}
|
||||
// If we got a PACKET_HEADER_HEAD_DATA, then we're talking to an AGENT_TYPE_INTERFACE, and we
|
||||
// If we got a PACKET_HEADER_HEAD_DATA, then we're talking to an AGENT_TYPE_AVATAR, and we
|
||||
// need to make sure we have it in our agentList.
|
||||
if (packetData[0] == PACKET_HEADER_HEAD_DATA) {
|
||||
if (agentList->addOrUpdateAgent(&agentPublicAddress,
|
||||
&agentPublicAddress,
|
||||
AGENT_TYPE_INTERFACE,
|
||||
AGENT_TYPE_AVATAR,
|
||||
agentList->getLastAgentId())) {
|
||||
agentList->increaseAgentId();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue