mirror of
https://github.com/minetest/minetest.git
synced 2024-08-19 04:54:18 +02:00
Merge support for anaglyph stereo
This commit is contained in:
commit
bb454b1846
@ -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)
|
||||
|
@ -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");
|
||||
|
70
src/game.cpp
70
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user