diff options
author | PilzAdam <adam-k@outlook.com> | 2012-12-01 12:41:05 +0100 |
---|---|---|
committer | PilzAdam <adam-k@outlook.com> | 2012-12-01 12:41:05 +0100 |
commit | bb454b184656735b51fea17a0cb6276514b1c8c1 (patch) | |
tree | fea745d7db7910069b36c2a9100f53ad428abc7e | |
parent | 778d9b0cd609ee24a86e88dbd1fe396d809683d9 (diff) | |
parent | 6c43ec2d2b86b77fe2d12953ebecdd63922ecebc (diff) | |
download | minetest-bb454b184656735b51fea17a0cb6276514b1c8c1.tar.gz minetest-bb454b184656735b51fea17a0cb6276514b1c8c1.tar.bz2 minetest-bb454b184656735b51fea17a0cb6276514b1c8c1.zip |
Merge support for anaglyph stereo
-rw-r--r-- | minetest.conf.example | 3 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 3 | ||||
-rw-r--r-- | src/game.cpp | 70 |
3 files changed, 76 insertions, 0 deletions
diff --git a/minetest.conf.example b/minetest.conf.example index 071b97c65..7d471dc05 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -117,6 +117,9 @@ #screenshot_path = . # Amount of view bobbing (0 = no view bobbing, 1.0 = normal, 2.0 = double) #view_bobbing_amount = 1.0 +# Anaglyph stereo +#anaglyph = false +#anaglyph_strength = 0.1 # In-game chat console background color (R,G,B) #console_color = (0,0,0) # In-game chat console background alpha (opaqueness, between 0 and 255) diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index d186427e7..333d98cd8 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("anaglyph_strength", "0.1"); settings->setDefault("aux1_descends", "false"); + // 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 edc3ce741..086293894 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2750,6 +2750,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); } |