History

#19171 merge with master

vincent committed 13 years ago

Commit cd1aa992 parents 4dbff46 5d1f11e9 files · +336 −236Browse files

Showing the changes to interface/src/main.cpp (1 of 9 files). Show all

Unified · Split

interface/src/main.cpp+174−177
@@ -99,7 +99,7 @@ bool wantColorRandomizer = true; // for addSphere and load file · 98 unmodified lines
9999
100100 Oscilloscope audioScope(256,200,true);
101101
102−Head myHead; // The rendered head of oneself
102+Head myAvatar; // The rendered avatar of oneself
103103 Camera myCamera; // My view onto the world (sometimes on myself :)
104104
105105 // Starfield information
@@ -123,7 +123,7 @@ ParticleSystem balls(0, · 17 unmodified lines
123123 0.0 // Gravity
124124 );
125125
126−Cloud cloud(0, // Particles
126+Cloud cloud(0, // Particles
127127 box, // Bounding Box
128128 false // Wrap
129129 );
@@ -135,7 +135,7 @@ Finger myFinger(WIDTH, HEIGHT); · 5 unmodified lines
135135 Field field;
136136
137137 #ifndef _WIN32
138−Audio audio(&audioScope, &myHead);
138+Audio audio(&audioScope, &myAvatar);
139139 #endif
140140
141141 #define IDLE_SIMULATE_MSECS 8 // How often should call simulate and other stuff
@@ -157,6 +157,13 @@ bool paintOn = false; // Whether to paint voxels as you fly around · 15 unmodified lines
157157 VoxelDetail paintingVoxel; // The voxel we're painting if we're painting
158158 unsigned char dominantColor = 0; // The dominant color of the voxel we're painting
159159 bool perfStatsOn = false; // Do we want to display perfStats?
160+bool frustumOn = false; // Whether or not to display the debug view frustum
161+
162+bool viewFrustumFromOffset=false; // Wether or not to offset the view of the frustum
163+float viewFrustumOffsetYaw = -90.0;
164+float viewFrustumOffsetPitch = 7.5;
165+float viewFrustumOffsetRoll = 0.0;
166+
160167 int noiseOn = 0; // Whether to add random noise
161168 float noise = 1.0; // Overall magnitude scaling for random noise levels
162169
@@ -182,10 +189,8 @@ SerialInterface serialPort; · 19 unmodified lines
182189 int latency_display = 1;
183190
184191 glm::vec3 gravity;
185−int first_measurement = 1;
186−//int samplecount = 0;
187192
188−// Frame rate Measurement
193+// Frame Rate Measurement
189194
190195 int frameCount = 0;
191196 float FPS = 120.f;
@@ -193,12 +198,6 @@ timeval timerStart, timerEnd; · 1 unmodified line
193198 timeval lastTimeIdle;
194199 double elapsedTime;
195200
196−// Particles
197−
198−
199−float particle_attenuation_quadratic[] = { 0.0f, 0.0f, 2.0f }; // larger Z = smaller particles
200−float pointer_attenuation_quadratic[] = { 1.0f, 0.0f, 0.0f }; // for 2D view
201−
202201 #ifdef MARKER_CAPTURE
203202
204203 /*** Marker Capture ***/
@@ -250,11 +249,11 @@ void displayStats(void) · 45 unmodified lines
250249 char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
251250 drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2);
252251
253− glm::vec3 headPos = myHead.getPos();
252+ glm::vec3 avatarPos = myAvatar.getPos();
254253
255254 char stats[200];
256255 sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)=( %f , %f , %f )",
257− FPS, packetsPerSecond, bytesPerSecond, headPos.x,headPos.y,headPos.z);
256+ FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z);
258257 drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats);
259258 if (serialPort.active) {
260259 sprintf(stats, "ADC samples = %d, LED = %d",
@@ -262,14 +261,6 @@ void displayStats(void) · 1 unmodified line
262261 drawtext(300, statsVerticalOffset + 30, 0.10f, 0, 1.0, 0, stats);
263262 }
264263
265− // Output the ping times to the various agents
266−// std::stringstream pingTimes;
267−// pingTimes << "Agent Pings, msecs:";
268−// for (int i = 0; i < getAgentCount(); i++) {
269−// pingTimes << " " << getAgentAddress(i) << ": " << getAgentPing(i);
270−// }
271−// drawtext(10,50,0.10, 0, 1.0, 0, (char *)pingTimes.str().c_str());
272−
273264 std::stringstream voxelStats;
274265 voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered();
275266 drawtext(10, statsVerticalOffset + 70, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
@@ -330,8 +321,8 @@ void initDisplay(void) · 54 unmodified lines
330321 void init(void)
331322 {
332323 voxels.init();
333− voxels.setViewerHead(&myHead);
334− myHead.setRenderYaw(startYaw);
324+ voxels.setViewerHead(&myAvatar);
325+ myAvatar.setRenderYaw(startYaw);
335326
336327 headMouseX = WIDTH/2;
337328 headMouseY = HEIGHT/2;
@@ -342,9 +333,9 @@ void init(void) · 4 unmodified lines
342333 field = Field();
343334
344335 if (noiseOn) {
345− myHead.setNoise(noise);
336+ myAvatar.setNoise(noise);
346337 }
347− myHead.setPos(start_location );
338+ myAvatar.setPos(start_location );
348339 myCamera.setPosition( start_location );
349340
350341 #ifdef MARKER_CAPTURE
@@ -381,15 +372,15 @@ void reset_sensors() · 30 unmodified lines
381372 //
382373 // Reset serial I/O sensors
383374 //
384− myHead.setRenderYaw(startYaw);
375+ myAvatar.setRenderYaw(startYaw);
385376
386377 yaw = renderYawRate = 0;
387378 pitch = renderPitch = renderPitchRate = 0;
388− myHead.setPos(start_location);
379+ myAvatar.setPos(start_location);
389380 headMouseX = WIDTH/2;
390381 headMouseY = HEIGHT/2;
391382
392− myHead.reset();
383+ myAvatar.reset();
393384
394385 if (serialPort.active) {
395386 serialPort.resetTrailingAverages();
@@ -405,7 +396,7 @@ void simulateHand(float deltaTime) { · 9 unmodified lines
405396 float dx = mouseX - mouseStartX;
406397 float dy = mouseY - mouseStartY;
407398 glm::vec3 vel(dx*MOUSE_HAND_FORCE, -dy*MOUSE_HAND_FORCE*(WIDTH/HEIGHT), 0);
408− myHead.hand->addVelocity(vel*deltaTime);
399+ myAvatar.hand->addVelocity(vel*deltaTime);
409400 }
410401 }
411402
@@ -421,12 +412,12 @@ void simulateHead(float frametime) · 9 unmodified lines
421412 //float measured_lateral_accel = serialPort.getRelativeValue(ACCEL_X);
422413 //float measured_fwd_accel = serialPort.getRelativeValue(ACCEL_Z);
423414
424− myHead.UpdatePos(frametime, &serialPort, headMirror, &gravity);
415+ myAvatar.UpdatePos(frametime, &serialPort, headMirror, &gravity);
425416
426417 //-------------------------------------------------------------------------------------
427418 // set the position of the avatar
428419 //-------------------------------------------------------------------------------------
429− myHead.setAvatarPosition( -myHead.getPos().x, -myHead.getPos().y, -myHead.getPos().z );
420+ myAvatar.setAvatarPosition( -myAvatar.getPos().x, -myAvatar.getPos().y, -myAvatar.getPos().z );
430421
431422 // Update head_mouse model
432423 const float MIN_MOUSE_RATE = 30.0;
@@ -451,8 +442,8 @@ void simulateHead(float frametime) · 18 unmodified lines
451442
452443 // Update render pitch and yaw rates based on keyPositions
453444 const float KEY_YAW_SENSITIVITY = 2.0;
454− if (myHead.getDriveKeys(ROT_LEFT)) renderYawRate -= KEY_YAW_SENSITIVITY*frametime;
455− if (myHead.getDriveKeys(ROT_RIGHT)) renderYawRate += KEY_YAW_SENSITIVITY*frametime;
445+ if (myAvatar.getDriveKeys(ROT_LEFT)) renderYawRate -= KEY_YAW_SENSITIVITY*frametime;
446+ if (myAvatar.getDriveKeys(ROT_RIGHT)) renderYawRate += KEY_YAW_SENSITIVITY*frametime;
456447
457448 if (fabs(measured_yaw_rate) > MIN_YAW_RATE)
458449 {
@@ -479,32 +470,32 @@ void simulateHead(float frametime) · 20 unmodified lines
479470 renderYawRate *= (1.f - 7.0*frametime);
480471
481472 // Update own head data
482− myHead.setRenderYaw(myHead.getRenderYaw() + renderYawRate);
483− myHead.setRenderPitch(renderPitch);
473+ myAvatar.setRenderYaw(myAvatar.getRenderYaw() + renderYawRate);
474+ myAvatar.setRenderPitch(renderPitch);
484475
485476 // Get audio loudness data from audio input device
486477 float loudness, averageLoudness;
487478 #ifndef _WIN32
488479 audio.getInputLoudness(&loudness, &averageLoudness);
489− myHead.setLoudness(loudness);
490− myHead.setAverageLoudness(averageLoudness);
480+ myAvatar.setLoudness(loudness);
481+ myAvatar.setAverageLoudness(averageLoudness);
491482 #endif
492483
493484 // Send my streaming head data to agents that are nearby and need to see it!
494485 const int MAX_BROADCAST_STRING = 200;
495486 char broadcast_string[MAX_BROADCAST_STRING];
496− int broadcast_bytes = myHead.getBroadcastData(broadcast_string);
487+ int broadcast_bytes = myAvatar.getBroadcastData(broadcast_string);
497488 agentList.broadcastToAgents(broadcast_string, broadcast_bytes,AgentList::AGENTS_OF_TYPE_VOXEL_AND_INTERFACE);
498489
499490 // If I'm in paint mode, send a voxel out to VOXEL server agents.
500491 if (::paintOn) {
501492
502− glm::vec3 headPos = myHead.getPos();
493+ glm::vec3 avatarPos = myAvatar.getPos();
503494
504495 // For some reason, we don't want to flip X and Z here.
505− ::paintingVoxel.x = headPos.x/-10.0;
506− ::paintingVoxel.y = headPos.y/-10.0;
507− ::paintingVoxel.z = headPos.z/-10.0;
496+ ::paintingVoxel.x = avatarPos.x/-10.0;
497+ ::paintingVoxel.y = avatarPos.y/-10.0;
498+ ::paintingVoxel.z = avatarPos.z/-10.0;
508499
509500 unsigned char* bufferOut;
510501 int sizeOut;
@@ -521,6 +512,9 @@ void simulateHead(float frametime) · 10 unmodified lines
521512 }
522513 }
523514
515+
516+
517+
524518 // XXXBHG - this code is not yet working. This is here to help Jeffery debug getAvatarHeadLookatDirection()
525519 // The code will draw a yellow line from the avatar's position to the origin,
526520 // It also attempts to draw a cyan line from the avatar to 2 meters in front of the avatar in the direction
@@ -538,117 +532,105 @@ void render_view_frustum() { · 11 unmodified lines
538532 // farDist – the distance from the camera to the far plane
539533 // farHeight – the height of the far plane
540534 // farWidth – the width of the far plane
541−
542− glm::vec3 cameraPosition = ::myHead.getPos()*-1.0; // We need to flip the sign to make this work.
543− glm::vec3 cameraDirection = ::myHead.getAvatarHeadLookatDirection()*-1.0; // gak! Not sure if this is correct!
544535
545− // this is a temporary test, create a vertice that's 2 meters in front of avatar in direction their looking
546− glm::vec3 lookingAt = cameraPosition+(cameraDirection*2.0);
547−
548− // Some debug lines.
549− glDisable(GL_LIGHTING);
550− glColor4f(1.0, 1.0, 1.0, 1.0);
551− glLineWidth(1.0);
552− glBegin(GL_LINES);
553−
554− // line from avatar to the origin -- this one is working.
555− glColor3f(1,1,0);
556− glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z);
557− glVertex3f(0,0,0);
558−
559− // line from avatar to 2 meters in front of avatar -- this is NOT working
560− glColor3f(0,1,1);
561− glVertex3f(cameraPosition.x,cameraPosition.y,cameraPosition.z);
562− glVertex3f(lookingAt.x,lookingAt.y,lookingAt.z);
563−
564− /*
565− // Not yet ready for this...
566− glm::vec3 up = glm::vec3(0.0,1.0,0.0);
567− glm::vec3 right = glm::vec3(1.0,0.0,0.0);
568− float nearDist = 0.1;
569− float farDist = 500.0;
570− float fov = (0.7854f*2.0); // 45 deg * 2 = 90 deg
536+ glm::vec3 viewFrustumPosition = myAvatar.getHeadPosition();
537+ glm::vec3 viewFrustumDirection = myAvatar.getHeadLookatDirection();
538+
539+ glm::vec3 up = myAvatar.getHeadLookatDirectionUp();
540+ glm::vec3 right = myAvatar.getHeadLookatDirectionRight();
541+
542+ // what? this are negative?? GRRRR!!!
543+ float nearDist = -0.1;
544+ float farDist = -1.0;
571545
572− float screenWidth = 800.0; // hack! We need to make this eventually be the correct height/width
573− float screenHeight = 600.0;
546+ float fovHalfAngle = 0.7854f; // 45 deg for half, so fov = 90 deg
547+
548+ float screenWidth = ::WIDTH; // These values come from reshape()
549+ float screenHeight = ::HEIGHT;
574550 float ratio = screenWidth/screenHeight;
575− float nearHeight = 2 * tan(fov / 2) * nearDist;
551+
552+ float nearHeight = 2 * tan(fovHalfAngle) * nearDist;
576553 float nearWidth = nearHeight * ratio;
577− float farHeight = 2 * tan(fov / 2) * farDist;
554+ float farHeight = 2 * tan(fovHalfAngle) * farDist;
578555 float farWidth = farHeight * ratio;
579556
580− glm::vec3 farCenter = cameraPosition+cameraDirection*farDist;
557+ glm::vec3 farCenter = viewFrustumPosition+viewFrustumDirection*farDist;
581558 glm::vec3 farTopLeft = farCenter + (up*farHeight*0.5) - (right*farWidth*0.5);
582559 glm::vec3 farTopRight = farCenter + (up*farHeight*0.5) + (right*farWidth*0.5);
583560 glm::vec3 farBottomLeft = farCenter - (up*farHeight*0.5) - (right*farWidth*0.5);
584561 glm::vec3 farBottomRight = farCenter - (up*farHeight*0.5) + (right*farWidth*0.5);
585562
586− glm::vec3 nearCenter = cameraPosition+cameraDirection*nearDist;
563+ glm::vec3 nearCenter = viewFrustumPosition+viewFrustumDirection*nearDist;
587564 glm::vec3 nearTopLeft = nearCenter + (up*nearHeight*0.5) - (right*nearWidth*0.5);
588565 glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5);
589566 glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5);
590567 glm::vec3 nearBottomRight = nearCenter - (up*nearHeight*0.5) + (right*nearWidth*0.5);
591− */
592−
593568
594−/*
595− glColor3f(1,1,1);
569+ // Get ready to draw some lines
570+ glDisable(GL_LIGHTING);
571+ glColor4f(1.0, 1.0, 1.0, 1.0);
572+ glLineWidth(1.0);
573+ glBegin(GL_LINES);
596574
597575 // near plane - bottom edge
598− glVertex3f(low.x,low.y,low.z);
599− glVertex3f(high.x,low.y,low.z);
576+ glColor3f(1,0,0);
577+ glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z);
578+ glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z);
600579
601580 // near plane - top edge
602− glVertex3f(low.x,high.y,low.z);
603− glVertex3f(high.x,high.y,low.z);
581+ glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z);
582+ glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z);
604583
605584 // near plane - right edge
606− glVertex3f(low.x,high.y,low.z);
607− glVertex3f(low.x,low.y,low.z);
585+ glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z);
586+ glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z);
608587
609588 // near plane - left edge
610− glVertex3f(high.x,high.y,low.z);
611− glVertex3f(high.x,low.y,low.z);
589+ glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z);
590+ glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z);
612591
613592 // far plane - bottom edge
614− glVertex3f(low.x,low.y,high.z);
615− glVertex3f(high.x,low.y,high.z);
616−
593+ glColor3f(0,1,0); // GREEN!!!
594+ glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z);
595+ glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z);
596+
617597 // far plane - top edge
618− glVertex3f(low.x,high.y,high.z);
619− glVertex3f(high.x,high.y,high.z);
598+ glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z);
599+ glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z);
620600
621601 // far plane - right edge
622− glVertex3f(low.x,high.y,high.z);
623− glVertex3f(low.x,low.y,high.z);
602+ glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z);
603+ glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z);
624604
625605 // far plane - left edge
626− glVertex3f(high.x,high.y,high.z);
627− glVertex3f(high.x,low.y,high.z);
606+ glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z);
607+ glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z);
628608
629609 // right plane - bottom edge - near to distant
630− glVertex3f(low.x,low.y,low.z);
631− glVertex3f(low.x,low.y,high.z);
610+ glColor3f(0,0,1);
611+ glVertex3f(nearBottomRight.x,nearBottomRight.y,nearBottomRight.z);
612+ glVertex3f(farBottomRight.x,farBottomRight.y,farBottomRight.z);
632613
633614 // right plane - top edge - near to distant
634− glVertex3f(low.x,high.y,low.z);
635− glVertex3f(low.x,high.y,high.z);
615+ glVertex3f(nearTopRight.x,nearTopRight.y,nearTopRight.z);
616+ glVertex3f(farTopRight.x,farTopRight.y,farTopRight.z);
636617
637618 // left plane - bottom edge - near to distant
638− glVertex3f(high.x,low.y,low.z);
639− glVertex3f(high.x,low.y,high.z);
619+ glColor3f(0,1,1);
620+ glVertex3f(nearBottomLeft.x,nearBottomLeft.y,nearBottomLeft.z);
621+ glVertex3f(farBottomLeft.x,farBottomLeft.y,farBottomLeft.z);
640622
641623 // left plane - top edge - near to distant
642− glVertex3f(high.x,high.y,low.z);
643− glVertex3f(high.x,high.y,high.z);
644−*/
624+ glVertex3f(nearTopLeft.x,nearTopLeft.y,nearTopLeft.z);
625+ glVertex3f(farTopLeft.x,farTopLeft.y,farTopLeft.z);
626+
645627 glEnd();
646628 }
647629
648630
649631 void display(void)
650632 {
651− //printf( "avatar head lookat = %f, %f, %f\n", myHead.getAvatarHeadLookatDirection().x, myHead.getAvatarHeadLookatDirection().y, myHead.getAvatarHeadLookatDirection().z );
633+ //printf( "avatar head lookat = %f, %f, %f\n", myAvatar.getAvatarHeadLookatDirection().x, myAvatar.getAvatarHeadLookatDirection().y, myAvatar.getAvatarHeadLookatDirection().z );
652634
653635 PerfStat("display");
654636
@@ -678,33 +660,42 @@ void display(void) · 23 unmodified lines
678660 //--------------------------------------------------------
679661 // camera settings
680662 //--------------------------------------------------------
681− myCamera.setTargetPosition( myHead.getPos() );
663+ myCamera.setTargetPosition( myAvatar.getPos() );
682664
683− if ( displayHead )
684− {
665+ if ( displayHead ) {
685666 //-----------------------------------------------
686667 // set the camera to looking at my own face
687668 //-----------------------------------------------
688− myCamera.setYaw ( - myHead.getAvatarYaw() );
669+ myCamera.setYaw ( - myAvatar.getBodyYaw() );
689670 myCamera.setPitch ( 0.0 );
690671 myCamera.setRoll ( 0.0 );
691672 myCamera.setUp ( 0.4 );
692673 myCamera.setDistance( 0.5 );
693674 myCamera.setDistance( 0.08 );
694675 myCamera.update();
695− }
696− else
697− {
698− //----------------------------------------------------
699− // set the camera to third-person view behind my av
700− //----------------------------------------------------
701− myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() );
702− myCamera.setPitch ( 0.0 );
703− myCamera.setRoll ( 0.0 );
704− myCamera.setUp ( 0.2 );
705− myCamera.setDistance( 1.6 );
706− myCamera.setDistance( 0.5 );
707− myCamera.update();
676+ } else {
677+ if (::viewFrustumFromOffset && ::frustumOn) {
678+ //----------------------------------------------------
679+ // set the camera to third-person view but offset so we can see the frustum
680+ //----------------------------------------------------
681+ myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw );
682+ myCamera.setPitch ( 0.0 + ::viewFrustumOffsetPitch );
683+ myCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll );
684+ myCamera.setUp ( 0.2 + 0.2 );
685+ myCamera.setDistance( 0.5 + 0.2 );
686+ myCamera.update();
687+ } else {
688+ //----------------------------------------------------
689+ // set the camera to third-person view behind my av
690+ //----------------------------------------------------
691+ myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() );
692+ myCamera.setPitch ( 0.0 );
693+ myCamera.setRoll ( 0.0 );
694+ myCamera.setUp ( 0.2 );
695+ myCamera.setDistance( 1.6 );
696+ myCamera.setDistance( 0.5 );
697+ myCamera.update();
698+ }
708699 }
709700
710701 //---------------------------------------------
@@ -737,7 +728,7 @@ void display(void) · 26 unmodified lines
737728 //---------------------------------------------
738729 // draw a grid gound plane....
739730 //---------------------------------------------
740− //drawGroundPlaneGrid( 5.0f, 9 );
731+ drawGroundPlaneGrid( 5.0f, 9 );
741732
742733
743734 // Draw cloud of dots
@@ -754,7 +745,7 @@ void display(void) · 10 unmodified lines
754745 // Draw field vectors
755746 if (displayField) field.render();
756747
757− // Render heads of other agents
748+ // Render avatars of other agents
758749 for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++)
759750 {
760751 if (agent->getLinkedData() != NULL)
@@ -774,19 +765,19 @@ void display(void) · 13 unmodified lines
774765 if (!displayHead && statsOn) render_world_box();
775766
776767 // brad's frustum for debugging
777− render_view_frustum();
768+ if (::frustumOn) render_view_frustum();
778769
779770
780771 //---------------------------------
781− // Render my own head
772+ // Render my own avatar
782773 //---------------------------------
783− myHead.render( true, 1 );
774+ myAvatar.render( true, 1 );
784775
785776 /*
786777 glPushMatrix();
787778 glLoadIdentity();
788779 glTranslatef(0.f, 0.f, -7.f);
789− myHead.render(displayHead, 1);
780+ myAvatar.render(displayHead, 1);
790781 glPopMatrix();
791782 */
792783
@@ -809,10 +800,6 @@ void display(void) · 16 unmodified lines
809800 if (audioScope.getState()) audioScope.render();
810801 #endif
811802
812−
813− //drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0);
814− glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic );
815−
816803 if (displayHeadMouse && !displayHead && statsOn)
817804 {
818805 // Display small target box at center or head mouse target that can also be used to measure LOD
@@ -890,9 +877,9 @@ int MenuCallBack setField(int state) { · 71 unmodified lines
890877 int MenuCallBack setNoise(int state) {
891878 int iRet = setValue(state, &noiseOn);
892879 if (noiseOn) {
893− myHead.setNoise(noise);
880+ myAvatar.setNoise(noise);
894881 } else {
895− myHead.setNoise(0);
882+ myAvatar.setNoise(0);
896883 }
897884 return iRet;
898885 }
@@ -966,11 +953,11 @@ void shiftPaintingColor() · 67 unmodified lines
966953
967954 void setupPaintingVoxel()
968955 {
969− glm::vec3 headPos = myHead.getPos();
956+ glm::vec3 avatarPos = myAvatar.getPos();
970957
971− ::paintingVoxel.x = headPos.z/-10.0; // voxel space x is negative z head space
972− ::paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space
973− ::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space
958+ ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space
959+ ::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space
960+ ::paintingVoxel.z = avatarPos.x/-10.0; // voxel space z is negative x head space
974961 ::paintingVoxel.s = 1.0/256;
975962
976963 shiftPaintingColor();
@@ -1002,20 +989,20 @@ const float KEYBOARD_FLY_RATE = 0.08; · 25 unmodified lines
1002989
1003990 void specialkeyUp(int k, int x, int y) {
1004991 if (k == GLUT_KEY_UP) {
1005− myHead.setDriveKeys(FWD, 0);
1006− myHead.setDriveKeys(UP, 0);
992+ myAvatar.setDriveKeys(FWD, 0);
993+ myAvatar.setDriveKeys(UP, 0);
1007994 }
1008995 if (k == GLUT_KEY_DOWN) {
1009− myHead.setDriveKeys(BACK, 0);
1010− myHead.setDriveKeys(DOWN, 0);
996+ myAvatar.setDriveKeys(BACK, 0);
997+ myAvatar.setDriveKeys(DOWN, 0);
1011998 }
1012999 if (k == GLUT_KEY_LEFT) {
1013− myHead.setDriveKeys(LEFT, 0);
1014− myHead.setDriveKeys(ROT_LEFT, 0);
1000+ myAvatar.setDriveKeys(LEFT, 0);
1001+ myAvatar.setDriveKeys(ROT_LEFT, 0);
10151002 }
10161003 if (k == GLUT_KEY_RIGHT) {
1017− myHead.setDriveKeys(RIGHT, 0);
1018− myHead.setDriveKeys(ROT_RIGHT, 0);
1004+ myAvatar.setDriveKeys(RIGHT, 0);
1005+ myAvatar.setDriveKeys(ROT_RIGHT, 0);
10191006 }
10201007
10211008 }
@@ -1024,20 +1011,20 @@ void specialkey(int k, int x, int y) · 2 unmodified lines
10241011 {
10251012 if (k == GLUT_KEY_UP || k == GLUT_KEY_DOWN || k == GLUT_KEY_LEFT || k == GLUT_KEY_RIGHT) {
10261013 if (k == GLUT_KEY_UP) {
1027− if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(UP, 1);
1028− else myHead.setDriveKeys(FWD, 1);
1014+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(UP, 1);
1015+ else myAvatar.setDriveKeys(FWD, 1);
10291016 }
10301017 if (k == GLUT_KEY_DOWN) {
1031− if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(DOWN, 1);
1032− else myHead.setDriveKeys(BACK, 1);
1018+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(DOWN, 1);
1019+ else myAvatar.setDriveKeys(BACK, 1);
10331020 }
10341021 if (k == GLUT_KEY_LEFT) {
1035− if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(LEFT, 1);
1036− else myHead.setDriveKeys(ROT_LEFT, 1);
1022+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(LEFT, 1);
1023+ else myAvatar.setDriveKeys(ROT_LEFT, 1);
10371024 }
10381025 if (k == GLUT_KEY_RIGHT) {
1039− if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(RIGHT, 1);
1040− else myHead.setDriveKeys(ROT_RIGHT, 1);
1026+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(RIGHT, 1);
1027+ else myAvatar.setDriveKeys(ROT_RIGHT, 1);
10411028 }
10421029 #ifndef _WIN32
10431030 audio.setWalkingState(true);
@@ -1047,12 +1034,12 @@ void specialkey(int k, int x, int y) · 3 unmodified lines
10471034
10481035
10491036 void keyUp(unsigned char k, int x, int y) {
1050− if (k == 'e') myHead.setDriveKeys(UP, 0);
1051− if (k == 'c') myHead.setDriveKeys(DOWN, 0);
1052− if (k == 'w') myHead.setDriveKeys(FWD, 0);
1053− if (k == 's') myHead.setDriveKeys(BACK, 0);
1054− if (k == 'a') myHead.setDriveKeys(ROT_LEFT, 0);
1055− if (k == 'd') myHead.setDriveKeys(ROT_RIGHT, 0);
1037+ if (k == 'e') myAvatar.setDriveKeys(UP, 0);
1038+ if (k == 'c') myAvatar.setDriveKeys(DOWN, 0);
1039+ if (k == 'w') myAvatar.setDriveKeys(FWD, 0);
1040+ if (k == 's') myAvatar.setDriveKeys(BACK, 0);
1041+ if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 0);
1042+ if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 0);
10561043
10571044 }
10581045
@@ -1064,6 +1051,16 @@ void key(unsigned char k, int x, int y) · 5 unmodified lines
10641051 if (k == '/') statsOn = !statsOn; // toggle stats
10651052 if (k == '*') ::starsOn = !::starsOn; // toggle stars
10661053 if (k == 'V') ::showingVoxels = !::showingVoxels; // toggle voxels
1054+ if (k == 'F') ::frustumOn = !::frustumOn; // toggle view frustum debugging
1055+ if (k == 'G') ::viewFrustumFromOffset = !::viewFrustumFromOffset; // toggle view frustum from offset debugging
1056+
1057+ if (k == '[') ::viewFrustumOffsetYaw -= 0.5;
1058+ if (k == ']') ::viewFrustumOffsetYaw += 0.5;
1059+ if (k == '{') ::viewFrustumOffsetPitch -= 0.5;
1060+ if (k == '}') ::viewFrustumOffsetPitch += 0.5;
1061+ if (k == '(') ::viewFrustumOffsetRoll -= 0.5;
1062+ if (k == ')') ::viewFrustumOffsetRoll += 0.5;
1063+
10671064 if (k == '&') {
10681065 ::paintOn = !::paintOn; // toggle paint
10691066 ::setupPaintingVoxel(); // also randomizes colors
@@ -1076,11 +1073,11 @@ void key(unsigned char k, int x, int y) · 6 unmodified lines
10761073 noiseOn = !noiseOn; // Toggle noise
10771074 if (noiseOn)
10781075 {
1079− myHead.setNoise(noise);
1076+ myAvatar.setNoise(noise);
10801077 }
10811078 else
10821079 {
1083− myHead.setNoise(0);
1080+ myAvatar.setNoise(0);
10841081 }
10851082
10861083 }
@@ -1097,10 +1094,10 @@ void key(unsigned char k, int x, int y) · 10 unmodified lines
10971094
10981095 if (k == 'f') displayField = !displayField;
10991096 if (k == 'l') displayLevels = !displayLevels;
1100− if (k == 'e') myHead.setDriveKeys(UP, 1);
1101− if (k == 'c') myHead.setDriveKeys(DOWN, 1);
1102− if (k == 'w') myHead.setDriveKeys(FWD, 1);
1103− if (k == 's') myHead.setDriveKeys(BACK, 1);
1097+ if (k == 'e') myAvatar.setDriveKeys(UP, 1);
1098+ if (k == 'c') myAvatar.setDriveKeys(DOWN, 1);
1099+ if (k == 'w') myAvatar.setDriveKeys(FWD, 1);
1100+ if (k == 's') myAvatar.setDriveKeys(BACK, 1);
11041101 if (k == ' ') reset_sensors();
11051102 if (k == 't') renderPitchRate -= KEYBOARD_PITCH_RATE;
11061103 if (k == 'g') renderPitchRate += KEYBOARD_PITCH_RATE;
@@ -1111,8 +1108,8 @@ void key(unsigned char k, int x, int y) · 4 unmodified lines
11111108 if (k == 'k') if (starsLod > 0.01) starsLod = stars.changeLOD(0.99);
11121109 if (k == 'r') stars.readInput(starFile, 0);
11131110 #endif
1114− if (k == 'a') myHead.setDriveKeys(ROT_LEFT, 1);
1115− if (k == 'd') myHead.setDriveKeys(ROT_RIGHT, 1);
1111+ if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 1);
1112+ if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 1);
11161113
11171114 // press the . key to get a new random sphere of voxels added
11181115 if (k == '.') addRandomSphere(wantColorRandomizer);
@@ -1134,7 +1131,7 @@ void *networkReceive(void *args) · 15 unmodified lines
11341131
11351132 if (incomingPacket[0] == PACKET_HEADER_TRANSMITTER_DATA) {
11361133 // Pass everything but transmitter data to the agent list
1137− myHead.hand->processTransmitterData(incomingPacket, bytesReceived);
1134+ myAvatar.hand->processTransmitterData(incomingPacket, bytesReceived);
11381135 } else if (incomingPacket[0] == PACKET_HEADER_VOXEL_DATA ||
11391136 incomingPacket[0] == PACKET_HEADER_Z_COMMAND ||
11401137 incomingPacket[0] == PACKET_HEADER_ERASE_VOXEL) {
@@ -1166,12 +1163,12 @@ void idle(void) · 25 unmodified lines
11661163 float xOffset = ( mouseX - mouseStartX ) / (double)WIDTH;
11671164 float yOffset = ( mouseY - mouseStartY ) / (double)HEIGHT;
11681165
1169− float leftRight = xOffset;
1170− float downUp = yOffset;
1166+ float leftRight = xOffset;
1167+ float downUp = -yOffset;
11711168 float backFront = 0.0;
11721169
11731170 glm::vec3 handMovement( leftRight, downUp, backFront );
1174− myHead.setHandMovement( handMovement );
1171+ myAvatar.setHandMovement( handMovement );
11751172 }
11761173
11771174 // Simulation
@@ -1194,7 +1191,7 @@ void idle(void) · 16 unmodified lines
11941191 simulateHand(1.f/FPS);
11951192
11961193 field.simulate(1.f/FPS);
1197− myHead.simulate(1.f/FPS);
1194+ myAvatar.simulate(1.f/FPS);
11981195 balls.simulate(1.f/FPS);
11991196 cloud.simulate(1.f/FPS);
12001197 lattice.simulate(1.f/FPS);