Revision: 19891
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19891
Author:   dfelinto
Date:     2009-04-23 04:27:11 +0200 (Thu, 23 Apr 2009)

Log Message:
-----------
BGE Dome update:
* Enviroment Map implemented (replacing truncated mode 2).
 - Now it's possible to pre-bake animated (or static) EnvMaps to use with Cube 
Map textures.

* Enabling 2DFilter in Dome mode
 - no GL_DEPTH_BUFFER supported though.

* Tweaking GameSettings menu (centralizing buttons)

Modified Paths:
--------------
    trunk/blender/source/blender/src/buttons_scene.c
    trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp
    trunk/blender/source/gameengine/Ketsji/KX_Dome.h
    trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp

Modified: trunk/blender/source/blender/src/buttons_scene.c
===================================================================
--- trunk/blender/source/blender/src/buttons_scene.c    2009-04-23 01:53:11 UTC 
(rev 19890)
+++ trunk/blender/source/blender/src/buttons_scene.c    2009-04-23 02:27:11 UTC 
(rev 19891)
@@ -1772,7 +1772,7 @@
        block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSS, 
UI_HELV, curarea->win);
 
        /* use this for a fake extra empy space around the buttons */
-       uiDefBut(block, LABEL, 0, "",                   -5, -10, 295, 300, 
NULL, 0, 0, 0, 0, "");
+       uiDefBut(block, LABEL, 0, "",                   -5, -10, 295, 305, 
NULL, 0, 0, 0, 0, "");
 
        uiDefBut(block, LABEL, 0, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, 
"");
        uiBlockBeginAlign(block);
@@ -1787,16 +1787,17 @@
        uiDefButF(block, COL, 0, "",                0, yco - 58 + 18, 33, 58, 
&G.scene->framing.col[0], 0, 0, 0, randomcolorindex, "");
 
        uiBlockBeginAlign(block);
