diff options
author | MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com> | 2012-02-18 18:51:19 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-11-13 19:20:35 +0200 |
commit | 8b16e5f27d7cebc836eaf0513a39f915a902aa0b (patch) | |
tree | 6559b05f49bfb6bcdacc0f6b0398a3a8d0114ff8 /src | |
parent | 5f1d3ad754e66144aaee2dcd2153db125195e9cc (diff) | |
download | minetest-8b16e5f27d7cebc836eaf0513a39f915a902aa0b.tar.gz minetest-8b16e5f27d7cebc836eaf0513a39f915a902aa0b.tar.bz2 minetest-8b16e5f27d7cebc836eaf0513a39f915a902aa0b.zip |
Anaglyph stereo support, created by xyz
Diffstat (limited to 'src')
-rw-r--r-- | src/defaultsettings.cpp | 3 | ||||
-rw-r--r-- | src/game.cpp | 70 |
2 files changed, 73 insertions, 0 deletions
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 6eaa28410..4c460c547 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -52,7 +52,10 @@ void set_default_settings(Settings *settings) settings->setDefault("keymap_toggle_profiler", "KEY_F6"); settings->setDefault("keymap_increase_viewing_range_min", "+"); settings->setDefault("keymap_decrease_viewing_range_min", "-"); + settings->setDefault("anaglyph", "false"); settings->setDefault("aux1_descends", "false"); + settings->setDefault("anaglyph_strength", "0.01"); + // Some (temporary) keys for debugging settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); settings->setDefault("keymap_quicktune_prev", "KEY_HOME"); diff --git a/src/game.cpp b/src/game.cpp index a1a197219..b6accfe37 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2734,6 +2734,76 @@ void the_game( { TimeTaker timer("smgr"); smgr->drawAll(); + + if(g_settings->getBool("anaglyph")) + { + irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition(); + irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget(); + + irr::core::matrix4 startMatrix = camera.getCameraNode()->getAbsoluteTransformation(); + + irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget() - + camera.getCameraNode()->getAbsolutePosition()).setLength(1) + + camera.getCameraNode()->getAbsolutePosition() ; + + //Left eye... + irr::core::vector3df leftEye; + irr::core::matrix4 leftMove; + + leftMove.setTranslation( irr::core::vector3df(-g_settings->getFloat("anaglyph_strength"),0.0f,0.0f) ); + leftEye=(startMatrix*leftMove).getTranslation(); + + //clear the depth buffer, and color + driver->beginScene( true, true, irr::video::SColor(0,200,200,255) ); + + driver->getOverrideMaterial().Material.ColorMask = irr::video::ECP_RED; + driver->getOverrideMaterial().EnableFlags = irr::video::EMF_COLOR_MASK; + driver->getOverrideMaterial().EnablePasses = irr::scene::ESNRP_SKY_BOX + + irr::scene::ESNRP_SOLID + + irr::scene::ESNRP_TRANSPARENT + + irr::scene::ESNRP_TRANSPARENT_EFFECT + + irr::scene::ESNRP_SHADOW; + + camera.getCameraNode()->setPosition( leftEye ); + camera.getCameraNode()->setTarget( focusPoint ); + + smgr->drawAll(); // 'smgr->drawAll();' may go here + + + //Right eye... + irr::core::vector3df rightEye; + irr::core::matrix4 rightMove; + + rightMove.setTranslation( irr::core::vector3df(g_settings->getFloat("anaglyph_strength"),0.0f,0.0f) ); + rightEye=(startMatrix*rightMove).getTranslation(); + + //clear the depth buffer + driver->clearZBuffer(); + + driver->getOverrideMaterial().Material.ColorMask = irr::video::ECP_GREEN + irr::video::ECP_BLUE; + driver->getOverrideMaterial().EnableFlags = irr::video::EMF_COLOR_MASK; + driver->getOverrideMaterial().EnablePasses = irr::scene::ESNRP_SKY_BOX + + irr::scene::ESNRP_SOLID + + irr::scene::ESNRP_TRANSPARENT + + irr::scene::ESNRP_TRANSPARENT_EFFECT + + irr::scene::ESNRP_SHADOW; + + camera.getCameraNode()->setPosition( rightEye ); + camera.getCameraNode()->setTarget( focusPoint ); + + smgr->drawAll(); // 'smgr->drawAll();' may go here + + + //driver->endScene(); + + driver->getOverrideMaterial().Material.ColorMask=irr::video::ECP_ALL; + driver->getOverrideMaterial().EnableFlags=0; + driver->getOverrideMaterial().EnablePasses=0; + + camera.getCameraNode()->setPosition( oldPosition ); + camera.getCameraNode()->setTarget( oldTarget ); + } + scenetime = timer.stop(true); } |