Irrlicht Engine Forum Index Irrlicht Engine
Official forum of the Irrlicht Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Anaglyph rendering.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Irrlicht Engine Forum Index -> Code Snippets
View previous topic :: View next topic  
Author Message
Luke
Admin


Joined: 14 Jul 2006
Posts: 449
Location: Australia

PostPosted: Mon May 04, 2009 12:53 pm    Post subject: Anaglyph rendering. Reply with quote

hey, though I should post a bit of code I did lately for anaglyph rendering.

Code:


void CGameEngine::drawAnaglyph()
{
    vector3df oldPosition=camera->getPosition();
   vector3df oldTarget=camera->getTarget();
   
   matrix4 startMatrix=camera->getAbsoluteTransformation();

   vector3df focusPoint= (camera->getTarget()-camera->getAbsolutePosition()).setLength(1) + camera->getAbsolutePosition() ;

   //Left eye...

   vector3df leftEye;
   matrix4 leftMove;
   leftMove.setTranslation( vector3df(-0.01f,0.0f,0.0f) );
   leftEye=(startMatrix*leftMove).getTranslation();

   //clear the depth buffer, and color
    driver->beginScene( true, true, SColor(0,200,200,255) );

   driver->getOverrideMaterial().Material.ColorMask=ECP_RED;
   driver->getOverrideMaterial().EnableFlags=EMF_COLOR_MASK;
   driver->getOverrideMaterial().EnablePasses=ESNRP_SKY_BOX+ESNRP_SOLID+ESNRP_TRANSPARENT+ESNRP_TRANSPARENT_EFFECT+ESNRP_SHADOW;

    camera->setPosition( leftEye );
    camera->setTarget( focusPoint );

   draw(); // 'smgr->drawAll();' may go here


   //Right eye...

   vector3df rightEye;
   matrix4 rightMove;
   rightMove.setTranslation( vector3df(0.01f,0.0f,0.0f) );
   rightEye=(startMatrix*rightMove).getTranslation();

   //clear the depth buffer
   driver->clearZBuffer();

   driver->getOverrideMaterial().Material.ColorMask=ECP_GREEN+ECP_BLUE;
   driver->getOverrideMaterial().EnableFlags=EMF_COLOR_MASK;
   driver->getOverrideMaterial().EnablePasses=ESNRP_SKY_BOX+ESNRP_SOLID+ESNRP_TRANSPARENT+ESNRP_TRANSPARENT_EFFECT+ESNRP_SHADOW;

    camera->setPosition( rightEye );
   camera->setTarget( focusPoint );

    draw(); // 'smgr->drawAll();' may go here

    driver->endScene();

   driver->getOverrideMaterial().Material.ColorMask=ECP_ALL;
   driver->getOverrideMaterial().EnableFlags=0;
   driver->getOverrideMaterial().EnablePasses=0;

    camera->setPosition( oldPosition );

    camera->setTarget( oldTarget );

}


similar to the code by bob, here: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=32209

but fixes a few problems, and more irrlicht friendly.






more images here
_________________
irrlicht irc - corrodinggames.com


Last edited by Luke on Mon May 04, 2009 1:15 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
hybrid
Admin


Joined: 19 Apr 2006
Posts: 9757
Location: Oldenburg(Oldb), Germany

PostPosted: Mon May 04, 2009 1:02 pm    Post subject: Reply with quote

Wow, fantastic Very Happy Actually, this was the thing I wanted to try out with the override material, but I failed to find proper glasses. So I postponed it - guess I have to buy some urgently!
We should probably set up a tutorial with this code.
Back to top
View user's profile Send private message Visit poster's website
Malgodur



Joined: 15 Mar 2009
Posts: 195

PostPosted: Mon May 04, 2009 1:34 pm    Post subject: Reply with quote

Its for 1.5? I got a bunch off errors...

Code:
rror C2039: 'getOverrideMaterial' : is not a member of 'irr::video::IVideoDriver'

error C2228: left of '.Material' must have class/struct/union


etc
Back to top
View user's profile Send private message
Luke
Admin


Joined: 14 Jul 2006
Posts: 449
Location: Australia

PostPosted: Mon May 04, 2009 1:47 pm    Post subject: Reply with quote

Quote:

We should probably set up a tutorial with this code.


yeah sounds good.

Quote:
Its for 1.5? I got a bunch off errors...


hmm, you may have to use the svn or wait for 1.6. sorry I always work off the svn, I forget what is in each version.
_________________
irrlicht irc - corrodinggames.com
Back to top
View user's profile Send private message Visit poster's website
shadowslair



Joined: 31 Mar 2008
Posts: 272
Location: Bulgaria

PostPosted: Mon May 04, 2009 8:16 pm    Post subject: Reply with quote

