3D Armagetronad

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

3D Armagetronad

Post by wrtlprnft »

Some little experiment with glColorMask: 3D tron! Screenshots

You need either red/green or red/cyan glasses to view the screenshots, but my hack can be configured to use all combinations of colors. Here's a patch based on the last trunk revision before philippe's zone merge:

Code: Select all

Index: src/engine/eCamera.cpp
===================================================================
--- src/engine/eCamera.cpp      (revision 7228)
+++ src/engine/eCamera.cpp      (working copy)
@@ -1340,6 +1340,20 @@
 static tSettingItem< REAL > se_confCameraSmart( "CAMERA_SMART", se_cameraSmart );
 */

+static float se_cameraEyeDistance = 0; // .1 to .5 appear to be good values
+static tConfItem<float> secced("CAMERA_EYE_DISTANCE", se_cameraEyeDistance);
+
+static int se_cameraEye1Color = 1; // 001b (bgR)
+static tConfItem<int> sece1ca("CAMERA_EYE_1_COLOR", se_cameraEye1Color);
+static tConfItem<int> sece1cb("CAMERA_EYE_1_COLOUR", se_cameraEye1Color);
+
+static int se_cameraEye2Color = 6; // 110b (BGr)
+static tConfItem<int> sece2ca("CAMERA_EYE_2_COLOR", se_cameraEye2Color);
+static tConfItem<int> sece2cb("CAMERA_EYE_2_COLOUR", se_cameraEye2Color);
+
+static float se_cameraInMaxFocusDistance = .5; //factor of the current speed
+static tConfItem<float> secimfd("CAMERA_IN_MAX_FOCUS_DISTANCE", se_cameraInMaxFocusDistance);
+
 #ifndef DEDICATED
 bool displaying=false;

@@ -1433,19 +1447,6 @@
     if(CenterCockpitFixedBefore()){
         vp->Perspective(fov,zNear,1E+20);

-        /*
-          gluLookAt(pos.x,
-             pos.y,
-             z,
-
-             pos.x+dir.x,
-             pos.y+dir.y,
-             z+rise,
-
-             top.x,top.y,
-             1);
-        */
-
         gluLookAt(0,
                   0,
                   0,
@@ -1471,6 +1472,9 @@
         if (zNear < -.1 )
             zNear = .1;

+               if(se_cameraEyeDistance) {
+                       glColorMask(se_cameraEye1Color & 1, se_cameraEye1Color & 2, se_cameraEye1Color & 4, GL_TRUE);
+               }
         grid->Render( this, id, zNear );

         zNear *= .3f;
@@ -1479,6 +1483,68 @@
             zNear = 0.0001f;
         }

+               if(se_cameraEyeDistance) {
+                       glClear(GL_DEPTH_BUFFER_BIT);
+                       glColorMask(se_cameraEye2Color & 1, se_cameraEye2Color & 2, se_cameraEye2Color & 4, GL_TRUE);
+                       glMatrixMode(GL_PROJECTION);
+                       glLoadIdentity();
+                       glMatrixMode(GL_MODELVIEW);
+                       glLoadIdentity();
+
+                       vp->Perspective(fov,zNear,1E+20);
+
+                       tCoord center = centerPosSmooth;
+
+                       float offset = 0;
+                       if(mode == CAMERA_IN) {
+                               eSensor test(Center(), Center()->Position(), Center()->Direction());
+                               test.detect(se_cameraInMaxFocusDistance*Center()->Speed());
+                               offset = test.hit;
+                       }
+
+                       tCoord ndir = dir * ((center - pos).Norm() + offset);
+
+                       tCoord bla = dir.Turn(tCoord(0,1))*se_cameraEyeDistance;
+                       tCoord dir2 = ndir - bla;
+                       dir2.Normalize();
+
+                       gluLookAt(0,
+                                         0,
+                                         0,
+
+                                         dir2.x,
+                                         dir2.y,
+                                         rise,
+
+                                         top.x,top.y,
+                                         1);
+
+                       bla += pos;
+
+                       glTranslatef(-bla.x,-bla.y,-z);
+                       glMatrixMode(GL_MODELVIEW);
+
+                       draw_center=((CenterPos()-pos).NormSquared()>1 ||
+                                                         fabs(CenterZ() - z)>1);
+
+                       tJUST_CONTROLLED_PTR< eGameObject > c=Center();
+                       if (!draw_center && c) c->RemoveFromList();
+
+                       eCoord poscopy = pos;
+                       zNear = - eWallRim::Bound( poscopy, 0.0f );
+                       if (zNear < -.1 )
+                               zNear = .1;
+
+                       grid->Render( this, id, zNear );
+
+                       zNear *= .3f;
+                       if ( zNear < 0.0001f )
+                       {
+                               zNear = 0.0001f;
+                       }
+                       glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+               }
+
         if (c) c->RenderCockpitVirtual();
It's disabled by default, you need to set CAMERA_EYE_DISTANCE to something ≠ 0 to see it. It needs to render the scene twice per frame, so expect it to be a bit slower than “normal” arma.
There's no place like ::1
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

What are you waiting for? Commit it :) It doesn't cost performance if the eye distance is left at the default, right?
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

