From 24ec0b0ddc9a11b510d38399509fadb86d29e792 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 6 Aug 2013 19:15:05 -0700 Subject: [PATCH 1/4] fixed packet header bug in createVoxelEditMessage() --- libraries/shared/src/SharedUtil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 93ea8a70ed..cf2374b84e 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -215,7 +215,6 @@ bool createVoxelEditMessage(unsigned char command, short int sequence, bool success = true; // assume the best int messageSize = MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE; // just a guess for now - int actualMessageSize = 3; unsigned char* messageBuffer = new unsigned char[messageSize]; int numBytesPacketHeader = populateTypeAndVersion(messageBuffer, command); @@ -223,6 +222,7 @@ bool createVoxelEditMessage(unsigned char command, short int sequence, *sequenceAt = sequence; unsigned char* copyAt = &messageBuffer[numBytesPacketHeader + sizeof(sequence)]; + int actualMessageSize = numBytesPacketHeader + sizeof(sequence); for (int i = 0; i < voxelCount && success; i++) { // get the coded voxel @@ -232,7 +232,7 @@ bool createVoxelEditMessage(unsigned char command, short int sequence, int lengthOfVoxelData = bytesRequiredForCodeLength(*voxelData)+SIZE_OF_COLOR_DATA; // make sure we have room to copy this voxel - if (actualMessageSize+lengthOfVoxelData > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) { + if (actualMessageSize + lengthOfVoxelData > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) { success = false; } else { // add it to our message From a5f472254d7758c3e342ae073ec94bad5ee0a989 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 6 Aug 2013 19:15:26 -0700 Subject: [PATCH 2/4] removed ground plane grid, and changed start position --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 359975339d..821a21d604 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -77,7 +77,7 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt"; static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored -const glm::vec3 START_LOCATION(4.f, 0.f, 5.f); // Where one's own node begins in the world +const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE); // Where one's own node begins in the world // (will be overwritten if avatar data file is found) const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff @@ -3045,7 +3045,7 @@ void Application::displaySide(Camera& whichCamera) { glDisable(GL_FOG); glDisable(GL_NORMALIZE); - renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude()); + //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude()); } // Draw voxels if (_renderVoxels->isChecked()) { From ac693c703afa41cf578abae80fe542dff4497f07 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 6 Aug 2013 19:19:04 -0700 Subject: [PATCH 3/4] added --domain option and --BuildStreet option --- animation-server/src/main.cpp | 77 +++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp index 4d0577b960..47cf94ff2e 100644 --- a/animation-server/src/main.cpp +++ b/animation-server/src/main.cpp @@ -31,11 +31,12 @@ #endif bool shouldShowPacketsPerSecond = false; // do we want to debug packets per second -bool includeBillboard = true; -bool includeBorderTracer = true; -bool includeMovingBug = true; +bool includeBillboard = false; +bool includeBorderTracer = false; +bool includeMovingBug = false; bool includeBlinkingVoxel = false; -bool includeDanceFloor = true; +bool includeDanceFloor = false; +bool buildStreet = false; const int ANIMATION_LISTEN_PORT = 40107; @@ -616,6 +617,62 @@ static void sendBillboard() { } } +bool roadInitialized = false; +const int ROAD_WIDTH_METERS = 3.0f; +const int BRICKS_ACROSS_ROAD = 32; +const float ROAD_BRICK_SIZE = 0.125f/TREE_SCALE; //(ROAD_WIDTH_METERS / TREE_SCALE) / BRICKS_ACROSS_ROAD; // in voxel units +const int ROAD_LENGTH = 1.0f / ROAD_BRICK_SIZE; // in bricks +const int ROAD_WIDTH = BRICKS_ACROSS_ROAD; // in bricks +glm::vec3 roadPosition(0.5f - (ROAD_BRICK_SIZE * BRICKS_ACROSS_ROAD), 0.0f, 0.0f); +//glm::vec3 roadPosition(0.0f, 0.0f, 0.0f); +const int BRICKS_PER_PACKET = 32; // guessing +const int PACKETS_PER_ROAD = VOXELS_PER_PACKET / (ROAD_LENGTH * ROAD_WIDTH); + +void doBuildStreet() { + if (roadInitialized) { + return; + } + + PACKET_TYPE message = PACKET_TYPE_SET_VOXEL_DESTRUCTIVE; // we're a bully! + static VoxelDetail details[BRICKS_PER_PACKET]; + unsigned char* bufferOut; + int sizeOut; + + for (int z = 0; z < ROAD_LENGTH; z++) { + for (int x = 0; x < ROAD_WIDTH; x++) { + + int nthVoxel = ((z * ROAD_WIDTH) + x); + int item = nthVoxel % BRICKS_PER_PACKET; + + glm::vec3 brick = roadPosition + glm::vec3(x * ROAD_BRICK_SIZE, 0, z * ROAD_BRICK_SIZE); + + details[item].s = ROAD_BRICK_SIZE; + details[item].x = brick.x; + details[item].y = brick.y; + details[item].z = brick.z; + + unsigned char randomTone = randIntInRange(118,138); + details[item].red = randomTone; + details[item].green = randomTone; + details[item].blue = randomTone; + + if (item == BRICKS_PER_PACKET - 1) { + if (createVoxelEditMessage(message, 0, BRICKS_PER_PACKET, (VoxelDetail*)&details, bufferOut, sizeOut)){ + ::packetsSent++; + ::bytesSent += sizeOut; + if (true || ::shouldShowPacketsPerSecond) { + printf("building road sending packet of size=%d\n", sizeOut); + } + NodeList::getInstance()->broadcastToNodes(bufferOut, sizeOut, &NODE_TYPE_VOXEL_SERVER, 1); + delete[] bufferOut; + } + } + } + } + roadInitialized = true; +} + + double start = 0; @@ -645,6 +702,10 @@ void* animateVoxels(void* args) { sendDanceFloor(); } + if (::buildStreet) { + doBuildStreet(); + } + uint64_t end = usecTimestampNow(); uint64_t elapsedSeconds = (end - ::start) / 1000000; if (::shouldShowPacketsPerSecond) { @@ -688,6 +749,9 @@ int main(int argc, const char * argv[]) const char* NO_DANCE_FLOOR = "--NoDanceFloor"; ::includeDanceFloor = !cmdOptionExists(argc, argv, NO_DANCE_FLOOR); + const char* BUILD_STREET = "--BuildStreet"; + ::buildStreet = cmdOptionExists(argc, argv, BUILD_STREET); + // Handle Local Domain testing with the --local command line const char* showPPS = "--showPPS"; ::shouldShowPacketsPerSecond = cmdOptionExists(argc, argv, showPPS); @@ -700,6 +764,11 @@ int main(int argc, const char * argv[]) nodeList->setDomainIPToLocalhost(); } + const char* domainIP = getCmdOption(argc, argv, "--domain"); + if (domainIP) { + NodeList::getInstance()->setDomainIP(domainIP); + } + nodeList->linkedDataCreateCallback = NULL; // do we need a callback? nodeList->startSilentNodeRemovalThread(); From 61560af28f6da61b316577456924980ee0653c4b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 6 Aug 2013 19:21:46 -0700 Subject: [PATCH 4/4] cleanup --- animation-server/src/main.cpp | 9 ++++----- interface/src/Application.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp index 47cf94ff2e..dec8f2ea5d 100644 --- a/animation-server/src/main.cpp +++ b/animation-server/src/main.cpp @@ -31,11 +31,11 @@ #endif bool shouldShowPacketsPerSecond = false; // do we want to debug packets per second -bool includeBillboard = false; -bool includeBorderTracer = false; -bool includeMovingBug = false; +bool includeBillboard = true; +bool includeBorderTracer = true; +bool includeMovingBug = true; bool includeBlinkingVoxel = false; -bool includeDanceFloor = false; +bool includeDanceFloor = true; bool buildStreet = false; @@ -624,7 +624,6 @@ const float ROAD_BRICK_SIZE = 0.125f/TREE_SCALE; //(ROAD_WIDTH_METERS / TREE_SCA const int ROAD_LENGTH = 1.0f / ROAD_BRICK_SIZE; // in bricks const int ROAD_WIDTH = BRICKS_ACROSS_ROAD; // in bricks glm::vec3 roadPosition(0.5f - (ROAD_BRICK_SIZE * BRICKS_ACROSS_ROAD), 0.0f, 0.0f); -//glm::vec3 roadPosition(0.0f, 0.0f, 0.0f); const int BRICKS_PER_PACKET = 32; // guessing const int PACKETS_PER_ROAD = VOXELS_PER_PACKET / (ROAD_LENGTH * ROAD_WIDTH); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 821a21d604..19b889a918 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -77,8 +77,10 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt"; static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored -const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE); // Where one's own node begins in the world - // (will be overwritten if avatar data file is found) +// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found) +// this is basically in the center of the ground plane. Slightly adjusted. This was asked for by +// Grayson as he's building a street around here for demo dinner 2 +const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE); const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff // in the idle loop? (60 FPS is default)