Haha! This is niiice... Smile
I`ll better wait for 1.6 also. Confused
_________________
Back to top
View user's profile Send private message
wITTus



Joined: 24 Jun 2008
Posts: 167
Location: Germany

PostPosted: Tue May 05, 2009 11:09 am    Post subject: Reply with quote

@hybrid: Check out ebay, there you can find tons of these glasses.

@Luke: This is almost a candidate for the screenshot of the month competition. Absolutely awesome Cool. But is it real 3D? Normally the red and green bars around the objects should change their size with distance, shouldn't they? Question
_________________
Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko
Back to top
View user's profile Send private message
Luke
Admin


Joined: 14 Jul 2006
Posts: 449
Location: Australia

PostPosted: Tue May 05, 2009 11:19 am    Post subject: Reply with quote

Quote:
@Luke: This is almost a candidate for the screenshot of the month competition. Absolutely awesome Cool. But is it real 3D? Normally the red and green bars around the objects should change their size with distance, shouldn't they? Question


yeah it is real 3d, and they do change. The red and green bars, reverse at the focus point (the difference between poping out, and looking far away), so it may not look like they change in that image.

have a look at some of the other shots here (you can see the size changing better):

http://corrodinggames.com/forums/viewtopic.php?f=1&t=16
_________________
irrlicht irc - corrodinggames.com
Back to top
View user's profile Send private message Visit poster's website
wITTus



Joined: 24 Jun 2008
Posts: 167
Location: Germany

PostPosted: Tue May 05, 2009 1:04 pm    Post subject: Reply with quote

True. Did I already mention that this is awesome? Wink

Your LUA stuff is also quite cool btw.
Was it hard to implement?
_________________
Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko
Back to top
View user's profile Send private message
CuteAlien
Admin


Joined: 06 Mar 2006
Posts: 1935
Location: Tübingen, Germany

PostPosted: Tue May 05, 2009 3:20 pm    Post subject: Reply with quote

Meh. I urgently need red-green glasses!
_________________
http://www.irrgheist.com/
http://www.michaelzeilfelder.de/irrlicht.htm
IRC: #irrlicht on irc.freenode.net
Back to top
View user's profile Send private message Visit poster's website
BlindSide
Admin


Joined: 08 Dec 2005
Posts: 2505
Location: NZ!

PostPosted: Wed May 06, 2009 5:35 am    Post subject: Reply with quote

Well if you want 3D glasses you can get em for 2 dollars with free shipping from here:

http://www.dealextreme.com/details.dx/sku.18501~r.19022052

Yes thats my shamelessly tacked on referral id on the end there. Laughing
_________________
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Back to top
View user's profile Send private message Send e-mail
CuteAlien
Admin


Joined: 06 Mar 2006
Posts: 1935
Location: Tübingen, Germany

PostPosted: Wed May 06, 2009 2:49 pm    Post subject: Reply with quote

Hm, those are red-blue glasses. What will I need for that image here? Red-Green, Red-Blue, Red-XYZ?
_________________
http://www.irrgheist.com/
http://www.michaelzeilfelder.de/irrlicht.htm
IRC: #irrlicht on irc.freenode.net
Back to top
View user's profile Send private message Visit poster's website
wITTus



Joined: 24 Jun 2008
Posts: 167
Location: Germany

PostPosted: Wed May 06, 2009 7:43 pm    Post subject: Reply with quote

In worst case, simply change the color within the code snippet Laughing
_________________
Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko
Back to top
View user's profile Send private message
BlindSide
Admin


Joined: 08 Dec 2005
Posts: 2505
Location: NZ!

PostPosted: Thu May 07, 2009 1:36 am    Post subject: Reply with quote

CuteAlien wrote:
Hm, those are red-blue glasses. What will I need for that image here? Red-Green, Red-Blue, Red-XYZ?


I knew you would say that you pedantic **** Razz

Actually they are Red-Cyan glasses, the title is misleading. And this is Red-Cyan anaglyph rendering (RED/GREEN+BLUE):

From luke's code:

Code:

driver->getOverrideMaterial().Material.ColorMask=ECP_GREEN+ECP_BLUE;


Yes I am hustlin' for my 1 DX point per 5 glass purchased. Cool
_________________
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Back to top
View user's profile Send private message Send e-mail
CuteAlien
Admin


Joined: 06 Mar 2006
Posts: 1935
Location: Tübingen, Germany

PostPosted: Thu May 07, 2009 2:03 am    Post subject: Reply with quote

BlindSide wrote:
CuteAlien wrote:
Hm, those are red-blue glasses. What will I need for that image here? Red-Green, Red-Blue, Red-XYZ?


I knew you would say that you pedantic **** :P


Lol - purely innocent curiosity - I really had no idea :-)
_________________
http://www.irrgheist.com/
http://www.michaelzeilfelder.de/irrlicht.htm
IRC: #irrlicht on irc.freenode.net
Back to top
View user's profile Send private message Visit poster's website
thatdudeoverthere



Joined: 24 Apr 2009
Posts: 18

PostPosted: Sun May 10, 2009 5:35 am    Post subject: Reply with quote

i'm having a seizure... oh, the images just look like that anyhow good work. lol Smile
_________________
//Personal code

bool sarcasm;

bool set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Irrlicht Engine Forum Index -> Code Snippets All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
SourceForge.net Logo


Powered by phpBB © 2001, 2005 phpBB Group