From 28a41132a42efb81a72efacde76470d061894e2c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Apr 2013 12:12:52 -0700 Subject: [PATCH 01/13] latest work on render_view_frustum --- interface/src/main.cpp | 100 ++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 37 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 00cd8d7bfc..13d20b7716 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -154,6 +154,7 @@ bool paintOn = false; // Whether to paint voxels as you fly around VoxelDetail paintingVoxel; // The voxel we're painting if we're painting unsigned char dominantColor = 0; // The dominant color of the voxel we're painting bool perfStatsOn = false; // Do we want to display perfStats? +bool frustumOn = false; // Whether or not to display the debug view frustum int noiseOn = 0; // Whether to add random noise float noise = 1.0; // Overall magnitude scaling for random noise levels @@ -530,7 +531,29 @@ void render_view_frustum() { // farWidth – the width of the far plane glm::vec3 cameraPosition = ::myHead.getPos()*-1.0; // We need to flip the sign to make this work. - glm::vec3 cameraDirection = ::myHead.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct! + //glm::vec3 cameraDirection = ::myHead.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct! + + float yaw = myHead.getYaw(); + float rightOfYaw = yaw-90.0; + //float pitch = myHead.getPitch(); + //float roll = myHead.getRoll(); + + //printf("yaw=%f, right of yaw=%f, pitch=%f, roll=%f\n",yaw,rightOfYaw,pitch,roll); + + // Currently we don't utilize pitch and yaw. Mainly because UI doesn't handle it. + float directionX = sin(yaw*PI_OVER_180); + float directionY = 0.0; + float directionZ = cos(yaw*PI_OVER_180); + + //printf("directionX=%f, directionY=%f, directionZ=%f\n",directionX,directionY,directionZ); + + float directionRightX = sin(rightOfYaw*PI_OVER_180); + float directionRightY = 0.0; + float directionRightZ = cos(rightOfYaw*PI_OVER_180); + + //printf("directionRightX=%f, directionRightY=%f, directionRightZ=%f\n",directionRightX,directionRightY,directionRightZ); + + glm::vec3 cameraDirection = glm::vec3(directionX,directionY,directionZ); // this is a temporary test, create a vertice that's 2 meters in front of avatar in direction their looking glm::vec3 lookingAt = cameraPosition+(cameraDirection*2.0); @@ -546,17 +569,16 @@ void render_view_frustum() { glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z); glVertex3f(0,0,0); - // line from avatar to 2 meters in front of avatar -- this is NOT working + // line from avatar to 2 meters in front of avatar -- this is working?? glColor3f(0,1,1); glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z); glVertex3f(lookingAt.x,lookingAt.y,lookingAt.z); - /* // Not yet ready for this... glm::vec3 up = glm::vec3(0.0,1.0,0.0); - glm::vec3 right = glm::vec3(1.0,0.0,0.0); + glm::vec3 right = glm::vec3(directionRightX,directionRightY,directionRightZ); float nearDist = 0.1; - float farDist = 500.0; + float farDist = 1.0; float fov = (0.7854f*2.0); // 45 deg * 2 = 90 deg float screenWidth = 800.0; // hack! We need to make this eventually be the correct height/width @@ -578,60 +600,63 @@ void render_view_frustum() { glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5); glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5); glm::vec3 nearBottomRight = nearCenter - (up*nearHeight*0.5) + (right*nearWidth*0.5); - */ - - -/* - glColor3f(1,1,1); + + //glColor3f(1,1,1); // near plane - bottom edge - glVertex3f(low.x,low.y,low.z); - glVertex3f(high.x,low.y,low.z); + glColor3f(1,0,0); + glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z); + glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z); // near plane - top edge - glVertex3f(low.x,high.y,low.z); - glVertex3f(high.x,high.y,low.z); + glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z); + glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z); // near plane - right edge - glVertex3f(low.x,high.y,low.z); - glVertex3f(low.x,low.y,low.z); + glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z); + glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z); // near plane - left edge - glVertex3f(high.x,high.y,low.z); - glVertex3f(high.x,low.y,low.z); + glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z); + glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z); // far plane - bottom edge - glVertex3f(low.x,low.y,high.z); - glVertex3f(high.x,low.y,high.z); - + glColor3f(0,1,0); // GREEN!!! + glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z); + glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z); + // far plane - top edge - glVertex3f(low.x,high.y,high.z); - glVertex3f(high.x,high.y,high.z); + glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); + glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z); // far plane - right edge - glVertex3f(low.x,high.y,high.z); - glVertex3f(low.x,low.y,high.z); + glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z); + glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z); // far plane - left edge - glVertex3f(high.x,high.y,high.z); - glVertex3f(high.x,low.y,high.z); + glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z); + glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); + + // right plane - bottom edge - near to distant - glVertex3f(low.x,low.y,low.z); - glVertex3f(low.x,low.y,high.z); + glColor3f(0,0,1); + glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z); + glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z); // right plane - top edge - near to distant - glVertex3f(low.x,high.y,low.z); - glVertex3f(low.x,high.y,high.z); + glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z); + glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z); // left plane - bottom edge - near to distant - glVertex3f(high.x,low.y,low.z); - glVertex3f(high.x,low.y,high.z); + glColor3f(0,1,1); + glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z); + glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z); // left plane - top edge - near to distant - glVertex3f(high.x,high.y,low.z); - glVertex3f(high.x,high.y,high.z); -*/ + glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z); + glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); + glEnd(); } @@ -764,7 +789,7 @@ void display(void) if (!displayHead && statsOn) render_world_box(); // brad's frustum for debugging - render_view_frustum(); + if (::frustumOn) render_view_frustum(); //--------------------------------- @@ -993,6 +1018,7 @@ void key(unsigned char k, int x, int y) if (k == '/') statsOn = !statsOn; // toggle stats if (k == '*') ::starsOn = !::starsOn; // toggle stars if (k == 'V') ::showingVoxels = !::showingVoxels; // toggle voxels + if (k == 'F') ::frustumOn = !::frustumOn; // toggle view frustum debugging if (k == '&') { ::paintOn = !::paintOn; // toggle paint ::setupPaintingVoxel(); // also randomizes colors From ab8140e0efeb3b4e8ccfcb1513b03fff48ed4eeb Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 10 Apr 2013 12:12:57 -0700 Subject: [PATCH 02/13] fixed a bug in avatar head lookat direction --- interface/src/Head.cpp | 31 ++++++++++++++++++++++++++++--- interface/src/Head.h | 2 ++ interface/src/Util.cpp | 33 +++++++++++++++++++++++++++++++++ interface/src/Util.h | 12 +++++------- interface/src/main.cpp | 37 +++++++++++++++++++++++++++++++++++-- 5 files changed, 103 insertions(+), 12 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 13f30084bc..1f2e7d92fc 100755 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -955,9 +955,34 @@ glm::vec3 Head::getAvatarHeadLookatDirection() { return glm::vec3 ( - avatar.bone[ AVATAR_BONE_HEAD ].orientation.getFront().x, - avatar.bone[ AVATAR_BONE_HEAD ].orientation.getFront().y, - avatar.bone[ AVATAR_BONE_HEAD ].orientation.getFront().z + avatar.orientation.getFront().x, + avatar.orientation.getFront().y, + -avatar.orientation.getFront().z + ); +} + + +//------------------------------------------- +glm::vec3 Head::getAvatarHeadPosition() +{ + return glm::vec3 + ( + avatar.bone[ AVATAR_BONE_HEAD ].position.x, + avatar.bone[ AVATAR_BONE_HEAD ].position.y, + avatar.bone[ AVATAR_BONE_HEAD ].position.z + ); +} + + + +//------------------------------------------- +glm::vec3 Head::getAvatarPosition() +{ + return glm::vec3 + ( + avatar.bone[ AVATAR_BONE_PELVIS_SPINE ].position.x, + avatar.bone[ AVATAR_BONE_PELVIS_SPINE ].position.y, + avatar.bone[ AVATAR_BONE_PELVIS_SPINE ].position.z ); } diff --git a/interface/src/Head.h b/interface/src/Head.h index 74c69492a9..68e0a15d95 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -160,6 +160,8 @@ class Head : public AgentData { float getAvatarYaw(); glm::vec3 getAvatarHeadLookatDirection(); + glm::vec3 getAvatarHeadPosition(); + glm::vec3 getAvatarPosition(); void render(int faceToFace, int isMine); diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index a670f48f9e..627af610fe 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -163,3 +163,36 @@ glm::vec3 operator* (const glm::vec3& lhs, float rhs) return result; } + + +void drawGroundPlaneGrid( float size, int resolution ) +{ + + glColor3f( 0.4f, 0.5f, 0.3f ); + glLineWidth(2.0); + + float gridSize = 10.0; + int gridResolution = 10; + + for (int g=0; g - -// added by Ventrella for utility purposes static const double ZERO = 0.0; static const double ONE = 1.0; static const double ONE_HALF = 0.5; @@ -29,11 +27,10 @@ static const double PI_OVER_180 = 3.14159265359 / 180.0; static const double EPSILON = 0.00001; //smallish number - used as margin of error for some values static const double SQUARE_ROOT_OF_2 = sqrt(2); static const double SQUARE_ROOT_OF_3 = sqrt(3); - -static const double METER = 1.0; -static const double DECIMETER = 0.1; -static const double CENTIMETER = 0.01; -static const double MILLIIMETER = 0.001; +static const double METER = 1.0; +static const double DECIMETER = 0.1; +static const double CENTIMETER = 0.01; +static const double MILLIIMETER = 0.001; float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos); float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw); @@ -51,5 +48,6 @@ double diffclock(timeval *clock1,timeval *clock2); glm::vec3 operator* (float lhs, const glm::vec3& rhs); glm::vec3 operator* (const glm::vec3& lhs, float rhs); +void drawGroundPlaneGrid( float size, int resolution ); #endif diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 00cd8d7bfc..9086385b96 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -511,6 +511,9 @@ void simulateHead(float frametime) } } + + + // XXXBHG - this code is not yet working. This is here to help Jeffery debug getAvatarHeadLookatDirection() // The code will draw a yellow line from the avatar's position to the origin, // It also attempts to draw a cyan line from the avatar to 2 meters in front of the avatar in the direction @@ -528,7 +531,35 @@ void render_view_frustum() { // farDist – the distance from the camera to the far plane // farHeight – the height of the far plane // farWidth – the width of the far plane + + +//Jeffrey's variation: +glm::vec3 avatarBodyPosition = myHead.getAvatarPosition(); +glm::vec3 avatarHeadPosition = myHead.getAvatarHeadPosition(); +glm::vec3 avatarHeadDirection = myHead.getAvatarHeadLookatDirection(); +glm::vec3 avatarHeadDirectionEndPoint( avatarHeadPosition ); +avatarHeadDirectionEndPoint += avatarHeadDirection; + +glDisable(GL_LIGHTING); +glLineWidth( 3.0 ); + +// line from avatar head to origin +glBegin( GL_LINE_STRIP ); +glColor4f( 1.0, 0.0, 0.0, 1.0 ); +glVertex3f( avatarBodyPosition.x, avatarBodyPosition.y, avatarBodyPosition.z ); +glVertex3f( 0.0f, 0.0f, 0.0f ); +glEnd(); + +//line from avatar head to 1 meter in front of avatar head +glBegin( GL_LINE_STRIP ); +glColor3f( 0.0f, 1.0f, 1.0f ); +glVertex3f( avatarHeadPosition.x, avatarHeadPosition.y, avatarHeadPosition.z ); +glVertex3f( avatarHeadDirectionEndPoint.x, avatarHeadDirectionEndPoint.y, avatarHeadDirectionEndPoint.z ); +glEnd(); + + + /* glm::vec3 cameraPosition = ::myHead.getPos()*-1.0; // We need to flip the sign to make this work. glm::vec3 cameraDirection = ::myHead.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct! @@ -550,7 +581,9 @@ void render_view_frustum() { glColor3f(0,1,1); glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z); glVertex3f(lookingAt.x,lookingAt.y,lookingAt.z); - + */ + + /* // Not yet ready for this... glm::vec3 up = glm::vec3(0.0,1.0,0.0); @@ -727,7 +760,7 @@ void display(void) //--------------------------------------------- // draw a grid gound plane.... //--------------------------------------------- - //drawGroundPlaneGrid( 5.0f, 9 ); + drawGroundPlaneGrid( 5.0f, 9 ); // Draw cloud of dots From 57724cb569105b6778f9dc7fb20cf098e4eb9e7d Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 10 Apr 2013 12:19:05 -0700 Subject: [PATCH 03/13] Fixing some compiler warnings in starfield --- interface/src/starfield/Controller.h | 2 +- interface/src/starfield/data/InputVertex.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/starfield/Controller.h b/interface/src/starfield/Controller.h index b004e73037..edf9fd7ec7 100644 --- a/interface/src/starfield/Controller.h +++ b/interface/src/starfield/Controller.h @@ -99,8 +99,8 @@ namespace starfield { _valLodOveralloc(1.2), _valLodNalloc(0), _valLodNrender(0), - _valLodBrightness(0), _valLodAllocBrightness(0), + _valLodBrightness(0), _ptrRenderer(0l) { } diff --git a/interface/src/starfield/data/InputVertex.h b/interface/src/starfield/data/InputVertex.h index dac242ec51..dc6c5a23be 100644 --- a/interface/src/starfield/data/InputVertex.h +++ b/interface/src/starfield/data/InputVertex.h @@ -26,8 +26,8 @@ namespace starfield { InputVertex(float azimuth, float altitude, unsigned color) { - _valColor = color >> 16 & 0xffu | color & 0xff00u | - color << 16 & 0xff0000u | 0xff000000u; + _valColor = (color >> 16 & 0xffu) | (color & 0xff00u) | + (color << 16 & 0xff0000u) | 0xff000000u; azimuth = angleConvert(azimuth); altitude = angleConvert(altitude); From 480eededfde7cd80fcf4947bfabaa5c796af7350 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 10 Apr 2013 12:19:55 -0700 Subject: [PATCH 04/13] Another fix to starfield warning. --- interface/src/starfield/Loader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/starfield/Loader.h b/interface/src/starfield/Loader.h index 83d63adc2c..67c8f53b66 100644 --- a/interface/src/starfield/Loader.h +++ b/interface/src/starfield/Loader.h @@ -50,7 +50,7 @@ namespace starfield { return false; } - fprintf(stderr, "Stars.cpp: read %d stars, rendering %d\n", + fprintf(stderr, "Stars.cpp: read %d stars, rendering %ld\n", _valRecordsRead, _ptrVertices->size()); return true; From 87c351ce4f663819008cdcea997e8095b4246ea5 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 10 Apr 2013 12:37:34 -0700 Subject: [PATCH 05/13] changed 'myHead' to 'myAvatar' in main.cpp, and a few local variables acordingly --- interface/src/main.cpp | 160 ++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 713dd3b09a..c93ef3051a 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -96,7 +96,7 @@ bool wantColorRandomizer = true; // for addSphere and load file Oscilloscope audioScope(256,200,true); -Head myHead; // The rendered head of oneself +Head myAvatar; // The rendered avatar of oneself Camera myCamera; // My view onto the world (sometimes on myself :) // Starfield information @@ -108,7 +108,7 @@ int starsTiles = 20; double starsLod = 1.0; #endif -bool showingVoxels = true; +bool showingVoxels = false; glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE); @@ -132,7 +132,7 @@ Finger myFinger(WIDTH, HEIGHT); Field field; #ifndef _WIN32 -Audio audio(&audioScope, &myHead); +Audio audio(&audioScope, &myAvatar); #endif #define IDLE_SIMULATE_MSECS 8 // How often should call simulate and other stuff @@ -241,11 +241,11 @@ void displayStats(void) char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene"; drawtext(10, 32, 0.10f, 0, 1.0, 0, legend2); - glm::vec3 headPos = myHead.getPos(); + glm::vec3 avatarPos = myAvatar.getPos(); char stats[200]; sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)=( %f , %f , %f )", - FPS, packetsPerSecond, bytesPerSecond, headPos.x,headPos.y,headPos.z); + FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z); drawtext(10, 49, 0.10f, 0, 1.0, 0, stats); if (serialPort.active) { sprintf(stats, "ADC samples = %d, LED = %d", @@ -321,8 +321,8 @@ void initDisplay(void) void init(void) { voxels.init(); - voxels.setViewerHead(&myHead); - myHead.setRenderYaw(startYaw); + voxels.setViewerHead(&myAvatar); + myAvatar.setRenderYaw(startYaw); headMouseX = WIDTH/2; headMouseY = HEIGHT/2; @@ -333,9 +333,9 @@ void init(void) field = Field(); if (noiseOn) { - myHead.setNoise(noise); + myAvatar.setNoise(noise); } - myHead.setPos(start_location ); + myAvatar.setPos(start_location ); myCamera.setPosition( start_location ); #ifdef MARKER_CAPTURE @@ -372,15 +372,15 @@ void reset_sensors() // // Reset serial I/O sensors // - myHead.setRenderYaw(startYaw); + myAvatar.setRenderYaw(startYaw); yaw = renderYawRate = 0; pitch = renderPitch = renderPitchRate = 0; - myHead.setPos(start_location); + myAvatar.setPos(start_location); headMouseX = WIDTH/2; headMouseY = HEIGHT/2; - myHead.reset(); + myAvatar.reset(); if (serialPort.active) { serialPort.resetTrailingAverages(); @@ -396,7 +396,7 @@ void simulateHand(float deltaTime) { float dx = mouseX - mouseStartX; float dy = mouseY - mouseStartY; glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0); - myHead.hand->addVelocity(vel*deltaTime); + myAvatar.hand->addVelocity(vel*deltaTime); } } @@ -412,12 +412,12 @@ void simulateHead(float frametime) //float measured_lateral_accel = serialPort.getRelativeValue(ACCEL_X); //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z); - myHead.UpdatePos(frametime, &serialPort, headMirror, &gravity); + myAvatar.UpdatePos(frametime, &serialPort, headMirror, &gravity); //------------------------------------------------------------------------------------- // set the position of the avatar //------------------------------------------------------------------------------------- - myHead.setAvatarPosition( -myHead.getPos().x, -myHead.getPos().y, -myHead.getPos().z ); + myAvatar.setAvatarPosition( -myAvatar.getPos().x, -myAvatar.getPos().y, -myAvatar.getPos().z ); // Update head_mouse model const float MIN_MOUSE_RATE = 30.0; @@ -442,8 +442,8 @@ void simulateHead(float frametime) // Update render pitch and yaw rates based on keyPositions const float KEY_YAW_SENSITIVITY = 2.0; - if (myHead.getDriveKeys(ROT_LEFT)) renderYawRate -= KEY_YAW_SENSITIVITY*frametime; - if (myHead.getDriveKeys(ROT_RIGHT)) renderYawRate += KEY_YAW_SENSITIVITY*frametime; + if (myAvatar.getDriveKeys(ROT_LEFT)) renderYawRate -= KEY_YAW_SENSITIVITY*frametime; + if (myAvatar.getDriveKeys(ROT_RIGHT)) renderYawRate += KEY_YAW_SENSITIVITY*frametime; if (fabs(measured_yaw_rate) > MIN_YAW_RATE) { @@ -470,32 +470,32 @@ void simulateHead(float frametime) renderYawRate *= (1.f - 7.0*frametime); // Update own head data - myHead.setRenderYaw(myHead.getRenderYaw() + renderYawRate); - myHead.setRenderPitch(renderPitch); + myAvatar.setRenderYaw(myAvatar.getRenderYaw() + renderYawRate); + myAvatar.setRenderPitch(renderPitch); // Get audio loudness data from audio input device float loudness, averageLoudness; #ifndef _WIN32 audio.getInputLoudness(&loudness, &averageLoudness); - myHead.setLoudness(loudness); - myHead.setAverageLoudness(averageLoudness); + myAvatar.setLoudness(loudness); + myAvatar.setAverageLoudness(averageLoudness); #endif // Send my streaming head data to agents that are nearby and need to see it! const int MAX_BROADCAST_STRING = 200; char broadcast_string[MAX_BROADCAST_STRING]; - int broadcast_bytes = myHead.getBroadcastData(broadcast_string); + int broadcast_bytes = myAvatar.getBroadcastData(broadcast_string); agentList.broadcastToAgents(broadcast_string, broadcast_bytes,AgentList::AGENTS_OF_TYPE_VOXEL_AND_INTERFACE); // If I'm in paint mode, send a voxel out to VOXEL server agents. if (::paintOn) { - glm::vec3 headPos = myHead.getPos(); + glm::vec3 avatarPos = myAvatar.getPos(); // For some reason, we don't want to flip X and Z here. - ::paintingVoxel.x = headPos.x/-10.0; - ::paintingVoxel.y = headPos.y/-10.0; - ::paintingVoxel.z = headPos.z/-10.0; + ::paintingVoxel.x = avatarPos.x/-10.0; + ::paintingVoxel.y = avatarPos.y/-10.0; + ::paintingVoxel.z = avatarPos.z/-10.0; unsigned char* bufferOut; int sizeOut; @@ -535,9 +535,9 @@ void render_view_frustum() { //Jeffrey's variation: -glm::vec3 avatarBodyPosition = myHead.getAvatarPosition(); -glm::vec3 avatarHeadPosition = myHead.getAvatarHeadPosition(); -glm::vec3 avatarHeadDirection = myHead.getAvatarHeadLookatDirection(); +glm::vec3 avatarBodyPosition = myAvatar.getAvatarPosition(); +glm::vec3 avatarHeadPosition = myAvatar.getAvatarHeadPosition(); +glm::vec3 avatarHeadDirection = myAvatar.getAvatarHeadLookatDirection(); glm::vec3 avatarHeadDirectionEndPoint( avatarHeadPosition ); avatarHeadDirectionEndPoint += avatarHeadDirection; @@ -561,13 +561,13 @@ glEnd(); /* - glm::vec3 cameraPosition = ::myHead.getPos()*-1.0; // We need to flip the sign to make this work. - //glm::vec3 cameraDirection = ::myHead.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct! + glm::vec3 cameraPosition = ::myAvatar.getPos()*-1.0; // We need to flip the sign to make this work. + //glm::vec3 cameraDirection = ::myAvatar.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct! - float yaw = myHead.getYaw(); + float yaw = myAvatar.getYaw(); float rightOfYaw = yaw-90.0; - //float pitch = myHead.getPitch(); - //float roll = myHead.getRoll(); + //float pitch = myAvatar.getPitch(); + //float roll = myAvatar.getRoll(); //printf("yaw=%f, right of yaw=%f, pitch=%f, roll=%f\n",yaw,rightOfYaw,pitch,roll); @@ -699,7 +699,7 @@ glEnd(); void display(void) { - //printf( "avatar head lookat = %f, %f, %f\n", myHead.getAvatarHeadLookatDirection().x, myHead.getAvatarHeadLookatDirection().y, myHead.getAvatarHeadLookatDirection().z ); + //printf( "avatar head lookat = %f, %f, %f\n", myAvatar.getAvatarHeadLookatDirection().x, myAvatar.getAvatarHeadLookatDirection().y, myAvatar.getAvatarHeadLookatDirection().z ); PerfStat("display"); @@ -729,14 +729,14 @@ void display(void) //-------------------------------------------------------- // camera settings //-------------------------------------------------------- - myCamera.setTargetPosition( myHead.getPos() ); + myCamera.setTargetPosition( myAvatar.getPos() ); if ( displayHead ) { //----------------------------------------------- // set the camera to looking at my own face //----------------------------------------------- - myCamera.setYaw ( - myHead.getAvatarYaw() ); + myCamera.setYaw ( - myAvatar.getAvatarYaw() ); myCamera.setPitch ( 0.0 ); myCamera.setRoll ( 0.0 ); myCamera.setUp ( 0.4 ); @@ -749,7 +749,7 @@ void display(void) //---------------------------------------------------- // set the camera to third-person view behind my av //---------------------------------------------------- - myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() ); + myCamera.setYaw ( 180.0 - myAvatar.getAvatarYaw() ); myCamera.setPitch ( 0.0 ); myCamera.setRoll ( 0.0 ); myCamera.setUp ( 0.2 ); @@ -805,7 +805,7 @@ void display(void) // Draw field vectors if (displayField) field.render(); - // Render heads of other agents + // Render avatars of other agents for(std::vector::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) { if (agent->getLinkedData() != NULL) @@ -829,15 +829,15 @@ void display(void) //--------------------------------- - // Render my own head + // Render my own avatar //--------------------------------- - myHead.render( true, 1 ); + myAvatar.render( true, 1 ); /* glPushMatrix(); glLoadIdentity(); glTranslatef(0.f, 0.f, -7.f); - myHead.render(displayHead, 1); + myAvatar.render(displayHead, 1); glPopMatrix(); */ @@ -861,7 +861,7 @@ void display(void) #endif - //drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0); + //drawvec3(100, 100, 0.15, 0, 1.0, 0, myAvatar.getPos(), 0, 1, 0); glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic ); if (displayHeadMouse && !displayHead && statsOn) @@ -957,11 +957,11 @@ void shiftPaintingColor() void setupPaintingVoxel() { - glm::vec3 headPos = myHead.getPos(); + glm::vec3 avatarPos = myAvatar.getPos(); - ::paintingVoxel.x = headPos.z/-10.0; // voxel space x is negative z head space - ::paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space - ::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space + ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space + ::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space + ::paintingVoxel.z = avatarPos.x/-10.0; // voxel space z is negative x head space ::paintingVoxel.s = 1.0/256; shiftPaintingColor(); @@ -993,20 +993,20 @@ const float KEYBOARD_FLY_RATE = 0.08; void specialkeyUp(int k, int x, int y) { if (k == GLUT_KEY_UP) { - myHead.setDriveKeys(FWD, 0); - myHead.setDriveKeys(UP, 0); + myAvatar.setDriveKeys(FWD, 0); + myAvatar.setDriveKeys(UP, 0); } if (k == GLUT_KEY_DOWN) { - myHead.setDriveKeys(BACK, 0); - myHead.setDriveKeys(DOWN, 0); + myAvatar.setDriveKeys(BACK, 0); + myAvatar.setDriveKeys(DOWN, 0); } if (k == GLUT_KEY_LEFT) { - myHead.setDriveKeys(LEFT, 0); - myHead.setDriveKeys(ROT_LEFT, 0); + myAvatar.setDriveKeys(LEFT, 0); + myAvatar.setDriveKeys(ROT_LEFT, 0); } if (k == GLUT_KEY_RIGHT) { - myHead.setDriveKeys(RIGHT, 0); - myHead.setDriveKeys(ROT_RIGHT, 0); + myAvatar.setDriveKeys(RIGHT, 0); + myAvatar.setDriveKeys(ROT_RIGHT, 0); } } @@ -1015,20 +1015,20 @@ void specialkey(int k, int x, int y) { if (k == GLUT_KEY_UP || k == GLUT_KEY_DOWN || k == GLUT_KEY_LEFT || k == GLUT_KEY_RIGHT) { if (k == GLUT_KEY_UP) { - if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(UP, 1); - else myHead.setDriveKeys(FWD, 1); + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(UP, 1); + else myAvatar.setDriveKeys(FWD, 1); } if (k == GLUT_KEY_DOWN) { - if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(DOWN, 1); - else myHead.setDriveKeys(BACK, 1); + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(DOWN, 1); + else myAvatar.setDriveKeys(BACK, 1); } if (k == GLUT_KEY_LEFT) { - if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(LEFT, 1); - else myHead.setDriveKeys(ROT_LEFT, 1); + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(LEFT, 1); + else myAvatar.setDriveKeys(ROT_LEFT, 1); } if (k == GLUT_KEY_RIGHT) { - if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(RIGHT, 1); - else myHead.setDriveKeys(ROT_RIGHT, 1); + if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(RIGHT, 1); + else myAvatar.setDriveKeys(ROT_RIGHT, 1); } #ifndef _WIN32 audio.setWalkingState(true); @@ -1038,12 +1038,12 @@ void specialkey(int k, int x, int y) void keyUp(unsigned char k, int x, int y) { - if (k == 'e') myHead.setDriveKeys(UP, 0); - if (k == 'c') myHead.setDriveKeys(DOWN, 0); - if (k == 'w') myHead.setDriveKeys(FWD, 0); - if (k == 's') myHead.setDriveKeys(BACK, 0); - if (k == 'a') myHead.setDriveKeys(ROT_LEFT, 0); - if (k == 'd') myHead.setDriveKeys(ROT_RIGHT, 0); + if (k == 'e') myAvatar.setDriveKeys(UP, 0); + if (k == 'c') myAvatar.setDriveKeys(DOWN, 0); + if (k == 'w') myAvatar.setDriveKeys(FWD, 0); + if (k == 's') myAvatar.setDriveKeys(BACK, 0); + if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 0); + if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 0); } @@ -1068,11 +1068,11 @@ void key(unsigned char k, int x, int y) noiseOn = !noiseOn; // Toggle noise if (noiseOn) { - myHead.setNoise(noise); + myAvatar.setNoise(noise); } else { - myHead.setNoise(0); + myAvatar.setNoise(0); } } @@ -1088,10 +1088,10 @@ void key(unsigned char k, int x, int y) if (k == 'f') displayField = !displayField; if (k == 'l') displayLevels = !displayLevels; - if (k == 'e') myHead.setDriveKeys(UP, 1); - if (k == 'c') myHead.setDriveKeys(DOWN, 1); - if (k == 'w') myHead.setDriveKeys(FWD, 1); - if (k == 's') myHead.setDriveKeys(BACK, 1); + if (k == 'e') myAvatar.setDriveKeys(UP, 1); + if (k == 'c') myAvatar.setDriveKeys(DOWN, 1); + if (k == 'w') myAvatar.setDriveKeys(FWD, 1); + if (k == 's') myAvatar.setDriveKeys(BACK, 1); if (k == ' ') reset_sensors(); if (k == 't') renderPitchRate -= KEYBOARD_PITCH_RATE; if (k == 'g') renderPitchRate += KEYBOARD_PITCH_RATE; @@ -1102,8 +1102,8 @@ void key(unsigned char k, int x, int y) if (k == 'k') if (starsLod > 0.01) starsLod = stars.changeLOD(0.99); if (k == 'r') stars.readInput(starFile, 0); #endif - if (k == 'a') myHead.setDriveKeys(ROT_LEFT, 1); - if (k == 'd') myHead.setDriveKeys(ROT_RIGHT, 1); + if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 1); + if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 1); // press the . key to get a new random sphere of voxels added if (k == '.') addRandomSphere(wantColorRandomizer); @@ -1125,7 +1125,7 @@ void *networkReceive(void *args) if (incomingPacket[0] == PACKET_HEADER_TRANSMITTER_DATA) { // Pass everything but transmitter data to the agent list - myHead.hand->processTransmitterData(incomingPacket, bytesReceived); + myAvatar.hand->processTransmitterData(incomingPacket, bytesReceived); } else if (incomingPacket[0] == PACKET_HEADER_VOXEL_DATA || incomingPacket[0] == PACKET_HEADER_Z_COMMAND || incomingPacket[0] == PACKET_HEADER_ERASE_VOXEL) { @@ -1162,7 +1162,7 @@ void idle(void) float backFront = 0.0; glm::vec3 handMovement( leftRight, downUp, backFront ); - myHead.setHandMovement( handMovement ); + myAvatar.setHandMovement( handMovement ); } // Simulation @@ -1185,7 +1185,7 @@ void idle(void) simulateHand(1.f/FPS); field.simulate(1.f/FPS); - myHead.simulate(1.f/FPS); + myAvatar.simulate(1.f/FPS); balls.simulate(1.f/FPS); cloud.simulate(1.f/FPS); lattice.simulate(1.f/FPS); From 8010129774140821e4f8b75e8fcbe9117d0270fa Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 10 Apr 2013 12:43:26 -0700 Subject: [PATCH 06/13] Few more bits of cleanup and variable renaming, turned voxel rendering back on by default --- interface/src/Cloud.cpp | 4 ++-- interface/src/Util.cpp | 4 ++-- interface/src/main.cpp | 24 ++++-------------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/interface/src/Cloud.cpp b/interface/src/Cloud.cpp index e612d042a9..5d68ecba75 100644 --- a/interface/src/Cloud.cpp +++ b/interface/src/Cloud.cpp @@ -46,7 +46,7 @@ Cloud::Cloud(int num, void Cloud::render() { - float particle_attenuation_quadratic[] = { 0.0f, 0.0f, 2.0f }; + float particleAttenuationQuadratic[] = { 0.0f, 0.0f, 2.0f }; glEnable( GL_TEXTURE_2D ); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); @@ -57,7 +57,7 @@ void Cloud::render() { glPointSize( maxSize ); - glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, particle_attenuation_quadratic ); + glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, particleAttenuationQuadratic ); glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, maxSize ); glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 0.001f ); diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index a670f48f9e..071825044a 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -46,9 +46,9 @@ void render_vector(glm::vec3 * vec) glVertex3f(vec->x, vec->y, vec->z); // Draw marker dots for magnitude glEnd(); - float particle_attenuation_quadratic[] = { 0.0f, 0.0f, 2.0f }; // larger Z = smaller particles + float particleAttenuationQuadratic[] = { 0.0f, 0.0f, 2.0f }; // larger Z = smaller particles - glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, particle_attenuation_quadratic ); + glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, particleAttenuationQuadratic ); glEnable(GL_POINT_SMOOTH); glPointSize(10.0); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 94b712a1fc..eef6aa4018 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -108,7 +108,7 @@ int starsTiles = 20; double starsLod = 1.0; #endif -bool showingVoxels = false; +bool showingVoxels = true; glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE); @@ -120,7 +120,7 @@ ParticleSystem balls(0, 0.0 // Gravity ); -Cloud cloud(0, // Particles +Cloud cloud(0, // Particles box, // Bounding Box false // Wrap ); @@ -177,10 +177,8 @@ SerialInterface serialPort; int latency_display = 1; glm::vec3 gravity; -int first_measurement = 1; -//int samplecount = 0; -// Frame rate Measurement +// Frame Rate Measurement int frameCount = 0; float FPS = 120.f; @@ -188,12 +186,6 @@ timeval timerStart, timerEnd; timeval lastTimeIdle; double elapsedTime; -// Particles - - -float particle_attenuation_quadratic[] = { 0.0f, 0.0f, 2.0f }; // larger Z = smaller particles -float pointer_attenuation_quadratic[] = { 1.0f, 0.0f, 0.0f }; // for 2D view - #ifdef MARKER_CAPTURE /*** Marker Capture ***/ @@ -253,14 +245,6 @@ void displayStats(void) drawtext(300, 30, 0.10f, 0, 1.0, 0, stats); } - // Output the ping times to the various agents -// std::stringstream pingTimes; -// pingTimes << "Agent Pings, msecs:"; -// for (int i = 0; i < getAgentCount(); i++) { -// pingTimes << " " << getAgentAddress(i) << ": " << getAgentPing(i); -// } -// drawtext(10,50,0.10, 0, 1.0, 0, (char *)pingTimes.str().c_str()); - std::stringstream voxelStats; voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered(); drawtext(10,70,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); @@ -826,7 +810,7 @@ void display(void) //drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0); - glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic ); + //glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic ); if (displayHeadMouse && !displayHead && statsOn) { From d57a4428d9aa275a163283e242e818bd599b4e18 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 10 Apr 2013 12:47:40 -0700 Subject: [PATCH 07/13] deleted unused stuff that caused conflict with myAvatar change --- interface/src/Head.cpp | 0 interface/src/main.cpp | 4 ---- 2 files changed, 4 deletions(-) mode change 100755 => 100644 interface/src/Head.cpp diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp old mode 100755 new mode 100644 diff --git a/interface/src/main.cpp b/interface/src/main.cpp index fd0eff13e7..6e8740de78 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -844,10 +844,6 @@ void display(void) if (audioScope.getState()) audioScope.render(); #endif - - //drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0); - //glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic ); - if (displayHeadMouse && !displayHead && statsOn) { // Display small target box at center or head mouse target that can also be used to measure LOD From be5044c560adbf86abcf5d94ed77e42e75193261 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 10 Apr 2013 12:54:52 -0700 Subject: [PATCH 08/13] flipped y direction of up-down avatar navigation --- interface/src/Head.cpp | 9 +++++---- interface/src/Head.h | 8 ++++---- interface/src/main.cpp | 10 +++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 12b10b38c8..f03999e739 100755 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -935,6 +935,7 @@ printf( "listing bone parent springyPosition:\n" ); avatar.bone[ avatar.bone[b].parent ].springyVelocity += springDirection * force; } + avatar.bone[b].springyVelocity += ( avatar.bone[b].position - avatar.bone[b].springyPosition ) * 0.01f; avatar.bone[b].springyVelocity *= 0.8; avatar.bone[b].springyPosition += avatar.bone[b].springyVelocity; @@ -944,14 +945,14 @@ printf( "listing bone parent springyPosition:\n" ); //------------------------------- -float Head::getAvatarYaw() +float Head::getBodyYaw() { return avatar.yaw; } //------------------------------------------- -glm::vec3 Head::getAvatarHeadLookatDirection() +glm::vec3 Head::getHeadLookatDirection() { return glm::vec3 ( @@ -963,7 +964,7 @@ glm::vec3 Head::getAvatarHeadLookatDirection() //------------------------------------------- -glm::vec3 Head::getAvatarHeadPosition() +glm::vec3 Head::getHeadPosition() { return glm::vec3 ( @@ -976,7 +977,7 @@ glm::vec3 Head::getAvatarHeadPosition() //------------------------------------------- -glm::vec3 Head::getAvatarPosition() +glm::vec3 Head::getBodyPosition() { return glm::vec3 ( diff --git a/interface/src/Head.h b/interface/src/Head.h index 68e0a15d95..aa96aa7fa7 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -158,10 +158,10 @@ class Head : public AgentData { float getYaw() {return Yaw;} float getLastMeasuredYaw() {return YawRate;} - float getAvatarYaw(); - glm::vec3 getAvatarHeadLookatDirection(); - glm::vec3 getAvatarHeadPosition(); - glm::vec3 getAvatarPosition(); + float getBodyYaw(); + glm::vec3 getHeadLookatDirection(); + glm::vec3 getHeadPosition(); + glm::vec3 getBodyPosition(); void render(int faceToFace, int isMine); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index c93ef3051a..ebfd2aa024 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -535,9 +535,9 @@ void render_view_frustum() { //Jeffrey's variation: -glm::vec3 avatarBodyPosition = myAvatar.getAvatarPosition(); -glm::vec3 avatarHeadPosition = myAvatar.getAvatarHeadPosition(); -glm::vec3 avatarHeadDirection = myAvatar.getAvatarHeadLookatDirection(); +glm::vec3 avatarBodyPosition = myAvatar.getBodyPosition(); +glm::vec3 avatarHeadPosition = myAvatar.getHeadPosition(); +glm::vec3 avatarHeadDirection = myAvatar.getHeadLookatDirection(); glm::vec3 avatarHeadDirectionEndPoint( avatarHeadPosition ); avatarHeadDirectionEndPoint += avatarHeadDirection; @@ -736,7 +736,7 @@ void display(void) //----------------------------------------------- // set the camera to looking at my own face //----------------------------------------------- - myCamera.setYaw ( - myAvatar.getAvatarYaw() ); + myCamera.setYaw ( - myAvatar.getBodyYaw() ); myCamera.setPitch ( 0.0 ); myCamera.setRoll ( 0.0 ); myCamera.setUp ( 0.4 ); @@ -749,7 +749,7 @@ void display(void) //---------------------------------------------------- // set the camera to third-person view behind my av //---------------------------------------------------- - myCamera.setYaw ( 180.0 - myAvatar.getAvatarYaw() ); + myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() ); myCamera.setPitch ( 0.0 ); myCamera.setRoll ( 0.0 ); myCamera.setUp ( 0.2 ); From 7cd70b1f4704f30fc59a04e54a1e7a7e7c464cb7 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Apr 2013 13:12:47 -0700 Subject: [PATCH 09/13] use Jeffery's code for view frustum debugging --- interface/src/main.cpp | 75 +++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 48 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 1b5c4abf70..eef4459bce 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -518,47 +518,44 @@ void render_view_frustum() { // farWidth – the width of the far plane -//Jeffrey's variation: -glm::vec3 avatarBodyPosition = myAvatar.getBodyPosition(); -glm::vec3 avatarHeadPosition = myAvatar.getHeadPosition(); -glm::vec3 avatarHeadDirection = myAvatar.getHeadLookatDirection(); + //Jeffrey's variation: + glm::vec3 avatarBodyPosition = myAvatar.getBodyPosition(); + glm::vec3 avatarHeadPosition = myAvatar.getHeadPosition(); + glm::vec3 avatarHeadDirection = myAvatar.getHeadLookatDirection(); -glm::vec3 avatarHeadDirectionEndPoint( avatarHeadPosition ); -avatarHeadDirectionEndPoint += avatarHeadDirection; + glm::vec3 avatarHeadDirectionEndPoint( avatarHeadPosition ); + avatarHeadDirectionEndPoint += avatarHeadDirection; -glDisable(GL_LIGHTING); -glLineWidth( 3.0 ); + glDisable(GL_LIGHTING); + glLineWidth( 3.0 ); -// line from avatar head to origin -glBegin( GL_LINE_STRIP ); -glColor4f( 1.0, 0.0, 0.0, 1.0 ); -glVertex3f( avatarBodyPosition.x, avatarBodyPosition.y, avatarBodyPosition.z ); -glVertex3f( 0.0f, 0.0f, 0.0f ); -glEnd(); + // line from avatar head to origin + glBegin( GL_LINE_STRIP ); + glColor4f( 1.0, 0.0, 0.0, 1.0 ); + glVertex3f( avatarBodyPosition.x, avatarBodyPosition.y, avatarBodyPosition.z ); + glVertex3f( 0.0f, 0.0f, 0.0f ); + glEnd(); -//line from avatar head to 1 meter in front of avatar head -glBegin( GL_LINE_STRIP ); -glColor3f( 0.0f, 1.0f, 1.0f ); -glVertex3f( avatarHeadPosition.x, avatarHeadPosition.y, avatarHeadPosition.z ); -glVertex3f( avatarHeadDirectionEndPoint.x, avatarHeadDirectionEndPoint.y, avatarHeadDirectionEndPoint.z ); -glEnd(); + //line from avatar head to 1 meter in front of avatar head + glBegin( GL_LINE_STRIP ); + glColor3f( 0.0f, 1.0f, 1.0f ); + glVertex3f( avatarHeadPosition.x, avatarHeadPosition.y, avatarHeadPosition.z ); + glVertex3f( avatarHeadDirectionEndPoint.x, avatarHeadDirectionEndPoint.y, avatarHeadDirectionEndPoint.z ); + glEnd(); - /* - glm::vec3 cameraPosition = ::myAvatar.getPos()*-1.0; // We need to flip the sign to make this work. - //glm::vec3 cameraDirection = ::myAvatar.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct! + glm::vec3 viewFrustumPosition = avatarHeadPosition; + glm::vec3 viewFrustumDirection = avatarHeadDirection; float yaw = myAvatar.getYaw(); float rightOfYaw = yaw-90.0; - //float pitch = myAvatar.getPitch(); - //float roll = myAvatar.getRoll(); //printf("yaw=%f, right of yaw=%f, pitch=%f, roll=%f\n",yaw,rightOfYaw,pitch,roll); // Currently we don't utilize pitch and yaw. Mainly because UI doesn't handle it. - float directionX = sin(yaw*PI_OVER_180); - float directionY = 0.0; - float directionZ = cos(yaw*PI_OVER_180); + //float directionX = sin(yaw*PI_OVER_180); + //float directionY = 0.0; + //float directionZ = cos(yaw*PI_OVER_180); //printf("directionX=%f, directionY=%f, directionZ=%f\n",directionX,directionY,directionZ); @@ -568,31 +565,14 @@ glEnd(); //printf("directionRightX=%f, directionRightY=%f, directionRightZ=%f\n",directionRightX,directionRightY,directionRightZ); - glm::vec3 cameraDirection = glm::vec3(directionX,directionY,directionZ); - - // this is a temporary test, create a vertice that's 2 meters in front of avatar in direction their looking - glm::vec3 lookingAt = cameraPosition+(cameraDirection*2.0); - // Some debug lines. glDisable(GL_LIGHTING); glColor4f(1.0, 1.0, 1.0, 1.0); glLineWidth(1.0); glBegin(GL_LINES); - // line from avatar to the origin -- this one is working. - glColor3f(1,1,0); - glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z); - glVertex3f(0,0,0); - - // line from avatar to 2 meters in front of avatar -- this is working?? - glColor3f(0,1,1); - glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z); - glVertex3f(lookingAt.x,lookingAt.y,lookingAt.z); - */ - /* - // Not yet ready for this... glm::vec3 up = glm::vec3(0.0,1.0,0.0); glm::vec3 right = glm::vec3(directionRightX,directionRightY,directionRightZ); @@ -608,13 +588,13 @@ glEnd(); float farHeight = 2 * tan(fov / 2) * farDist; float farWidth = farHeight * ratio; - glm::vec3 farCenter = cameraPosition+cameraDirection*farDist; + glm::vec3 farCenter = viewFrustumPosition+viewFrustumDirection*farDist; glm::vec3 farTopLeft = farCenter + (up*farHeight*0.5) - (right*farWidth*0.5); glm::vec3 farTopRight = farCenter + (up*farHeight*0.5) + (right*farWidth*0.5); glm::vec3 farBottomLeft = farCenter - (up*farHeight*0.5) - (right*farWidth*0.5); glm::vec3 farBottomRight = farCenter - (up*farHeight*0.5) + (right*farWidth*0.5); - glm::vec3 nearCenter = cameraPosition+cameraDirection*nearDist; + glm::vec3 nearCenter = viewFrustumPosition+viewFrustumDirection*nearDist; glm::vec3 nearTopLeft = nearCenter + (up*nearHeight*0.5) - (right*nearWidth*0.5); glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5); glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5); @@ -675,7 +655,6 @@ glEnd(); // left plane - top edge - near to distant glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z); glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); - */ glEnd(); } From 4b7b5437acf267490f0b5bbbacc1693d27bf8975 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Apr 2013 13:26:21 -0700 Subject: [PATCH 10/13] some cleanup of view frustum debugging code --- interface/src/Head.cpp | 22 +++++++++++ interface/src/Head.h | 2 + interface/src/main.cpp | 83 ++++++++---------------------------------- 3 files changed, 40 insertions(+), 67 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index f03999e739..14abe9ee71 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -962,6 +962,28 @@ glm::vec3 Head::getHeadLookatDirection() ); } +//------------------------------------------- +glm::vec3 Head::getHeadLookatDirectionUp() +{ + return glm::vec3 + ( + avatar.orientation.getUp().x, + avatar.orientation.getUp().y, + -avatar.orientation.getUp().z + ); +} + +//------------------------------------------- +glm::vec3 Head::getHeadLookatDirectionRight() +{ + return glm::vec3 + ( + avatar.orientation.getRight().x, + avatar.orientation.getRight().y, + -avatar.orientation.getRight().z + ); +} + //------------------------------------------- glm::vec3 Head::getHeadPosition() diff --git a/interface/src/Head.h b/interface/src/Head.h index aa96aa7fa7..e0cf0dac64 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -160,6 +160,8 @@ class Head : public AgentData { float getBodyYaw(); glm::vec3 getHeadLookatDirection(); + glm::vec3 getHeadLookatDirectionUp(); + glm::vec3 getHeadLookatDirectionRight(); glm::vec3 getHeadPosition(); glm::vec3 getBodyPosition(); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index eef4459bce..df95fd037d 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -517,75 +517,22 @@ void render_view_frustum() { // farHeight – the height of the far plane // farWidth – the width of the far plane + glm::vec3 viewFrustumPosition = myAvatar.getHeadPosition(); + glm::vec3 viewFrustumDirection = myAvatar.getHeadLookatDirection(); - //Jeffrey's variation: - glm::vec3 avatarBodyPosition = myAvatar.getBodyPosition(); - glm::vec3 avatarHeadPosition = myAvatar.getHeadPosition(); - glm::vec3 avatarHeadDirection = myAvatar.getHeadLookatDirection(); - - glm::vec3 avatarHeadDirectionEndPoint( avatarHeadPosition ); - avatarHeadDirectionEndPoint += avatarHeadDirection; - - glDisable(GL_LIGHTING); - glLineWidth( 3.0 ); - - // line from avatar head to origin - glBegin( GL_LINE_STRIP ); - glColor4f( 1.0, 0.0, 0.0, 1.0 ); - glVertex3f( avatarBodyPosition.x, avatarBodyPosition.y, avatarBodyPosition.z ); - glVertex3f( 0.0f, 0.0f, 0.0f ); - glEnd(); - - //line from avatar head to 1 meter in front of avatar head - glBegin( GL_LINE_STRIP ); - glColor3f( 0.0f, 1.0f, 1.0f ); - glVertex3f( avatarHeadPosition.x, avatarHeadPosition.y, avatarHeadPosition.z ); - glVertex3f( avatarHeadDirectionEndPoint.x, avatarHeadDirectionEndPoint.y, avatarHeadDirectionEndPoint.z ); - glEnd(); - - - glm::vec3 viewFrustumPosition = avatarHeadPosition; - glm::vec3 viewFrustumDirection = avatarHeadDirection; - - float yaw = myAvatar.getYaw(); - float rightOfYaw = yaw-90.0; - - //printf("yaw=%f, right of yaw=%f, pitch=%f, roll=%f\n",yaw,rightOfYaw,pitch,roll); - - // Currently we don't utilize pitch and yaw. Mainly because UI doesn't handle it. - //float directionX = sin(yaw*PI_OVER_180); - //float directionY = 0.0; - //float directionZ = cos(yaw*PI_OVER_180); - - //printf("directionX=%f, directionY=%f, directionZ=%f\n",directionX,directionY,directionZ); - - float directionRightX = sin(rightOfYaw*PI_OVER_180); - float directionRightY = 0.0; - float directionRightZ = cos(rightOfYaw*PI_OVER_180); - - //printf("directionRightX=%f, directionRightY=%f, directionRightZ=%f\n",directionRightX,directionRightY,directionRightZ); - - // Some debug lines. - glDisable(GL_LIGHTING); - glColor4f(1.0, 1.0, 1.0, 1.0); - glLineWidth(1.0); - glBegin(GL_LINES); - - - - // Not yet ready for this... - glm::vec3 up = glm::vec3(0.0,1.0,0.0); - glm::vec3 right = glm::vec3(directionRightX,directionRightY,directionRightZ); + glm::vec3 up = myAvatar.getHeadLookatDirectionUp(); + glm::vec3 right = myAvatar.getHeadLookatDirectionRight(); float nearDist = 0.1; float farDist = 1.0; - float fov = (0.7854f*2.0); // 45 deg * 2 = 90 deg + float fovHalfAngle = 0.7854f; // 45 deg for half, so fov = 90 deg - float screenWidth = 800.0; // hack! We need to make this eventually be the correct height/width - float screenHeight = 600.0; + float screenWidth = ::WIDTH; // These values come from reshape() + float screenHeight = ::HEIGHT; float ratio = screenWidth/screenHeight; - float nearHeight = 2 * tan(fov / 2) * nearDist; + + float nearHeight = 2 * tan(fovHalfAngle) * nearDist; float nearWidth = nearHeight * ratio; - float farHeight = 2 * tan(fov / 2) * farDist; + float farHeight = 2 * tan(fovHalfAngle) * farDist; float farWidth = farHeight * ratio; glm::vec3 farCenter = viewFrustumPosition+viewFrustumDirection*farDist; @@ -600,8 +547,12 @@ void render_view_frustum() { glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5); glm::vec3 nearBottomRight = nearCenter - (up*nearHeight*0.5) + (right*nearWidth*0.5); - - //glColor3f(1,1,1); + // Get ready to draw some lines + glDisable(GL_LIGHTING); + glColor4f(1.0, 1.0, 1.0, 1.0); + glLineWidth(1.0); + glBegin(GL_LINES); + // near plane - bottom edge glColor3f(1,0,0); glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z); @@ -636,8 +587,6 @@ void render_view_frustum() { glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z); glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z); - - // right plane - bottom edge - near to distant glColor3f(0,0,1); glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z); From 7b4d0b5598f66f0e03ad860da427336f982d5201 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 10 Apr 2013 14:29:08 -0700 Subject: [PATCH 11/13] removed bone spam --- interface/src/Head.cpp | 51 +++++++++++++----------------------------- interface/src/main.cpp | 2 +- 2 files changed, 17 insertions(+), 36 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index f03999e739..f494b08ef4 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -773,12 +773,6 @@ void Head::initializeAvatar() // generate world positions //---------------------------------------------------------------------------- updateAvatarSkeleton(); - - - -//avatar.bone[4].springyVelocity = glm::vec3( 1.0f, 0.0f, 0.0f ); - - } @@ -866,7 +860,6 @@ void Head::updateAvatarSkeleton() //------------------------------------------------------------------------ updateHandMovement(); - /* glm::dvec3 v( avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position ); v -= avatar.bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].position; @@ -875,8 +868,6 @@ void Head::updateAvatarSkeleton() { avatar.bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].position += v * 0.2; } - */ - /* @@ -891,21 +882,19 @@ void Head::updateAvatarSkeleton() avatar.bone[b].offsetPosition += diff * 0.1; } */ - - } - -//------------------------------- +//------------------------------ void Head::updateAvatarSprings() { -printf( "listing bone parent springyPosition:\n" ); + //printf( "listing bone parent springyPosition:\n" ); for (int b=0; b 0.0) hand->setPos(handPos); } diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 1b5c4abf70..051b9501b6 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -108,7 +108,7 @@ int starsTiles = 20; double starsLod = 1.0; #endif -bool showingVoxels = true; +bool showingVoxels = false; glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE); From a523a24c237d26936a645f7b310cac1191f804df Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 10 Apr 2013 15:00:28 -0700 Subject: [PATCH 12/13] fixed hand motion stuff --- interface/src/Head.cpp | 65 +++++++++++++++++++++++++++++++++--------- interface/src/Head.h | 4 ++- interface/src/main.cpp | 4 +-- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 88efc9b2e8..a9537c0e14 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -85,7 +85,9 @@ Head::Head() browAudioLift = 0.0; noise = 0; - handOffset = glm::vec3( 0.0, 0.0, 0.0 ); + mouseMovedHand = false; + //movedHandPosition = glm::vec3( 0.0, 0.0, 0.0 ); + movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); sphere = NULL; @@ -662,7 +664,29 @@ void Head::renderHead( int faceToFace, int isMine ) //--------------------------------------------------------- void Head::setHandMovement( glm::vec3 movement ) { - handOffset = glm::vec3( movement.x, -movement.y, movement.z ); + //float x = movement.x; + //float y = movement.y; + //float z = movement.z; + + //movedHandPosition = avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position + movement * 0.1f; + + + /* + float x = glm::dot( movement.x, (float)avatar.bone[b].orientation.getRight ().x ) + + glm::dot( movement.y, (float)avatar.bone[b].orientation.getRight ().y ) + + glm::dot( movement.z, (float)avatar.bone[b].orientation.getRight ().z ); + + float y = glm::dot( movement.x, (float)avatar.bone[b].orientation.getUp ().x ) + + glm::dot( movement.y, (float)avatar.bone[b].orientation.getUp ().y ) + + glm::dot( movement.z, (float)avatar.bone[b].orientation.getUp ().z ); + + float z = glm::dot( movement.x, (float)avatar.bone[b].orientation.getFront ().x ) + + glm::dot( movement.y, (float)avatar.bone[b].orientation.getFront ().y ) + + glm::dot( movement.z, (float)avatar.bone[b].orientation.getFront ().z ); + */ + + mouseMovedHand = true; + movedHandOffset = movement; } @@ -858,7 +882,11 @@ void Head::updateAvatarSkeleton() //------------------------------------------------------------------------ // reset hand and elbow position according to hand movement //------------------------------------------------------------------------ - updateHandMovement(); + if ( mouseMovedHand ) + { + updateHandMovement(); + mouseMovedHand = false; + } glm::dvec3 v( avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position ); v -= avatar.bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].position; @@ -1004,10 +1032,7 @@ glm::vec3 Head::getBodyPosition() //----------------------------- void Head::updateHandMovement() { - //---------------------------------------------------------------- - // adjust right hand and elbow according to hand offset - //---------------------------------------------------------------- - avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position += handOffset; + avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position += movedHandOffset; glm::vec3 armVector = avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position; armVector -= avatar.bone[ AVATAR_BONE_RIGHT_SHOULDER ].position; @@ -1170,7 +1195,7 @@ int Head::getBroadcastData(char* data) void Head::parseData(void *data, int size) { // parse head data for this agent - glm::vec3 handPos( 0,0,0 ); + //glm::vec3 handPos( 0,0,0 ); sscanf ( @@ -1178,16 +1203,28 @@ void Head::parseData(void *data, int size) &Pitch, &Yaw, &Roll, &position.x, &position.y, &position.z, &loudness, &averageLoudness, - &handPos.x, - &handPos.y, - &handPos.z + &avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x, + &avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.y, + &avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.z ); - - handOffset = glm::vec3( handPos.x, handPos.y, handPos.z ); - if (glm::length(handPos) > 0.0) hand->setPos(handPos); + mouseMovedHand = true; + + /* + movedHandPosition = glm::vec3 + ( + handPos.x - avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x, + handPos.y - avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.y, + handPos.z - avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.z + ); + */ + + //if (glm::length(handPos) > 0.0) hand->setPos(handPos); } + + + //--------------------------------------------------- void Head::SetNewHeadTarget(float pitch, float yaw) { diff --git a/interface/src/Head.h b/interface/src/Head.h index e0cf0dac64..3255e9855a 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -239,7 +239,9 @@ class Head : public AgentData { glm::vec3 velocity; glm::vec3 thrust; - glm::vec3 handOffset; + bool mouseMovedHand; + glm::vec3 movedHandOffset; + //glm::vec3 movedHandPosition; int driveKeys[MAX_DRIVE_KEYS]; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index bf0a3931f3..b5246f692f 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -1065,8 +1065,8 @@ void idle(void) float xOffset = ( mouseX - mouseStartX ) / (double)WIDTH; float yOffset = ( mouseY - mouseStartY ) / (double)HEIGHT; - float leftRight = xOffset; - float downUp = yOffset; + float leftRight = xOffset; + float downUp = -yOffset; float backFront = 0.0; glm::vec3 handMovement( leftRight, downUp, backFront ); From 5d1f11e41397d69d81195958b4c7be5e1e4fa3f2 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Apr 2013 15:02:31 -0700 Subject: [PATCH 13/13] fixed bug in frustrum direction, added viewing offset mode --- interface/src/main.cpp | 61 ++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index b5246f692f..be89c0c4f8 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -155,6 +155,12 @@ VoxelDetail paintingVoxel; // The voxel we're painting if we're painting unsigned char dominantColor = 0; // The dominant color of the voxel we're painting bool perfStatsOn = false; // Do we want to display perfStats? bool frustumOn = false; // Whether or not to display the debug view frustum + +bool viewFrustumFromOffset=false; // Wether or not to offset the view of the frustum +float viewFrustumOffsetYaw = -90.0; +float viewFrustumOffsetPitch = 7.5; +float viewFrustumOffsetRoll = 0.0; + int noiseOn = 0; // Whether to add random noise float noise = 1.0; // Overall magnitude scaling for random noise levels @@ -522,8 +528,11 @@ void render_view_frustum() { glm::vec3 up = myAvatar.getHeadLookatDirectionUp(); glm::vec3 right = myAvatar.getHeadLookatDirectionRight(); - float nearDist = 0.1; - float farDist = 1.0; + + // what? this are negative?? GRRRR!!! + float nearDist = -0.1; + float farDist = -1.0; + float fovHalfAngle = 0.7854f; // 45 deg for half, so fov = 90 deg float screenWidth = ::WIDTH; // These values come from reshape() @@ -643,8 +652,7 @@ void display(void) //-------------------------------------------------------- myCamera.setTargetPosition( myAvatar.getPos() ); - if ( displayHead ) - { + if ( displayHead ) { //----------------------------------------------- // set the camera to looking at my own face //----------------------------------------------- @@ -655,19 +663,29 @@ void display(void) myCamera.setDistance( 0.5 ); myCamera.setDistance( 0.08 ); myCamera.update(); - } - else - { - //---------------------------------------------------- - // set the camera to third-person view behind my av - //---------------------------------------------------- - myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() ); - myCamera.setPitch ( 0.0 ); - myCamera.setRoll ( 0.0 ); - myCamera.setUp ( 0.2 ); - myCamera.setDistance( 1.6 ); - myCamera.setDistance( 0.5 ); - myCamera.update(); + } else { + if (::viewFrustumFromOffset && ::frustumOn) { + //---------------------------------------------------- + // set the camera to third-person view but offset so we can see the frustum + //---------------------------------------------------- + myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw ); + myCamera.setPitch ( 0.0 + ::viewFrustumOffsetPitch ); + myCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll ); + myCamera.setUp ( 0.2 + 0.2 ); + myCamera.setDistance( 0.5 + 0.2 ); + myCamera.update(); + } else { + //---------------------------------------------------- + // set the camera to third-person view behind my av + //---------------------------------------------------- + myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() ); + myCamera.setPitch ( 0.0 ); + myCamera.setRoll ( 0.0 ); + myCamera.setUp ( 0.2 ); + myCamera.setDistance( 1.6 ); + myCamera.setDistance( 0.5 ); + myCamera.update(); + } } //--------------------------------------------- @@ -964,6 +982,15 @@ void key(unsigned char k, int x, int y) if (k == '*') ::starsOn = !::starsOn; // toggle stars if (k == 'V') ::showingVoxels = !::showingVoxels; // toggle voxels if (k == 'F') ::frustumOn = !::frustumOn; // toggle view frustum debugging + if (k == 'G') ::viewFrustumFromOffset = !::viewFrustumFromOffset; // toggle view frustum from offset debugging + + if (k == '[') ::viewFrustumOffsetYaw -= 0.5; + if (k == ']') ::viewFrustumOffsetYaw += 0.5; + if (k == '{') ::viewFrustumOffsetPitch -= 0.5; + if (k == '}') ::viewFrustumOffsetPitch += 0.5; + if (k == '(') ::viewFrustumOffsetRoll -= 0.5; + if (k == ')') ::viewFrustumOffsetRoll += 0.5; + if (k == '&') { ::paintOn = !::paintOn; // toggle paint ::setupPaintingVoxel(); // also randomizes colors