Done (after adding documentation, NEWS, rebeautifying and renaming some variables so they're not called “bla” anymore).
It eats two floating point comparisons and conditional jumps per frame and viewport if it's not used.
There's no place like ::1
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

wrtlprnft wrote:It eats two floating point comparisons and conditional jumps per frame and viewport if it's not used.
That's actually too much, but maybe they'll allow it. :)

I've been thinking of doing this, but I decided to wait for 3D glasses to somehow get here first without actively seeking them out.

Suggestion if this is to get serious: make colors gray or at least desaturated. I'm just afraid that's more than a little experiment.

Edit: I'm an idiot and should have actually looked. You're supposed to move the camera to the side without turning to have some point at finite distance in the center.
ˌɑrməˈɡɛˌtrɑn
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

Jonathan wrote:Suggestion if this is to get serious: make colors gray or at least desaturated. I'm just afraid that's more than a little experiment.
I did another little hack to make the AIs use only shades of gray and set the floor and myself to be white, but I didn't really like it.
Edit: I'm an idiot and should have actually looked. You're supposed to move the camera to the side without turning to have some point at finite distance in the center.
Err, why? In real life you move your eyes so they both look at some point of interest (unless you're drunk, in which case you shouldn't play arma). Of course the game can't know where your point of interest will be, so it just uses the current cycle position.
I tried not turning the camera (in fact i did that first), but it just looks weird, not 3- dimensional at all.
There's no place like ::1
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

wrtlprnft wrote:Err, why? In real life you move your eyes so they both look at some point of interest (unless you're drunk, in which case you shouldn't play arma).
Yeah, your eyes should do that, not the renderer.
wrtlprnft wrote:Of course the game can't know where your point of interest will be, so it just uses the current cycle position.
I tried not turning the camera (in fact i did that first), but it just looks weird, not 3- dimensional at all.
Try skewing:

Code: Select all

\ \              / /
  \\____________//
    \          /
     \\      //
      \ \  / /
       \ /\ /
        *  *
ˌɑrməˈɡɛˌtrɑn
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1975
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Post by kyle »

As Wrtl said you use the colored classes. by using the colored glasses it makes you look at refracted angle grouping them together this is how it render and and creates the 3D allusion. just some simple physics that is all. nice mod i need 3d glasses now. just threw out a pair last week they were polarized ones though.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

I know how it works. Each of the filters passes a different band of the visible spectrum. The display should be capable of emitting light that is primarily passed by only one of the filters, and the other. Now display two images, one for each filter, and you can get the 3D effect if the images have approximately correct perspective for each eye. It'll look a little odd due to the chromaticity differences and focus conflicting with convergence, but the brain can cope with that.
ˌɑrməˈɡɛˌtrɑn
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

FYI, this is called "anaglyph stereo" :)
Thank you thank you wrtl! I like this :)
Pre-greyscaling would definately make it work better, though. To get good anaglyph stereo vision, you need to first make the video source mono colour. Otherwise only your right eye will see the death zone and confuse you ;)
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

Actually, better than greyscaling would be constraining the red channel to at least an average of the green and blue, or something to that effect... This would be best suited for the red/cyan glasses. Red/blue would go back to a greyscale goal.
HellBlade
On Lightcycle Grid
Posts: 47
Joined: Tue Feb 06, 2007 7:07 am

Post by HellBlade »

my red green glasses still slightly show the cyan line, I know I had a full pair of red cyan glasses (with plastic rims and the like) I just gatta find them.
Image
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

HellBlade wrote:my red green glasses still slightly show the cyan line, I know I had a full pair of red cyan glasses (with plastic rims and the like) I just gatta find them.
Set CAMERA_EYE_2_COLOR to 2 and the blue component of the image will be gone entirely.

Luke: thanks for the name, I'll look how hard it will be to find the spots that actually set the color for walls and cycles and if there's an easy way to make the texture loader convert everything it loads to grayscale. You can convert all textures to grayscale by using imagemagick, though, so this doesn't exactly have top priority.
There's no place like ::1
User avatar
Lucifer
Project Developer
Posts: 8751
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Er, didn't we all agree arma would be a 2D game? :roll:

I kid, I kid.

So, yeah, cool, but I must reserve some skepticism. I tried this same technique in an asteroids game on my amiga years ago that didn't work. Of course, that was years ago...

Edit: On rereading, it's not clear that I was the player in the asteroids game, not the programmer.
Last edited by Lucifer on Sat Aug 11, 2007 5:04 am, edited 1 time in total.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

Whatever we do to handle colour manipulation, do be sure it's in one function so we can modify the effect globally and not have to make changes in 500 places :)

but that's probably obvious...
User avatar
2020
Outside Corner Grinder
Posts: 1322
Joined: Thu Dec 29, 2005 9:21 pm
Location: the present, finally

Post by 2020 »

gotta get some glasses...
looking forward to returning to the grid on a regular basis...

i hope to get goggles one day
with a visual image for left eye and right eye separately
it wouldn't be too hard to produce the hack for that
would it?
hold the line
Post Reply