From 2b7095925d5932efb8edfd7fe7da96ee84cb4d18 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 23 Apr 2013 15:45:29 -0700 Subject: [PATCH 1/2] add randomization of eve's position, face eve down z-axis --- eve/src/main.cpp | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/eve/src/main.cpp b/eve/src/main.cpp index 5a16556e06..ed4ec36e98 100644 --- a/eve/src/main.cpp +++ b/eve/src/main.cpp @@ -15,8 +15,9 @@ #include #include -const int EVE_AGENT_LIST_PORT = 55441; -const float DATA_SEND_INTERVAL_MSECS = 10; +const float RANDOM_POSITION_MAX_DIMENSION = 5.0f; + +const float DATA_SEND_INTERVAL_MSECS = 15; const float MIN_AUDIO_SEND_INTERVAL_SECS = 10; const int MIN_ITERATIONS_BETWEEN_AUDIO_SENDS = (MIN_AUDIO_SEND_INTERVAL_SECS * 1000) / DATA_SEND_INTERVAL_MSECS; const int MAX_AUDIO_SEND_INTERVAL_SECS = 15; @@ -26,7 +27,7 @@ bool stopReceiveAgentDataThread; bool injectAudioThreadRunning = false; int TEMP_AUDIO_LISTEN_PORT = 55439; -UDPSocket audioSocket(TEMP_AUDIO_LISTEN_PORT); +// UDPSocket audioSocket(TEMP_AUDIO_LISTEN_PORT); void *receiveAgentData(void *args) { sockaddr senderAddress; @@ -77,7 +78,7 @@ void *injectAudio(void *args) { } // we have an active audio mixer we can send data to - eveAudioInjector->injectAudio(&::audioSocket, audioMixer->getActiveSocket()); +// eveAudioInjector->injectAudio(&::audioSocket, audioMixer->getActiveSocket()); } ::injectAudioThreadRunning = false; @@ -90,7 +91,7 @@ int main(int argc, const char* argv[]) { srand(time(0)); // create an AgentList instance to handle communication with other agents - AgentList* agentList = AgentList::createInstance(AGENT_TYPE_AVATAR, EVE_AGENT_LIST_PORT); + AgentList* agentList = AgentList::createInstance(AGENT_TYPE_AVATAR, 55441); // start telling the domain server that we are alive agentList->startDomainServerCheckInThread(); @@ -108,10 +109,14 @@ int main(int argc, const char* argv[]) { AvatarData eve = AvatarData(); // move eve away from the origin - eve.setBodyPosition(glm::vec3(3, 0, -3)); + // pick a random point inside a 10x10 grid - // turn her back towards the origin - eve.setBodyYaw(-45); + eve.setBodyPosition(glm::vec3(randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION), + 0, + randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION))); + + // face any instance of eve down the z-axis + eve.setBodyYaw(0); // put her hand out so somebody can shake it eve.setHandPosition(glm::vec3(eve.getBodyPosition()[0] - 0.2, @@ -129,8 +134,8 @@ int main(int argc, const char* argv[]) { timeval thisSend; double numMicrosecondsSleep = 0; - int numIterationsLeftBeforeAudioSend = 0; - pthread_t injectAudioThread; +// int numIterationsLeftBeforeAudioSend = 0; +// pthread_t injectAudioThread; while (true) { // update the thisSend timeval to the current time @@ -147,17 +152,18 @@ int main(int argc, const char* argv[]) { // use the UDPSocket instance attached to our agent list to send avatar data to mixer agentList->getAgentSocket().send(avatarMixer->getActiveSocket(), broadcastPacket, numBytesToSend); } - - if (numIterationsLeftBeforeAudioSend == 0) { - if (!::injectAudioThreadRunning) { - pthread_create(&injectAudioThread, NULL, injectAudio, (void*) &eveAudioInjector); - - numIterationsLeftBeforeAudioSend = randIntInRange(MIN_ITERATIONS_BETWEEN_AUDIO_SENDS, - MAX_ITERATIONS_BETWEEN_AUDIO_SENDS); - } - } else { - numIterationsLeftBeforeAudioSend--; - } + + // temporarily disable Eve's audio sending until the file is actually available on EC2 box +// if (numIterationsLeftBeforeAudioSend == 0) { +// if (!::injectAudioThreadRunning) { +// pthread_create(&injectAudioThread, NULL, injectAudio, (void*) &eveAudioInjector); +// +// numIterationsLeftBeforeAudioSend = randIntInRange(MIN_ITERATIONS_BETWEEN_AUDIO_SENDS, +// MAX_ITERATIONS_BETWEEN_AUDIO_SENDS); +// } +// } else { +// numIterationsLeftBeforeAudioSend--; +// } // 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) { From a4244da27efded4db93731827214555afc88cb28 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 23 Apr 2013 15:46:57 -0700 Subject: [PATCH 2/2] add randomization of eve's listening port on launch --- eve/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eve/src/main.cpp b/eve/src/main.cpp index ed4ec36e98..d1a82b860d 100644 --- a/eve/src/main.cpp +++ b/eve/src/main.cpp @@ -91,7 +91,7 @@ int main(int argc, const char* argv[]) { srand(time(0)); // create an AgentList instance to handle communication with other agents - AgentList* agentList = AgentList::createInstance(AGENT_TYPE_AVATAR, 55441); + AgentList* agentList = AgentList::createInstance(AGENT_TYPE_AVATAR, randIntInRange(1500, 65000)); // start telling the domain server that we are alive agentList->startDomainServerCheckInThread();