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
438438 // set the bounds of rear mirror view
439439 glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
440440 glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
441− updateProjectionMatrix(_mirrorCamera);
441+ bool updateViewFrustum = false;
442+ updateProjectionMatrix(_mirrorCamera, updateViewFrustum);
442443 glEnable(GL_SCISSOR_TEST);
443444 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
444445
445446 // render rear mirror view
446447 glPushMatrix();
447− displaySide(_mirrorCamera);
448+ bool selfAvatarOnly = true;
449+ displaySide(_mirrorCamera, selfAvatarOnly);
448450 glPopMatrix();
449451
450452 // render rear view tools if mouse is in the bounds
@@ -456,7 +458,7 @@ void Application::paintGL() { · 5 unmodified lines
456458 // reset Viewport and projection matrix
457459 glViewport(0, 0, _glWidget->width(), _glWidget->height());
458460 glDisable(GL_SCISSOR_TEST);
459− updateProjectionMatrix();
461+ updateProjectionMatrix(_myCamera, updateViewFrustum);
460462 }
461463
462464 displayOverlay();
@@ -494,22 +496,28 @@ void Application::updateProjectionMatrix() { · 31 unmodified lines
494496 updateProjectionMatrix(_myCamera);
495497 }
496498
497−void Application::updateProjectionMatrix(Camera& camera) {
499+void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) {
498500 glMatrixMode(GL_PROJECTION);
499501 glLoadIdentity();
500−
501− // Tell our viewFrustum about this change, using the application camera
502− loadViewFrustum(camera, _viewFrustum);
503−
502+
504503 float left, right, bottom, top, nearVal, farVal;
505504 glm::vec4 nearClipPlane, farClipPlane;
506− computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
507505
508− // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
509− // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum
510− if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
511− nearVal = _viewFrustumOffsetCamera.getNearClip();
512− farVal = _viewFrustumOffsetCamera.getFarClip();
506+ // Tell our viewFrustum about this change, using the application camera
507+ if (updateViewFrustum) {
508+ loadViewFrustum(camera, _viewFrustum);
509+ computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
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);
513521 }
514522 glFrustum(left, right, bottom, top, nearVal, farVal);
515523
@@ -2508,7 +2516,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 1992 unmodified lines
25082516 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);
25092517 }
25102518
2511−void Application::displaySide(Camera& whichCamera) {
2519+void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
25122520 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
25132521 // transform by eye offset
25142522
@@ -2540,7 +2548,7 @@ void Application::displaySide(Camera& whichCamera) { · 25 unmodified lines
25402548 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
25412549 setupWorldLight(whichCamera);
25422550
2543− if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
2551+ if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
25442552 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
25452553 "Application::displaySide() ... stars...");
25462554 if (!_stars.isStarsLoaded()) {
@@ -2567,7 +2575,7 @@ void Application::displaySide(Camera& whichCamera) { · 20 unmodified lines
25672575 }
25682576
25692577 // draw the sky dome
2570− if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
2578+ if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
25712579 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
25722580 "Application::displaySide() ... atmosphere...");
25732581 _environment.renderAtmospheres(whichCamera);
@@ -2580,122 +2588,124 @@ void Application::displaySide(Camera& whichCamera) { · 6 unmodified lines
25802588 //renderLineToTouchedVoxel();
25812589 //renderThrustAtVoxel(_voxelThrust);
25822590
2583− // draw a red sphere
2584− float sphereRadius = 0.25f;
2585− glColor3f(1,0,0);
2586− glPushMatrix();
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);
2591+ if (!selfAvatarOnly) {
2592+ // draw a red sphere
2593+ float sphereRadius = 0.25f;
2594+ glColor3f(1,0,0);
26052595 glPushMatrix();
2606− const float GRASS_PLANE_SIZE = 256.0f;
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);
2596+ glutSolidSphere(sphereRadius, 15, 15);
26132597 glPopMatrix();
2614− glDisable(GL_FOG);
2615− glDisable(GL_NORMALIZE);
2598+
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);
26162625
2617− //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
2618− }
2619− // Draw Cloud Particles
2620− if (Menu::getInstance()->isOptionChecked(MenuOption::ParticleCloud)) {
2621− _cloud.render();
2622− }
2623− // Draw voxels
2624− if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2625− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2626− "Application::displaySide() ... voxels...");
2627− if (!Menu::getInstance()->isOptionChecked(MenuOption::DontRenderVoxels)) {
2628− _voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
2626+ //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
2627+ }
2628+ // Draw Cloud Particles
2629+ if (Menu::getInstance()->isOptionChecked(MenuOption::ParticleCloud)) {
2630+ _cloud.render();
2631+ }
2632+ // Draw voxels
2633+ if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2634+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2635+ "Application::displaySide() ... voxels...");
2636+ if (!Menu::getInstance()->isOptionChecked(MenuOption::DontRenderVoxels)) {
2637+ _voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
2638+ }
26292639 }
2630− }
26312640
26322641
2633− // restore default, white specular
2634− glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
2642+ // restore default, white specular
2643+ glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
26352644
2636− // indicate what we'll be adding/removing in mouse mode, if anything
2637− if (_mouseVoxel.s != 0 && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2638− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2639− "Application::displaySide() ... voxels TOOLS UX...");
2645+ // indicate what we'll be adding/removing in mouse mode, if anything
2646+ if (_mouseVoxel.s != 0 && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2647+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2648+ "Application::displaySide() ... voxels TOOLS UX...");
26402649
2641− 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);
2650+ glDisable(GL_LIGHTING);
26472651 glPushMatrix();
2648− glTranslatef(_nudgeVoxel.x + _nudgeVoxel.s * 0.5f,
2649− _nudgeVoxel.y + _nudgeVoxel.s * 0.5f,
2650− _nudgeVoxel.z + _nudgeVoxel.s * 0.5f);
2651− glColor3ub(255, 255, 255);
2652− glLineWidth(4.0f);
2653− glutWireCube(_nudgeVoxel.s);
2654− glPopMatrix();
2655− } else {
2656− renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
2657− }
2652+ glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
2653+ if (_nudgeStarted) {
2654+ renderNudgeGuide(_nudgeGuidePosition.x, _nudgeGuidePosition.y, _nudgeGuidePosition.z, _nudgeVoxel.s);
2655+ renderNudgeGrid(_nudgeVoxel.x, _nudgeVoxel.y, _nudgeVoxel.z, _nudgeVoxel.s, _mouseVoxel.s);
2656+ glPushMatrix();
2657+ glTranslatef(_nudgeVoxel.x + _nudgeVoxel.s * 0.5f,
2658+ _nudgeVoxel.y + _nudgeVoxel.s * 0.5f,
2659+ _nudgeVoxel.z + _nudgeVoxel.s * 0.5f);
2660+ glColor3ub(255, 255, 255);
2661+ glLineWidth(4.0f);
2662+ glutWireCube(_nudgeVoxel.s);
2663+ glPopMatrix();
2664+ } else {
2665+ renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
2666+ }
26582667
2659− if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {
2660− // use a contrasting color so that we can see what we're doing
2661− glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128);
2662− } else {
2663− glColor3ub(_mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue);
2664− }
2668+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {
2669+ // use a contrasting color so that we can see what we're doing
2670+ glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128);
2671+ } else {
2672+ glColor3ub(_mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue);
2673+ }
26652674
2666− if (_nudgeStarted) {
2667− // render nudge guide cube
2668− glTranslatef(_nudgeGuidePosition.x + _nudgeVoxel.s*0.5f,
2669− _nudgeGuidePosition.y + _nudgeVoxel.s*0.5f,
2670− _nudgeGuidePosition.z + _nudgeVoxel.s*0.5f);
2671− glLineWidth(4.0f);
2672− glutWireCube(_nudgeVoxel.s);
2673− } else {
2674− glTranslatef(_mouseVoxel.x + _mouseVoxel.s*0.5f,
2675− _mouseVoxel.y + _mouseVoxel.s*0.5f,
2676− _mouseVoxel.z + _mouseVoxel.s*0.5f);
2677− glLineWidth(4.0f);
2678− glutWireCube(_mouseVoxel.s);
2675+ if (_nudgeStarted) {
2676+ // render nudge guide cube
2677+ glTranslatef(_nudgeGuidePosition.x + _nudgeVoxel.s*0.5f,
2678+ _nudgeGuidePosition.y + _nudgeVoxel.s*0.5f,
2679+ _nudgeGuidePosition.z + _nudgeVoxel.s*0.5f);
2680+ glLineWidth(4.0f);
2681+ glutWireCube(_nudgeVoxel.s);
2682+ } else {
2683+ glTranslatef(_mouseVoxel.x + _mouseVoxel.s*0.5f,
2684+ _mouseVoxel.y + _mouseVoxel.s*0.5f,
2685+ _mouseVoxel.z + _mouseVoxel.s*0.5f);
2686+ glLineWidth(4.0f);
2687+ glutWireCube(_mouseVoxel.s);
2688+ }
2689+ glLineWidth(1.0f);
2690+ glPopMatrix();
2691+ glEnable(GL_LIGHTING);
26792692 }
2680− glLineWidth(1.0f);
2681− glPopMatrix();
2682− glEnable(GL_LIGHTING);
2683− }
26842693
2685− if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2686− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2687− "Application::displaySide() ... PASTE Preview...");
2694+ if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2695+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2696+ "Application::displaySide() ... PASTE Preview...");
26882697
2689− glPushMatrix();
2690− glTranslatef(_mouseVoxel.x * TREE_SCALE,
2691− _mouseVoxel.y * TREE_SCALE,
2692− _mouseVoxel.z * TREE_SCALE);
2693− glScalef(_mouseVoxel.s,
2694− _mouseVoxel.s,
2695− _mouseVoxel.s);
2696−
2697− _sharedVoxelSystem.render(true);
2698− glPopMatrix();
2698+ glPushMatrix();
2699+ glTranslatef(_mouseVoxel.x * TREE_SCALE,
2700+ _mouseVoxel.y * TREE_SCALE,
2701+ _mouseVoxel.z * TREE_SCALE);
2702+ glScalef(_mouseVoxel.s,
2703+ _mouseVoxel.s,
2704+ _mouseVoxel.s);
2705+
2706+ _sharedVoxelSystem.render(true);
2707+ glPopMatrix();
2708+ }
26992709 }
27002710
27012711 _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
@@ -2705,26 +2715,28 @@ void Application::displaySide(Camera& whichCamera) { · 3 unmodified lines
27052715 "Application::displaySide() ... Avatars...");
27062716
27072717
2708− // Render avatars of other nodes
2709− NodeList* nodeList = NodeList::getInstance();
2718+ if (!selfAvatarOnly) {
2719+ // Render avatars of other nodes
2720+ NodeList* nodeList = NodeList::getInstance();
27102721
2711− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2712− node->lock();
2722+ for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2723+ node->lock();
27132724
2714− if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
2715− Avatar *avatar = (Avatar *)node->getLinkedData();
2716− if (!avatar->isInitialized()) {
2717− avatar->init();
2718− }
2719− // Set lookAt to myCamera on client side if other avatars are looking at client
2720− if (isLookingAtMyAvatar(avatar)) {
2721− avatar->getHead().setLookAtPosition(whichCamera.getPosition());
2725+ if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
2726+ Avatar *avatar = (Avatar *)node->getLinkedData();
2727+ if (!avatar->isInitialized()) {
2728+ avatar->init();
2729+ }
2730+ // Set lookAt to myCamera on client side if other avatars are looking at client
2731+ if (isLookingAtMyAvatar(avatar)) {
2732+ avatar->getHead().setLookAtPosition(whichCamera.getPosition());
2733+ }
2734+ avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
2735+ avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
27222736 }
2723− avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
2724− avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
2725− }
27262737
2727− node->unlock();
2738+ node->unlock();
2739+ }
27282740 }
27292741
27302742 // 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