-       uiDefButF(block, NUMSLI, 0, "R ", xco,yco,243,18, 
&G.scene->framing.col[0], 0.0, 1.0, randomcolorindex, 0, "Set the red component 
of the bars");
+       uiDefButF(block, NUMSLI, 0, "R ", xco,yco,240,18, 
&G.scene->framing.col[0], 0.0, 1.0, randomcolorindex, 0, "Set the red component 
of the bars");
        yco -= 20;
-       uiDefButF(block, NUMSLI, 0, "G ", xco,yco,243,18, 
&G.scene->framing.col[1], 0.0, 1.0, randomcolorindex, 0, "Set the green 
component of the bars");
+       uiDefButF(block, NUMSLI, 0, "G ", xco,yco,240,18, 
&G.scene->framing.col[1], 0.0, 1.0, randomcolorindex, 0, "Set the green 
component of the bars");
        yco -= 20;
-       uiDefButF(block, NUMSLI, 0, "B ", xco,yco,243,18, 
&G.scene->framing.col[2], 0.0, 1.0, randomcolorindex, 0, "Set the blue 
component of the bars");
+       uiDefButF(block, NUMSLI, 0, "B ", xco,yco,240,18, 
&G.scene->framing.col[2], 0.0, 1.0, randomcolorindex, 0, "Set the blue 
component of the bars");
        uiBlockEndAlign(block);
        
        xco = 0;
        uiDefBut(block, LABEL, 0, "Fullscreen:",                xco, yco-=30, 
100, 19, 0, 0.0, 0.0, 0, 0, "");
-       uiDefButS(block, TOG, 0, "Fullscreen", xco+70, yco, 68, 19, 
&G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen 
display");
+       uiDefButS(block, TOG, 0, "Fullscreen", xco+74, yco, 68, 19, 
&G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen 
display");
+       xco = 3;
        uiBlockBeginAlign(block);
        uiDefButS(block, NUM, 0, "X:",          xco+40, yco-=27, 100, 19, 
&G.scene->r.xplay, 10.0, 2000.0, 0, 0, "Displays current X screen/window 
resolution. Click to change.");
        uiDefButS(block, NUM, 0, "Y:",          xco+140, yco, 100, 19, 
&G.scene->r.yplay,    10.0, 2000.0, 0, 0, "Displays current Y screen/window 
resolution. Click to change.");
@@ -1816,26 +1817,29 @@
         * RAS_STEREO_VINTERLACE        7
         * RAS_STEREO_DOME              8
         */
+
+       xco = 8;
        uiBlockBeginAlign(block);
        uiDefButS(block, ROW, 0, "No Stereo", xco, yco-=30, 88, 19, 
&(G.scene->r.stereomode), 7.0, 1.0, 0, 0, "Disables stereo");
-       uiDefButS(block, ROW, 0, "Pageflip", xco+=90, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 2.0, 0, 0, "Enables hardware pageflip stereo 
method");
-       uiDefButS(block, ROW, 0, "Syncdouble", xco+=90, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
-       uiDefButS(block, ROW, 0, "Anaglyph", xco-=180, yco-=21, 88, 19, 
&(G.scene->r.stereomode), 7.0, 5.0, 0, 0, "Enables anaglyph (Red-Blue) stereo 
method");
-       uiDefButS(block, ROW, 0, "Side by Side", xco+=90, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 6.0, 0, 0, "Enables side by side left and right 
images");
-       uiDefButS(block, ROW, 0, "V Interlace", xco+=90, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 7.0, 0, 0, "Enables interlaced vertical strips 
for autostereo display");
+       uiDefButS(block, ROW, 0, "Pageflip", xco+90, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 2.0, 0, 0, "Enables hardware pageflip stereo 
method");
+       uiDefButS(block, ROW, 0, "Syncdouble", xco+180, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
+       uiDefButS(block, ROW, 0, "Anaglyph", xco, yco-=21, 88, 19, 
&(G.scene->r.stereomode), 7.0, 5.0, 0, 0, "Enables anaglyph (Red-Blue) stereo 
method");
+       uiDefButS(block, ROW, 0, "Side by Side", xco+90, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 6.0, 0, 0, "Enables side by side left and right 
images");
+       uiDefButS(block, ROW, 0, "V Interlace", xco+180, yco, 88, 19, 
&(G.scene->r.stereomode), 7.0, 7.0, 0, 0, "Enables interlaced vertical strips 
for autostereo display");
        
        uiBlockEndAlign(block);
 
+       xco = 8;
        uiBlockBeginAlign(block);
-       uiDefButS(block, ROW, 0, "Dome", xco-=180, yco-=30, 88, 19, 
&(G.scene->r.stereomode), 7.0, 8.0, 0, 0, "Enables dome camera");
-       uiDefButS(block, NUM, 0, "Ang:",                xco+=90, yco, 88, 19, 
&G.scene->r.domeangle, 90.0, 250.0, 0, 0, "Angle (Aperture) of the Dome - it 
only works in mode 1");
-       uiDefButS(block, NUM, 0, "Mode:",               xco+=90, yco, 88, 19, 
&G.scene->r.domemode, 1.0, 3.0, 0, 0, "Dome mode - 1 fisheye, 2 truncated, 3 
spherical panoramic");
+       uiDefButS(block, ROW, 0, "Dome",        xco, yco-=30, 88, 19, 
&(G.scene->r.stereomode), 7.0, 8.0, 0, 0, "Enables dome camera");
+       uiDefButS(block, NUM, 0, "Ang:",        xco+90, yco, 88, 19, 
&G.scene->r.domeangle, 90.0, 250.0, 0, 0, "Angle (Aperture) of the Dome - it 
only works in mode 1");
+       uiDefButS(block, NUM, 0, "Mode:",       xco+180, yco, 88, 19, 
&G.scene->r.domemode, 1.0, 3.0, 0, 0, "1 fisheye, 2 environment map, 3 
spherical panoramic");
 
-       uiDefButF(block, NUM, 0, "Size:",               xco-=180, yco-=21, 88, 
19, &G.scene->r.domesize, 0.5, 3.5, 0, 0, "Size adjustments");
-       uiDefButS(block, NUM, 0, "Tes:",                xco+=90, yco, 88, 19, 
&G.scene->r.domeres, 1.0, 8.0, 0, 0, "Tesselation level - 1 to 8");
-       uiDefButF(block, NUM, 0, "Res:",        xco+=90, yco, 88, 19, 
&G.scene->r.domeresbuf, 0.1, 1.0, 0, 0, "Buffer Resolution - decrease it to 
increase speed");
+       uiDefButF(block, NUM, 0, "Size:",       xco, yco-=21, 88, 19, 
&G.scene->r.domesize, 0.5, 3.5, 0, 0, "Size adjustments");
+       uiDefButS(block, NUM, 0, "Tes:",        xco+90, yco, 88, 19, 
&G.scene->r.domeres, 1.0, 8.0, 0, 0, "Tesselation level - 1 to 8");
+       uiDefButF(block, NUM, 0, "Res:",        xco+180, yco, 88, 19, 
&G.scene->r.domeresbuf, 0.1, 1.0, 0, 0, "Buffer Resolution - decrease it to 
increase speed");
 
-       uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Warp Data: ", 
xco-180,yco-=21,268, 19, &G.scene->r.dometext, "Custom Warp Mesh data file");
+       uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Warp Data: ", 
xco,yco-=21,268, 19, &G.scene->r.dometext, "Custom Warp Mesh data file");
        uiBlockEndAlign(block);
 
        uiBlockSetDirection(block, UI_TOP);

Modified: trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp  2009-04-23 01:53:11 UTC 
(rev 19890)
+++ trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp  2009-04-23 02:27:11 UTC 
(rev 19891)
@@ -107,15 +107,9 @@
                                CreateMeshDome250();
                                m_numfaces = 5;
                        } break;
-               case DOME_TRUNCATED:
-                       cubetop.resize(1);
-                       cubebottom.resize(1);
-                       cubeleft.resize(2);
-                       cuberight.resize(2);
-
-                       m_angle = 180;
-                       CreateMeshDome180();
-                       m_numfaces = 4;
+               case DOME_ENVMAP:
+                       m_angle = 360;
+                       m_numfaces = 6;
                        break;
                case DOME_PANORAM_SPH:
                        cubeleft.resize(2);
@@ -240,7 +234,7 @@
 
        dlistId = glGenLists((GLsizei) m_numimages);
        if (dlistId != 0) {
-               if(m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED){
+               if(m_mode == DOME_FISHEYE){
                        glNewList(dlistId, GL_COMPILE);
                                GLDrawTriangles(cubetop, nfacestop);
                        glEndList();
@@ -386,7 +380,7 @@
                }
                glEnd();
        } else{
-               printf("Error: Warp Mode unsupported. Try 1 for Polar Mesh or 2 
for Fisheye.\n");
+               printf("Error: Warp Mode %d unsupported. Try 1 for Polar Mesh 
or 2 for Fisheye.\n", warp.mode);
        }
 }
 
@@ -1415,7 +1409,7 @@
        MT_Scalar c = cos(deg45);
        MT_Scalar s = sin(deg45);
 
-       if ((m_mode == DOME_FISHEYE && m_angle <= 180)|| m_mode == 
DOME_TRUNCATED){
+       if ((m_mode == DOME_FISHEYE && m_angle <= 180)){
 
                m_locRot[0] = MT_Matrix3x3( // 90\xBA - Top
                                                c, -s, 0.0,
@@ -1437,7 +1431,7 @@
                                                0.0, 1.0, 0.0,
                                                s, 0.0, c);
 
-       } else if ((m_mode == DOME_FISHEYE && m_angle > 180)){
+       } else if ((m_mode == DOME_FISHEYE && m_angle > 180) || m_mode == 
DOME_ENVMAP){
 
                m_locRot[0] = MT_Matrix3x3( // 90\xBA - Top
                                                 1.0, 0.0, 0.0,
@@ -1464,7 +1458,7 @@
                                                0.0, 1.0, 0.0,
                                                0.0, 0.0, 1.0);
 
-               m_locRot[5] = MT_Matrix3x3( // 180\xBA - Back - NOT USING
+               m_locRot[5] = MT_Matrix3x3( // 180\xBA - Back - USED for ENVMAP 
only
                                                -1.0, 0.0, 0.0,
                                                 0.0, 1.0, 0.0,
                                                 0.0, 0.0,-1.0);
@@ -1531,8 +1525,8 @@
                case DOME_FISHEYE:
                        DrawDomeFisheye();
                        break;
-               case DOME_TRUNCATED:
-                       DrawDomeFisheye();
+               case DOME_ENVMAP:
+                       DrawEnvMap();
                        break;
                case DOME_PANORAM_SPH:
                        DrawPanorama();
@@ -1547,7 +1541,7 @@
        }
 }
 
-void KX_Dome::DrawDomeFisheye(void)
+void KX_Dome::DrawEnvMap(void)
 {
        int i,j;
 
@@ -1563,17 +1557,141 @@
        float ortho_width, ortho_height;
 
        if (warp.usemesh)
-               glOrtho((-1.0), 1.0, (-1.0), 1.0, -20.0, 10.0); //stretch the 
image to reduce resolution lost
+               glOrtho((-1.0), 1.0, (-0.66), 0.66, -20.0, 10.0); //stretch the 
image to reduce resolution lost
 
-       else if(m_mode == DOME_TRUNCATED){
-               ortho_width = 1.0;
-               ortho_height = 2 * ((float)can_height/can_width) - 1.0 ;
+       else {
+               if (can_width/3 <= can_height/2){
+                       ortho_width = 1.0;
+                       ortho_height = (float)can_height/can_width;
+               }else{
+                       ortho_height = 2.0f / 3;
+                       ortho_width = (float)can_width/can_height * 
ortho_height;
+               }
                
                ortho_width /= m_size;
                ortho_height /= m_size;
+               
+               glOrtho((-ortho_width), ortho_width, (-ortho_height), 
ortho_height, -20.0, 10.0);
+       }
 
-               glOrtho((-ortho_width), ortho_width, (-ortho_height), 
ortho_width, -20.0, 10.0);
-       } else {
+       glMatrixMode(GL_TEXTURE);
+       glLoadIdentity();
+       glMatrixMode(GL_MODELVIEW);
+       glLoadIdentity();
+       gluLookAt(0.0,0.0,1.0, 0.0,0.0,0.0, 0.0,1.0,0.0);
+
+       glPolygonMode(GL_FRONT, GL_FILL);
+       glShadeModel(GL_SMOOTH);
+       glDisable(GL_LIGHTING);
+       glDisable(GL_DEPTH_TEST);
+
+       glEnable(GL_TEXTURE_2D);
+       glColor3f(1.0,1.0,1.0);
+
+       float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
+       double onebythree = 1.0f / 3;
+
+       // domefacesId[0] =>  (top)
+       glBindTexture(GL_TEXTURE_2D, domefacesId[0]);
+       glBegin(GL_QUADS);
+               glTexCoord2f(uv_ratio,uv_ratio);
+               glVertex3f( onebythree, 0.0f, 3.0f);
+               glTexCoord2f(0.0,uv_ratio);
+               glVertex3f(-onebythree, 0.0f, 3.0f);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to