History

fix rear view mirror mode to only render self

ZappoMan committed 13 years ago

Commit 161367c1 parent b1364f52 files · +149 −137Browse files

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

Unified · Split

interface/src/Application.cpp+147−135
@@ -438,13 +438,15 @@ void Application::paintGL() { · 437 unmodified lines
438 // set the bounds of rear mirror view438 // set the bounds of rear mirror view
439 glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());439 glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
440 glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());440 glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
441 updateProjectionMatrix(_mirrorCamera);441 bool updateViewFrustum = false;
442 updateProjectionMatrix(_mirrorCamera, updateViewFrustum);
442 glEnable(GL_SCISSOR_TEST);443 glEnable(GL_SCISSOR_TEST);
443 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);444 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
444 445
445 // render rear mirror view446 // render rear mirror view
446 glPushMatrix();447 glPushMatrix();
447 displaySide(_mirrorCamera);448 bool selfAvatarOnly = true;
449 displaySide(_mirrorCamera, selfAvatarOnly);
448 glPopMatrix();450 glPopMatrix();
449 451
450 // render rear view tools if mouse is in the bounds452 // render rear view tools if mouse is in the bounds
@@ -456,7 +458,7 @@ void Application::paintGL() { · 5 unmodified lines
456 // reset Viewport and projection matrix458 // reset Viewport and projection matrix
457 glViewport(0, 0, _glWidget->width(), _glWidget->height());459 glViewport(0, 0, _glWidget->width(), _glWidget->height());
458 glDisable(GL_SCISSOR_TEST);460 glDisable(GL_SCISSOR_TEST);
459 updateProjectionMatrix();461 updateProjectionMatrix(_myCamera, updateViewFrustum);
460 }462 }
461 463
462 displayOverlay();464 displayOverlay();
@@ -494,22 +496,28 @@ void Application::updateProjectionMatrix() { · 31 unmodified lines
494 updateProjectionMatrix(_myCamera);496 updateProjectionMatrix(_myCamera);
495}497}
496 498
497void Application::updateProjectionMatrix(Camera& camera) {499void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) {
498 glMatrixMode(GL_PROJECTION);500 glMatrixMode(GL_PROJECTION);
499 glLoadIdentity();501 glLoadIdentity();
500 502
501 // Tell our viewFrustum about this change, using the application camera
502 loadViewFrustum(camera, _viewFrustum);
503
504 float left, right, bottom, top, nearVal, farVal;503 float left, right, bottom, top, nearVal, farVal;
505 glm::vec4 nearClipPlane, farClipPlane;504 glm::vec4 nearClipPlane, farClipPlane;
506 computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
507 505
508 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the506 // Tell our viewFrustum about this change, using the application camera
509 // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum507 if (updateViewFrustum) {
510 if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {508 loadViewFrustum(camera, _viewFrustum);
511 nearVal = _viewFrustumOffsetCamera.getNearClip();509 computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
512 farVal = _viewFrustumOffsetCamera.getFarClip();510
511 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
512 // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum
513 if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
514 nearVal = _viewFrustumOffsetCamera.getNearClip();
515 farVal = _viewFrustumOffsetCamera.getFarClip();
516 }
517 } else {
518 ViewFrustum tempViewFrustum;
519 loadViewFrustum(camera, tempViewFrustum);
520 tempViewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
513 }521 }
514 glFrustum(left, right, bottom, top, nearVal, farVal);522 glFrustum(left, right, bottom, top, nearVal, farVal);
515 523
@@ -2508,7 +2516,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 1992 unmodified lines
2508 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);2516 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);
2509}2517}
2510 2518
2511void Application::displaySide(Camera& whichCamera) {2519void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
2512 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");2520 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
2513 // transform by eye offset2521 // transform by eye offset
2514 2522
@@ -2540,7 +2548,7 @@ void Application::displaySide(Camera& whichCamera) { · 25 unmodified lines
2540 // Setup 3D lights (after the camera transform, so that they are positioned in world space)2548 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
2541 setupWorldLight(whichCamera);2549 setupWorldLight(whichCamera);
2542 2550
2543 if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {2551 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
2544 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), 2552 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2545 "Application::displaySide() ... stars...");2553 "Application::displaySide() ... stars...");
2546 if (!_stars.isStarsLoaded()) {2554 if (!_stars.isStarsLoaded()) {
@@ -2567,7 +2575,7 @@ void Application::displaySide(Camera& whichCamera) { · 20 unmodified lines
2567 }2575 }
2568 2576
2569 // draw the sky dome2577 // draw the sky dome
2570 if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {2578 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
2571 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), 2579 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2572 "Application::displaySide() ... atmosphere...");2580 "Application::displaySide() ... atmosphere...");
2573 _environment.renderAtmospheres(whichCamera);2581 _environment.renderAtmospheres(whichCamera);
@@ -2580,122 +2588,124 @@ void Application::displaySide(Camera& whichCamera) { · 6 unmodified lines
2580 //renderLineToTouchedVoxel();2588 //renderLineToTouchedVoxel();
2581 //renderThrustAtVoxel(_voxelThrust);2589 //renderThrustAtVoxel(_voxelThrust);
2582 2590
2583 // draw a red sphere 2591 if (!selfAvatarOnly) {
2584 float sphereRadius = 0.25f;2592 // draw a red sphere
2585 glColor3f(1,0,0);2593 float sphereRadius = 0.25f;
2586 glPushMatrix();2594 glColor3f(1,0,0);
2587 glutSolidSphere(sphereRadius, 15, 15);
2588 glPopMatrix();
2589
2590 // disable specular lighting for ground and voxels
2591 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);
2592
2593 //draw a grid ground plane....
2594 if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) {
2595 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2596 "Application::displaySide() ... ground plane...");
2597
2598 // draw grass plane with fog
2599 glEnable(GL_FOG);
2600 glEnable(GL_NORMALIZE);
2601 const float FOG_COLOR[] = { 1.0f, 1.0f, 1.0f, 1.0f };
2602 glFogfv(GL_FOG_COLOR, FOG_COLOR);
2603 glFogi(GL_FOG_MODE, GL_EXP2);
2604 glFogf(GL_FOG_DENSITY, 0.025f);
2605 glPushMatrix();2595 glPushMatrix();
2606 const float GRASS_PLANE_SIZE = 256.0f;2596 glutSolidSphere(sphereRadius, 15, 15);
2607 glTranslatef(-GRASS_PLANE_SIZE * 0.5f, -0.01f, GRASS_PLANE_SIZE * 0.5f);
2608 glScalef(GRASS_PLANE_SIZE, 1.0f, GRASS_PLANE_SIZE);
2609 glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
2610 glColor3ub(70, 134, 74);
2611 const int GRASS_DIVISIONS = 40;
2612 _geometryCache.renderSquare(GRASS_DIVISIONS, GRASS_DIVISIONS);
2613 glPopMatrix();2597 glPopMatrix();
2614 glDisable(GL_FOG);2598
2615 glDisable(GL_NORMALIZE);2599 // disable specular lighting for ground and voxels
2600 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);
2601
2602 //draw a grid ground plane....
2603 if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) {
2604 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2605 "Application::displaySide() ... ground plane...");
2606
2607 // draw grass plane with fog
2608 glEnable(GL_FOG);
2609 glEnable(GL_NORMALIZE);
2610 const float FOG_COLOR[] = { 1.0f, 1.0f, 1.0f, 1.0f };
2611 glFogfv(GL_FOG_COLOR, FOG_COLOR);
2612 glFogi(GL_FOG_MODE, GL_EXP2);
2613 glFogf(GL_FOG_DENSITY, 0.025f);
2614 glPushMatrix();
2615 const float GRASS_PLANE_SIZE = 256.0f;
2616 glTranslatef(-GRASS_PLANE_SIZE * 0.5f, -0.01f, GRASS_PLANE_SIZE * 0.5f);
2617 glScalef(GRASS_PLANE_SIZE, 1.0f, GRASS_PLANE_SIZE);
2618 glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
2619 glColor3ub(70, 134, 74);
2620 const int GRASS_DIVISIONS = 40;
2621 _geometryCache.renderSquare(GRASS_DIVISIONS, GRASS_DIVISIONS);
2622 glPopMatrix();
2623 glDisable(GL_FOG);
2624 glDisable(GL_NORMALIZE);
2616 2625
2617 //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());2626 //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
2618 }2627 }
2619 // Draw Cloud Particles2628 // Draw Cloud Particles
2620 if (Menu::getInstance()->isOptionChecked(MenuOption::ParticleCloud)) {2629 if (Menu::getInstance()->isOptionChecked(MenuOption::ParticleCloud)) {
2621 _cloud.render();2630 _cloud.render();
2622 }2631 }
2623 // Draw voxels2632 // Draw voxels
2624 if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {2633 if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2625 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), 2634 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2626 "Application::displaySide() ... voxels...");2635 "Application::displaySide() ... voxels...");
2627 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontRenderVoxels)) {2636 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontRenderVoxels)) {
2628 _voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));2637 _voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
2638 }
2629 }2639 }
2630 }
2631 2640
2632 2641
2633 // restore default, white specular2642 // restore default, white specular
2634 glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);2643 glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
2635 2644
2636 // indicate what we'll be adding/removing in mouse mode, if anything2645 // indicate what we'll be adding/removing in mouse mode, if anything
2637 if (_mouseVoxel.s != 0 && whichCamera.getMode() != CAMERA_MODE_MIRROR) {2646 if (_mouseVoxel.s != 0 && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2638 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), 2647 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2639 "Application::displaySide() ... voxels TOOLS UX...");2648 "Application::displaySide() ... voxels TOOLS UX...");
2640 2649
2641 glDisable(GL_LIGHTING);2650 glDisable(GL_LIGHTING);
2642 glPushMatrix();
2643 glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
2644 if (_nudgeStarted) {
2645 renderNudgeGuide(_nudgeGuidePosition.x, _nudgeGuidePosition.y, _nudgeGuidePosition.z, _nudgeVoxel.s);
2646 renderNudgeGrid(_nudgeVoxel.x, _nudgeVoxel.y, _nudgeVoxel.z, _nudgeVoxel.s, _mouseVoxel.s);
2647 glPushMatrix();2651 glPushMatrix();
2648 glTranslatef(_nudgeVoxel.x + _nudgeVoxel.s * 0.5f,2652 glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
2649 _nudgeVoxel.y + _nudgeVoxel.s * 0.5f,2653 if (_nudgeStarted) {
2650 _nudgeVoxel.z + _nudgeVoxel.s * 0.5f);2654 renderNudgeGuide(_nudgeGuidePosition.x, _nudgeGuidePosition.y, _nudgeGuidePosition.z, _nudgeVoxel.s);
2651 glColor3ub(255, 255, 255);2655 renderNudgeGrid(_nudgeVoxel.x, _nudgeVoxel.y, _nudgeVoxel.z, _nudgeVoxel.s, _mouseVoxel.s);
2652 glLineWidth(4.0f);2656 glPushMatrix();
2653 glutWireCube(_nudgeVoxel.s);2657 glTranslatef(_nudgeVoxel.x + _nudgeVoxel.s * 0.5f,
2654 glPopMatrix();2658 _nudgeVoxel.y + _nudgeVoxel.s * 0.5f,
2655 } else {2659 _nudgeVoxel.z + _nudgeVoxel.s * 0.5f);
2656 renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);2660 glColor3ub(255, 255, 255);
2657 }2661 glLineWidth(4.0f);
2662 glutWireCube(_nudgeVoxel.s);
2663 glPopMatrix();
2664 } else {
2665 renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
2666 }
2658 2667
2659 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {2668 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {
2660 // use a contrasting color so that we can see what we're doing2669 // use a contrasting color so that we can see what we're doing
2661 glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128);2670 glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128);
2662 } else {2671 } else {
2663 glColor3ub(_mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue);2672 glColor3ub(_mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue);
2664 }2673 }
2665 2674
2666 if (_nudgeStarted) {2675 if (_nudgeStarted) {
2667 // render nudge guide cube2676 // render nudge guide cube
2668 glTranslatef(_nudgeGuidePosition.x + _nudgeVoxel.s*0.5f,2677 glTranslatef(_nudgeGuidePosition.x + _nudgeVoxel.s*0.5f,
2669 _nudgeGuidePosition.y + _nudgeVoxel.s*0.5f,2678 _nudgeGuidePosition.y + _nudgeVoxel.s*0.5f,
2670 _nudgeGuidePosition.z + _nudgeVoxel.s*0.5f);2679 _nudgeGuidePosition.z + _nudgeVoxel.s*0.5f);
2671 glLineWidth(4.0f);2680 glLineWidth(4.0f);
2672 glutWireCube(_nudgeVoxel.s);2681 glutWireCube(_nudgeVoxel.s);
2673 } else {2682 } else {
2674 glTranslatef(_mouseVoxel.x + _mouseVoxel.s*0.5f,2683 glTranslatef(_mouseVoxel.x + _mouseVoxel.s*0.5f,
2675 _mouseVoxel.y + _mouseVoxel.s*0.5f,2684 _mouseVoxel.y + _mouseVoxel.s*0.5f,
2676 _mouseVoxel.z + _mouseVoxel.s*0.5f);2685 _mouseVoxel.z + _mouseVoxel.s*0.5f);
2677 glLineWidth(4.0f);2686 glLineWidth(4.0f);
2678 glutWireCube(_mouseVoxel.s);2687 glutWireCube(_mouseVoxel.s);
2688 }
2689 glLineWidth(1.0f);
2690 glPopMatrix();
2691 glEnable(GL_LIGHTING);
2679 }2692 }
2680 glLineWidth(1.0f);
2681 glPopMatrix();
2682 glEnable(GL_LIGHTING);
2683 }
2684 2693
2685 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode && whichCamera.getMode() != CAMERA_MODE_MIRROR) {2694 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2686 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), 2695 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2687 "Application::displaySide() ... PASTE Preview...");2696 "Application::displaySide() ... PASTE Preview...");
2688 2697
2689 glPushMatrix();2698 glPushMatrix();
2690 glTranslatef(_mouseVoxel.x * TREE_SCALE,2699 glTranslatef(_mouseVoxel.x * TREE_SCALE,
2691 _mouseVoxel.y * TREE_SCALE,2700 _mouseVoxel.y * TREE_SCALE,
2692 _mouseVoxel.z * TREE_SCALE);2701 _mouseVoxel.z * TREE_SCALE);
2693 glScalef(_mouseVoxel.s,2702 glScalef(_mouseVoxel.s,
2694 _mouseVoxel.s,2703 _mouseVoxel.s,
2695 _mouseVoxel.s);2704 _mouseVoxel.s);
2696 2705
2697 _sharedVoxelSystem.render(true);2706 _sharedVoxelSystem.render(true);
2698 glPopMatrix();2707 glPopMatrix();
2708 }
2699 }2709 }
2700 2710
2701 _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);2711 _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
@@ -2705,26 +2715,28 @@ void Application::displaySide(Camera& whichCamera) { · 3 unmodified lines
2705 "Application::displaySide() ... Avatars...");2715 "Application::displaySide() ... Avatars...");
2706 2716
2707 2717
2708 // Render avatars of other nodes2718 if (!selfAvatarOnly) {
2709 NodeList* nodeList = NodeList::getInstance();2719 // Render avatars of other nodes
2720 NodeList* nodeList = NodeList::getInstance();
2710 2721
2711 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {2722 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2712 node->lock();2723 node->lock();
2713 2724
2714 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {2725 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
2715 Avatar *avatar = (Avatar *)node->getLinkedData();2726 Avatar *avatar = (Avatar *)node->getLinkedData();
2716 if (!avatar->isInitialized()) {2727 if (!avatar->isInitialized()) {
2717 avatar->init();2728 avatar->init();
2718 }2729 }
2719 // Set lookAt to myCamera on client side if other avatars are looking at client2730 // Set lookAt to myCamera on client side if other avatars are looking at client
2720 if (isLookingAtMyAvatar(avatar)) {2731 if (isLookingAtMyAvatar(avatar)) {
2721 avatar->getHead().setLookAtPosition(whichCamera.getPosition());2732 avatar->getHead().setLookAtPosition(whichCamera.getPosition());
2733 }
2734 avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
2735 avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
2722 }2736 }
2723 avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
2724 avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
2725 }
2726 2737
2727 node->unlock();2738 node->unlock();
2739 }
2728 }2740 }
2729 2741
2730 // Render my own Avatar2742 // Render my own Avatar

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t