BGE: when letterbox is enabled use the camera framing as a clipping area (good for...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 27 Oct 2009 00:25:38 +0000 (00:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 27 Oct 2009 00:25:38 +0000 (00:25 +0000)
source/blender/editors/space_view3d/view3d_view.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

index 12654bd..b108d38 100644 (file)
@@ -1550,7 +1550,7 @@ void game_set_commmandline_options(GameData *gm)
 }
 
 /* maybe we need this defined somewhere else */
-extern void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int always_use_expand_framing);
+extern void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *cam_frame, int always_use_expand_framing);
 
 #endif // GAMEBLENDER == 1
 
@@ -1566,6 +1566,7 @@ static int game_engine_exec(bContext *C, wmOperator *unused)
        bScreen *sc= CTX_wm_screen(C);
        ScrArea *sa, *prevsa= CTX_wm_area(C);
        ARegion *ar, *prevar= CTX_wm_region(C);
+       rcti cam_frame;
 
        sa= prevsa;
        if(sa->spacetype != SPACE_VIEW3D) {
@@ -1592,8 +1593,25 @@ static int game_engine_exec(bContext *C, wmOperator *unused)
        
        game_set_commmandline_options(&startscene->gm);
 
+       if(startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) { /* Letterbox */
+               rctf cam_framef;
+               calc_viewborder(startscene, ar, CTX_wm_view3d(C), &cam_framef);
+               cam_frame.xmin = cam_framef.xmin + ar->winrct.xmin;
+               cam_frame.xmax = cam_framef.xmax + ar->winrct.xmin;
+               cam_frame.ymin = cam_framef.ymin + ar->winrct.ymin;
+               cam_frame.ymax = cam_framef.ymax + ar->winrct.ymin;
+               BLI_isect_rcti(&ar->winrct, &cam_frame, &cam_frame);
+       }
+       else {
+               cam_frame.xmin = ar->winrct.xmin;
+               cam_frame.xmax = ar->winrct.xmax;
+               cam_frame.ymin = ar->winrct.ymin;
+               cam_frame.ymax = ar->winrct.ymax;
+       }
+
+
        SaveState(C);
-       StartKetsjiShell(C, ar, 1);
+       StartKetsjiShell(C, ar, &cam_frame, 1);
        RestoreState(C);
        
        CTX_wm_region_set(C, prevar);
index 5c7e18b..d4421f9 100644 (file)
@@ -120,19 +120,19 @@ static BlendFileData *load_game_data(char *filename)
        return bfd;
 }
 
-extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int always_use_expand_framing)
+extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *cam_frame, int always_use_expand_framing)
 {
        /* context values */
        struct wmWindow *win= CTX_wm_window(C);
        struct Scene *scene= CTX_data_scene(C);
        struct Main* maggie1= CTX_data_main(C);
-       
+
 
        RAS_Rect area_rect;
-       area_rect.SetLeft(ar->winrct.xmin);
-       area_rect.SetBottom(ar->winrct.ymin);
-       area_rect.SetRight(ar->winrct.xmax);
-       area_rect.SetTop(ar->winrct.ymax);
+       area_rect.SetLeft(cam_frame->xmin);
+       area_rect.SetBottom(cam_frame->ymin);
+       area_rect.SetRight(cam_frame->xmax);
+       area_rect.SetTop(cam_frame->ymax);
 
        int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
        Main* blenderdata = maggie1;
@@ -246,14 +246,21 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw
                }
                
                if(rv3d->persp==V3D_CAMOB) {
-                       camzoom = (1.41421 + (rv3d->camzoom / 50.0));
-                       camzoom *= camzoom;
+                       if(scene->gm.framing.type == SCE_GAMEFRAMING_BARS) { /* Letterbox */
+                               camzoom = 1.0f;
+                       }
+                       else {
+                               camzoom = (1.41421 + (rv3d->camzoom / 50.0));
+                               camzoom *= camzoom;
+                               camzoom = 4.0 / camzoom;
+                       }
                }
-               else
+               else {
                        camzoom = 2.0;
+               }
 
-               camzoom = 4.0 / camzoom;
                
+
                ketsjiengine->SetDrawType(v3d->drawtype);
                ketsjiengine->SetCameraZoom(camzoom);
                
@@ -336,6 +343,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw
                                if (blscene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
                                        rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->gm.stereomode);
                        }
+
+                       rasterizer->SetBackColor(blscene->gm.framing.col[0], blscene->gm.framing.col[1], blscene->gm.framing.col[2], 0.0f);
                }
                
                if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
@@ -688,6 +697,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
                        if (blscene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
                                rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->gm.stereomode);
                }
+               rasterizer->SetBackColor(blscene->gm.framing.col[0], blscene->gm.framing.col[1], blscene->gm.framing.col[2], 0.0f);
 
                if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
                {
index 5b732e8..336d805 100644 (file)
@@ -107,11 +107,7 @@ bool RAS_OpenGLRasterizer::Init()
 {
        GPU_state_init();
 
-       m_redback = 0.4375;
-       m_greenback = 0.4375;
-       m_blueback = 0.4375;
-       m_alphaback = 0.0;
-       
+
        m_ambr = 0.0f;
        m_ambg = 0.0f;
        m_ambb = 0.0f;
@@ -128,6 +124,12 @@ bool RAS_OpenGLRasterizer::Init()
        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
+
+       m_redback = 0.4375;
+       m_greenback = 0.4375;
+       m_blueback = 0.4375;
+       m_alphaback = 0.0;
+
        glShadeModel(GL_SMOOTH);
 
        return true;