summaryrefslogtreecommitdiff
path: root/src/drawscene.cpp
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2015-12-14 19:01:32 -0200
committersfan5 <sfan5@live.de>2016-01-09 16:52:29 +0100
commit9943ae3f1a4fa1b687c780419b7f3a2d8091abe0 (patch)
treeccef2ab8002f276b6a2c4e4fb8cdb8d0064ff49b /src/drawscene.cpp
parentfe3f6be4d262b466cd511595ad3b3c9bd5c89ea1 (diff)
downloadminetest-9943ae3f1a4fa1b687c780419b7f3a2d8091abe0.tar.gz
minetest-9943ae3f1a4fa1b687c780419b7f3a2d8091abe0.tar.bz2
minetest-9943ae3f1a4fa1b687c780419b7f3a2d8091abe0.zip
New 3D Mode: Pageflip
The pageflip mode requires a stereo quadbuffer, and a modern graphic card. Patch tested with NVidia 3D Vision. The mini-map is not drawn, but that's what is done for topbottom and sidebyside modes as well. Also most of the time the user would prefer the HUD to be off. That's for the user to decide though, and toggle it manually. Finally, the interocular distance (aka eye separation) is twice as much as the "3d_paralax_strength" settings. I find this a strange design decision. I didn't want to chance this though, since it's how the other 3d modes interpret this settings.
Diffstat (limited to 'src/drawscene.cpp')
-rw-r--r--src/drawscene.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/drawscene.cpp b/src/drawscene.cpp
index 509f341d5..c716ca0d4 100644
--- a/src/drawscene.cpp
+++ b/src/drawscene.cpp
@@ -404,6 +404,84 @@ void draw_top_bottom_3d_mode(Camera& camera, bool show_hud,
camera.getCameraNode()->setTarget(oldTarget);
}
+void draw_pageflip_3d_mode(Camera& camera, bool show_hud,
+ Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
+ scene::ISceneManager* smgr, const v2u32& screensize,
+ bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
+ video::SColor skycolor)
+{
+ /* preserve old setup*/
+ 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...
+ driver->setRenderTarget(irr::video::ERT_STEREO_LEFT_BUFFER);
+
+ irr::core::vector3df leftEye;
+ irr::core::matrix4 leftMove;
+ leftMove.setTranslation(
+ irr::core::vector3df(-g_settings->getFloat("3d_paralax_strength"),
+ 0.0f, 0.0f));
+ leftEye = (startMatrix * leftMove).getTranslation();
+
+ //clear the depth buffer, and color
+ driver->beginScene(true, true, irr::video::SColor(200, 200, 200, 255));
+ camera.getCameraNode()->setPosition(leftEye);
+ camera.getCameraNode()->setTarget(focusPoint);
+ smgr->drawAll();
+ driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
+
+ if (show_hud) {
+ draw_selectionbox(driver, hud, hilightboxes, show_hud);
+
+ if (draw_wield_tool)
+ camera.drawWieldedTool(&leftMove);
+
+ hud.drawHotbar(client.getPlayerItem());
+ hud.drawLuaElements(camera.getOffset());
+ }
+
+ guienv->drawAll();
+
+ //Right eye...
+ driver->setRenderTarget(irr::video::ERT_STEREO_RIGHT_BUFFER);
+
+ irr::core::vector3df rightEye;
+ irr::core::matrix4 rightMove;
+ rightMove.setTranslation(
+ irr::core::vector3df(g_settings->getFloat("3d_paralax_strength"),
+ 0.0f, 0.0f));
+ rightEye = (startMatrix * rightMove).getTranslation();
+
+ //clear the depth buffer, and color
+ driver->beginScene(true, true, irr::video::SColor(200, 200, 200, 255));
+ camera.getCameraNode()->setPosition(rightEye);
+ camera.getCameraNode()->setTarget(focusPoint);
+ smgr->drawAll();
+ driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
+
+ if (show_hud) {
+ draw_selectionbox(driver, hud, hilightboxes, show_hud);
+
+ if (draw_wield_tool)
+ camera.drawWieldedTool(&rightMove);
+
+ hud.drawHotbar(client.getPlayerItem());
+ hud.drawLuaElements(camera.getOffset());
+ }
+
+ guienv->drawAll();
+
+ camera.getCameraNode()->setPosition(oldPosition);
+ camera.getCameraNode()->setTarget(oldTarget);
+}
+
void draw_plain(Camera& camera, bool show_hud, Hud& hud,
std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv)
@@ -466,6 +544,13 @@ void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr,
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
show_hud = false;
}
+ else if (draw_mode == "pageflip")
+ {
+ draw_pageflip_3d_mode(camera, show_hud, hud, hilightboxes, driver,
+ smgr, screensize, draw_wield_tool, client, guienv, skycolor);
+ draw_crosshair = false;
+ show_hud = false;
+ }
else {
draw_plain(camera, show_hud, hud, hilightboxes, driver,
draw_wield_tool, client, guienv);