Changeset 119

Show
Ignore:
Timestamp:
08/16/10 21:15:24 (18 months ago)
Author:
Carsten
Message:

Re-established most of the client functionality:

Location:
cafu/branches/cafu_to_wx
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • cafu/branches/cafu_to_wx/Ca3DE/Client/ClientStateInGame.cpp

    r116 r119  
    383383            Graphs.PosZ   [ClientFrameNr & (512-1)]=((unsigned short)(OurEntityCurrentState->Origin.z/20.0)) & 511; 
    384384 
     385            MatSys::Renderer->PushMatrix(MatSys::RendererI::PROJECTION    ); 
     386            MatSys::Renderer->PushMatrix(MatSys::RendererI::MODEL_TO_WORLD); 
     387            MatSys::Renderer->PushMatrix(MatSys::RendererI::WORLD_TO_VIEW ); 
     388 
     389            MatSys::Renderer->SetMatrix(MatSys::RendererI::PROJECTION, 
     390                // Note that the far plane is located at infinity for our stencil shadows implementation! 
     391                // A fovY of 67.5 corresponds to a fovX of 90.0 when the aspect ratio is 4:3. 
     392                MatrixT::GetProjPerspectiveMatrix(67.5f, float(FrameSize.GetWidth())/float(FrameSize.GetHeight()), 100.0f, -1.0f)); 
     393 
     394            MatSys::Renderer->SetMatrix(MatSys::RendererI::MODEL_TO_WORLD, MatrixT()); 
     395            MatSys::Renderer->SetMatrix(MatSys::RendererI::WORLD_TO_VIEW,  MatrixT()); 
     396 
    385397            World->Draw(FrameTime, OurEntityCurrentState); 
     398 
     399            MatSys::Renderer->PopMatrix(MatSys::RendererI::PROJECTION    ); 
     400            MatSys::Renderer->PopMatrix(MatSys::RendererI::MODEL_TO_WORLD); 
     401            MatSys::Renderer->PopMatrix(MatSys::RendererI::WORLD_TO_VIEW ); 
    386402 
    387403            // Die Framerate ist zwar World-unabhängig, ihre Anzeige hier aber besser aufgehoben (aus rein kosmetischen Gründen). 
     
    811827    if (World) 
    812828    { 
    813         cf::GuiSys::GuiI* ActiveGui=cf::GuiSys::GuiMan->GetTopmostActiveAndInteractive(); 
     829        cf::GuiSys::GuiI*  ActiveGui =cf::GuiSys::GuiMan->GetTopmostActiveAndInteractive(); 
     830        const wxMouseState MouseState=wxGetMouseState(); 
    814831        assert(ActiveGui!=NULL);    // The GUI of the client for the world output must always be there. 
    815832 
    816833        // This is unfortunately needed, because the users last click (in the GUI) that brought us here may still have the "LMB up" event pending. 
    817 #if 0 
    818         WasLMBOnceUp|=(SingleOpenGLWindow->GetMouseButtonState() & 0x1)==0; 
     834        WasLMBOnceUp=WasLMBOnceUp || !MouseState.LeftIsDown(); 
    819835 
    820836        // FIXME: Should test for ActiveGui==ClientGui instead of ActiveGui->GetScriptName()=="". 
    821837        if (ActiveGui->GetScriptName()=="" && WasLMBOnceUp) 
    822838        { 
    823             if (SingleOpenGLWindow->GetMouseButtonState() & 0x1) PlayerCommand.Keys|=PCK_Fire1;  // Button 0 
    824             if (SingleOpenGLWindow->GetMouseButtonState() & 0x6) PlayerCommand.Keys|=PCK_Fire2;  // Button 1 oder 2 
     839            if (MouseState.LeftIsDown())                               PlayerCommand.Keys|=PCK_Fire1; 
     840            if (MouseState.MiddleIsDown() || MouseState.RightIsDown()) PlayerCommand.Keys|=PCK_Fire2; 
    825841 
    826842            // Alle anderen Keys via KeyboardState bestimmen und über die volle Frametime anwenden. 
     
    828844            // Mit anderen Worten: Diesen Kram mit in die obige Buffer-Schleife nehmen! 
    829845            // Player movement / state 
    830          // if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_RCONTROL   ]) ;                                       // R_Strg   Run 
    831             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_RSHIFT     ] ||                                       // R_Shift  Stealth 
    832                 SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_LSHIFT     ]) PlayerCommand.Keys|=PCK_Walk;           // L_Shift  Stealth 
    833             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_UP         ] ||                                       // Up       Walk forward 
    834                 SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_W          ]) PlayerCommand.Keys|=PCK_MoveForward;    // W        Walk forward 
    835             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_DOWN       ] ||                                       // Down     Walk backward 
    836                 SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_S          ]) PlayerCommand.Keys|=PCK_MoveBackward;   // S        Walk backward 
    837             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_A          ] ||                                       // A        Strafe left 
    838                 SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_COMMA      ]) PlayerCommand.Keys|=PCK_StrafeLeft;     // ,        Strafe left 
    839             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_D          ] ||                                       // D        Strafe right 
    840                 SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_PERIOD     ]) PlayerCommand.Keys|=PCK_StrafeRight;    // .        Strafe right 
    841             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_R          ]) PlayerCommand.Keys|=PCK_Fire1;          // R        Fire/Respawn 
    842             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_RETURN     ] ||                                       // RETURN   Use 
    843                 SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_NUMPADENTER]) PlayerCommand.Keys|=PCK_Use;            // ENTER    Use 
    844             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_LEFT       ]) PlayerCommand.Keys|=PCK_TurnLeft;       // Left     Turn left 
    845             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_RIGHT      ]) PlayerCommand.Keys|=PCK_TurnRight;      // Right    Turn right 
    846             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_PGDN       ]) PlayerCommand.Keys|=PCK_LookUp;         //          Look up 
    847             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_PGUP       ]) PlayerCommand.Keys|=PCK_LookDown;       //          Look down 
    848          // if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_HOME       ]) PlayerCommand.Keys|=PCK_BankCW          //          Bank CW 
    849          // if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_INSERT     ]) PlayerCommand.Keys|=PCK_BankCCW;        //          Bank CCW 
    850             if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_END        ]) PlayerCommand.Keys|=PCK_CenterView; 
    851         } 
    852 #endif 
     846         // if (wxGetKeyState(WXK_CONTROL)     ) ;                                       // R_Strg   Run 
     847            if (wxGetKeyState(WXK_SHIFT)       ) PlayerCommand.Keys|=PCK_Walk;           // Shift  Stealth 
     848            if (wxGetKeyState(WXK_UP) ||                                                 // Up       Walk forward 
     849                wxGetKeyState(wxKeyCode('W'))  ) PlayerCommand.Keys|=PCK_MoveForward;    // W        Walk forward 
     850            if (wxGetKeyState(WXK_DOWN) ||                                               // Down     Walk backward 
     851                wxGetKeyState(wxKeyCode('S'))  ) PlayerCommand.Keys|=PCK_MoveBackward;   // S        Walk backward 
     852            if (wxGetKeyState(wxKeyCode('A')) ||                                         // A        Strafe left 
     853                wxGetKeyState(wxKeyCode(','))  ) PlayerCommand.Keys|=PCK_StrafeLeft;     // ,        Strafe left 
     854            if (wxGetKeyState(wxKeyCode('D')) ||                                         // D        Strafe right 
     855                wxGetKeyState(wxKeyCode('.'))  ) PlayerCommand.Keys|=PCK_StrafeRight;    // .        Strafe right 
     856            if (wxGetKeyState(wxKeyCode('R'))  ) PlayerCommand.Keys|=PCK_Fire1;          // R        Fire/Respawn 
     857            if (wxGetKeyState(WXK_RETURN) ||                                             // RETURN   Use 
     858                wxGetKeyState(WXK_NUMPAD_ENTER)) PlayerCommand.Keys|=PCK_Use;            // ENTER    Use 
     859            if (wxGetKeyState(WXK_LEFT        )) PlayerCommand.Keys|=PCK_TurnLeft;       // Left     Turn left 
     860            if (wxGetKeyState(WXK_RIGHT       )) PlayerCommand.Keys|=PCK_TurnRight;      // Right    Turn right 
     861            if (wxGetKeyState(WXK_PAGEDOWN    )) PlayerCommand.Keys|=PCK_LookUp;         //          Look up 
     862            if (wxGetKeyState(WXK_PAGEUP      )) PlayerCommand.Keys|=PCK_LookDown;       //          Look down 
     863         // if (wxGetKeyState(WXK_HOME        )) PlayerCommand.Keys|=PCK_BankCW          //          Bank CW 
     864         // if (wxGetKeyState(WXK_INSERT      )) PlayerCommand.Keys|=PCK_BankCCW;        //          Bank CCW 
     865            if (wxGetKeyState(WXK_END         )) PlayerCommand.Keys|=PCK_CenterView; 
     866        } 
    853867 
    854868 
  • cafu/branches/cafu_to_wx/Ca3DE/Client/ClientWindow.cpp

    r36 r119  
    7777{ 
    7878    // Call the clients render methods here. 
    79  
    80     // We don't want want ortho rendering here, so setup a perspective projection matrix. 
    81     // TODO 1: Move this into the world rendering code?? 
    82     // TODO 2: Should actually *push* the matrices, properly *set* them and below *pop* them!! 
    83     //         Also see the TODO in GuiManImplT::RenderAll() for more details!! 
    84     MatSys::Renderer->PopMatrix(MatSys::RendererI::PROJECTION    ); 
    85     MatSys::Renderer->PopMatrix(MatSys::RendererI::MODEL_TO_WORLD); 
    86     MatSys::Renderer->PopMatrix(MatSys::RendererI::WORLD_TO_VIEW ); 
    87  
    8879    Client->Render(LastFrameTime); 
    89  
    90     MatSys::Renderer->PushMatrix(MatSys::RendererI::PROJECTION    ); 
    91     MatSys::Renderer->PushMatrix(MatSys::RendererI::MODEL_TO_WORLD); 
    92     MatSys::Renderer->PushMatrix(MatSys::RendererI::WORLD_TO_VIEW ); 
    9380} 
    9481 
  • cafu/branches/cafu_to_wx/Ca3DE/MainCanvas.cpp

    r116 r119  
    2828#include "Server/Server.hpp" 
    2929 
     30#include "Bitmap/Bitmap.hpp" 
    3031#include "ClipSys/CollisionModelMan.hpp" 
    3132#include "ConsoleCommands/Console.hpp" 
     
    7071    EVT_IDLE(MainCanvasT::OnIdle) 
    7172    EVT_SIZE(MainCanvasT::OnSize) 
    72     // EVT_SHOW(MainCanvasT::OnShow) 
    7373 
    7474    EVT_MOTION    (MainCanvasT::OnMouseMove ) 
     
    433433 
    434434 
     435static const char* ScreenShotSuffixTypes[] = { "jpg", "png", "bmp", NULL }; 
     436static ConVarT ScreenShotSuffix("screenSuffix", "jpg", ConVarT::FLAG_MAIN_EXE, "The suffix to be used for screen-shot image files. Only \"jpg\", \"png\" and \"bmp\" are allowed.", ScreenShotSuffixTypes); 
     437 
     438 
     439void MainCanvasT::TakeScreenshot() const 
     440{ 
     441    const unsigned int      Width =GetClientSize().GetWidth(); 
     442    const unsigned int      Height=GetClientSize().GetHeight(); 
     443    static ArrayT<uint32_t> FrameBuffer; 
     444 
     445    FrameBuffer.Overwrite(); 
     446    FrameBuffer.PushBackEmpty(Width*Height); 
     447 
     448    // Read the pixels fromt the OpenGL back buffer into FrameBuffer. 
     449    // Note that the first two parameters (0, 0) specify the left BOTTOM corner of the desired rectangle! 
     450    glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &FrameBuffer[0]); 
     451 
     452    // As mentioned above is the data in the FrameBuffer bottom-up. 
     453    // Thus now swap all lines (vertical mirroring). 
     454    for (unsigned int y=0; y<Height/2; y++) 
     455    { 
     456        uint32_t* UpperRow=&FrameBuffer[0]+        y   *Width; 
     457        uint32_t* LowerRow=&FrameBuffer[0]+(Height-y-1)*Width; 
     458 
     459        for (unsigned int x=0; x<Width; x++) 
     460        { 
     461            const uint32_t Swap=*UpperRow; 
     462 
     463            *UpperRow=*LowerRow; 
     464            *LowerRow=Swap; 
     465 
     466            UpperRow++; 
     467            LowerRow++; 
     468        } 
     469    } 
     470 
     471    // Find the next free image name and save the file. 
     472    for (unsigned int Nr=0; Nr<100000; Nr++) 
     473    { 
     474        const wxString FileName=wxString::Format("pic%04u", Nr) + "." + ScreenShotSuffix.GetValueString(); 
     475 
     476        if (!wxFileExists(FileName)) 
     477        { 
     478            if (BitmapT(Width, Height, &FrameBuffer[0]).SaveToDisk(FileName)) 
     479            { 
     480                Console->Print(std::string("Screenshot \"")+FileName.ToStdString()+"\" saved.\n"); 
     481            } 
     482            else 
     483            { 
     484                Console->Warning(std::string("Screenshot \"")+FileName.ToStdString()+"\" could not be saved.\n"); 
     485            } 
     486            return; 
     487        } 
     488    } 
     489} 
     490 
     491 
    435492void MainCanvasT::OnPaint(wxPaintEvent& PE) 
    436493{ 
    437494    wxPaintDC dc(this);     // It is VERY important not to omit this, or otherwise everything goes havoc. 
    438495 
    439     if (m_InitState==INIT_REQUIRED) Initialize(); 
     496    if (m_InitState==INIT_REQUIRED) 
     497    { 
     498        // This code is in this place due to a few peculiarities of OpenGL under GTK that do not exist under MSW: 
     499        //   - An OpenGL context can only be made current with a canvas that is shown on the screen. 
     500        //   - Relying on EVT_SHOW however is not a good approach, see the discussions at 
     501        //     <http://thread.gmane.org/gmane.comp.lib.wxwidgets.general/68490> and 
     502        //     <http://thread.gmane.org/gmane.comp.lib.wxwidgets.general/70607> for details. 
     503        // Consequently, the first and best opportunity for initialization is here. 
     504        Initialize(); 
     505    } 
    440506} 
    441507 
     
    457523 
    458524    // Beende das Programm, wenn das letzte aktive GUI geschlossen wurde. 
    459     // if (cf::GuiSys::GuiMan->GetNumberOfActiveGUIs()==0) Close(); 
     525    // if (cf::GuiSys::GuiMan->GetNumberOfActiveGUIs()==0) m_Parent->Close(); 
    460526 
    461527    static ConVarT quit("quit", false, ConVarT::FLAG_MAIN_EXE, "The program quits if this variable is set to 1 (true)."); 
     
    463529    { 
    464530        quit.SetValue(false);   // Immediately reset the value, so that we're able to restart the game from a loop that governs the master loop... 
    465         Close(); 
     531        m_Parent->Close(); 
    466532    } 
    467533 
     
    503569    if (m_Server) m_Server->MainLoop(); 
    504570} 
    505  
    506  
    507 // void MainCanvasT::OnShow(wxShowEvent& SE) 
    508 // { 
    509 //     wxMessageBox(wxString::Format("%i %i", SE.IsShown(), m_IsInited)); 
    510 //     if (SE.IsShown() && !m_IsInited) 
    511 //     { 
    512 //         // This code is in this place due to a few peculiarities of OpenGL under GTK that do not exist under MSW: 
    513 //         //   - First, an OpenGL context can only be made current with a canvas that is shown on the screen. 
    514 //         //   - Second, calling Show() in the ctor above doesn't show the frame immediately - that requires 
    515 //         //     getting back to the main event loop first. 
    516 //         // Consequently, the first and best opportunity for initializing the MatSys is here. 
    517 //         Initialize(); 
    518 //     } 
    519 // } 
    520571 
    521572 
     
    745796void MainCanvasT::OnKeyDown(wxKeyEvent& KE) 
    746797{ 
     798    if (m_InitState!=INIT_SUCCESS) return; 
     799 
     800    switch (KE.GetKeyCode()) 
     801    { 
     802        case WXK_F1: 
     803        { 
     804            // Activate the in-game console GUI (it's "F1" now, not CK_GRAVE ("^", accent grave) any longer). 
     805            extern ConVarT    Options_ServerGameName; 
     806            cf::GuiSys::GuiI* ConsoleGui=cf::GuiSys::GuiMan->Find("Games/"+Options_ServerGameName.GetValueString()+"/GUIs/Console.cgui"); 
     807 
     808            // ConsoleGui should be the same as in Initialize(), but could be NULL on file not found, parse error, etc. 
     809            if (ConsoleGui!=NULL && !ConsoleGui->GetIsActive()) 
     810            { 
     811                ConsoleGui->Activate(); 
     812                cf::GuiSys::GuiMan->BringToFront(ConsoleGui); 
     813 
     814                static bool InitialHelpMsgPrinted=false; 
     815 
     816                if (!InitialHelpMsgPrinted) 
     817                { 
     818                    Console->Print("\n"); 
     819                    Console->Print("Welcome to the Cafu console!\n"); 
     820                    Console->Print("Enter   help()   to obtain more information.\n"); 
     821                    Console->Print("\n"); 
     822                    InitialHelpMsgPrinted=true; 
     823                } 
     824 
     825                // Handled the key. 
     826                return; 
     827            } 
     828 
     829            // Let the active GUI handle the key below (e.g. for closing the console again). 
     830            break; 
     831        } 
     832 
     833        case WXK_F5: 
     834        { 
     835            TakeScreenshot(); 
     836            return; 
     837        } 
     838    } 
     839 
    747840    // Look for the pressed keys keycode in the table and translate it to a CaKeyCode if found. 
    748841    for (int KeyCodeNr=0; KeyCodes[KeyCodeNr].wxKC!=0; KeyCodeNr++) 
     
    756849 
    757850            cf::GuiSys::GuiMan->ProcessDeviceEvent(KeyboardEvent); 
    758             return; 
     851            // We should probably return here if the GuiMan handled the key, break (only when unhandled) for calling KE.Skip() otherwise. 
     852            break; 
    759853        } 
    760854    } 
     
    766860void MainCanvasT::OnKeyUp(wxKeyEvent& KE) 
    767861{ 
     862    if (m_InitState!=INIT_SUCCESS) return; 
     863 
    768864    // Look for the released keys keycode in the table and translate it to a CaKeyCode if found. 
    769865    for (int KeyCodeNr=0; KeyCodes[KeyCodeNr].wxKC!=0; KeyCodeNr++) 
     
    787883void MainCanvasT::OnKeyChar(wxKeyEvent& KE) 
    788884{ 
     885    if (m_InitState!=INIT_SUCCESS) return; 
     886 
    789887    CaKeyboardEventT KeyboardEvent; 
    790888 
  • cafu/branches/cafu_to_wx/Ca3DE/MainCanvas.hpp

    r116 r119  
    5959 
    6060    void Initialize(); 
     61    void TakeScreenshot() const; 
    6162 
    6263    void OnPaint(wxPaintEvent& PE); 
    6364    void OnSize(wxSizeEvent& SE); 
    6465    void OnIdle(wxIdleEvent& IE);   ///< The idle event handler runs one frame of the Cafu Engine (client and/or server). 
    65  // void OnShow(wxShowEvent& SE);   ///< Event handler for "has been shown" events. 
    6666 
    6767    void OnMouseMove (wxMouseEvent& ME); 
  • cafu/branches/cafu_to_wx/Libs/GuiSys/GuiManImpl.cpp

    r36 r119  
    174174    } 
    175175 
    176     // Render the GUIs in back-to-front order. 
     176    // We assume that the caller doesn't expect us to preserve (push/pop) the matrices... 
     177    const float zNear=0.0f; 
     178    const float zFar =1.0f; 
     179    MatSys::Renderer->SetMatrix(MatSys::RendererI::PROJECTION,     MatrixT::GetProjOrthoMatrix(0.0f, VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y, 0.0f, zNear, zFar)); 
     180    MatSys::Renderer->SetMatrix(MatSys::RendererI::MODEL_TO_WORLD, MatrixT()); 
     181    MatSys::Renderer->SetMatrix(MatSys::RendererI::WORLD_TO_VIEW,  MatrixT()); 
     182 
     183    // Render the active GUIs in back-to-front order. 
    177184    for (unsigned long GuiNr=StartGuiNr; GuiNr<Guis.Size(); GuiNr++) 
    178185    { 
    179         // TODO: 
    180         // 1) Remove the next (no-comment-) line. 
    181         // 2) Move the matrix push, set and pop code out of this loop! 
    182         // 3) Fix the clients ClientWindowT::Render() method by fixing the matrix setup code inside it 
    183         //    (it probably belongs into the world rendering method anyway)!! 
    184         if (!Guis[GuiNr]->GetIsActive()) continue; 
    185  
    186         // Setup the matrices. 
    187         MatSys::Renderer->PushMatrix(MatSys::RendererI::PROJECTION    ); 
    188         MatSys::Renderer->PushMatrix(MatSys::RendererI::MODEL_TO_WORLD); 
    189         MatSys::Renderer->PushMatrix(MatSys::RendererI::WORLD_TO_VIEW ); 
    190  
    191         const float zNear=0.0f; 
    192         const float zFar =1.0f; 
    193         MatSys::Renderer->SetMatrix(MatSys::RendererI::PROJECTION,     MatrixT::GetProjOrthoMatrix(0.0f, VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y, 0.0f, zNear, zFar)); 
    194         MatSys::Renderer->SetMatrix(MatSys::RendererI::MODEL_TO_WORLD, MatrixT()); 
    195         MatSys::Renderer->SetMatrix(MatSys::RendererI::WORLD_TO_VIEW,  MatrixT()); 
    196  
    197         if (Guis[GuiNr]->GetIsActive()) Guis[GuiNr]->Render(); 
    198  
    199         // Restore the previously active matrices. 
    200         MatSys::Renderer->PopMatrix(MatSys::RendererI::PROJECTION    ); 
    201         MatSys::Renderer->PopMatrix(MatSys::RendererI::MODEL_TO_WORLD); 
    202         MatSys::Renderer->PopMatrix(MatSys::RendererI::WORLD_TO_VIEW ); 
     186        if (Guis[GuiNr]->GetIsActive()) 
     187            Guis[GuiNr]->Render(); 
    203188    } 
    204189} 
  • cafu/branches/cafu_to_wx/Libs/Math3D/Matrix.cpp

    r96 r119  
    6666MatrixT MatrixT::GetProjPerspectiveMatrix(float fovY, float aspect, float zNear, float zFar) 
    6767{ 
     68    if (zFar<=zNear) 
     69    { 
     70        // If zFar <= zNear, the far plane is assumed to be at infinity (a useful special case for stencil shadow projections). 
     71        // This code is also used in <http://trac.cafu.de/browser/cafu/trunk/Libs/OpenGL/OpenGLWindow.cpp?rev=100#L137>. 
     72        const float cotanFovY=1.0f/tan(fovY*3.14159265358979323846f/360.0f); 
     73 
     74        return MatrixT( 
     75            cotanFovY/aspect,      0.0f,  0.0f,        0.0f, 
     76                        0.0f, cotanFovY,  0.0f,        0.0f, 
     77                        0.0f,      0.0f, -1.0f, -2.0f*zNear, 
     78                        0.0f,      0.0f, -1.0f,        0.0f); 
     79    } 
     80 
    6881    const float ymax= zNear*float(tan(fovY*3.14159265358979323846f/360.0f)); 
    6982    const float ymin=-ymax; 
  • cafu/branches/cafu_to_wx/SConscript

    r116 r119  
    5151                       + Split("gdi32 glu32 opengl32 user32") + ['cfsOpenGL', 'dinput', 'dxguid']) 
    5252elif sys.platform=="linux2": 
    53     # envTools.Append(LINKFLAGS = ['-Wl,--export-dynamic'])     # Not needed any more, .so libs now link to the required .a libs directly, just as under Windows. 
     53    # envTools.Append(LINKFLAGS=['-Wl,--export-dynamic'])       # Not needed any more, .so libs now link to the required .a libs directly, just as under Windows. 
    5454    # GLU is needed for the TerrainViewerOld *and* for e.g. gluBuild2DMipmaps() in the renderers... 
    5555    envTools.Append(CPPPATH=['/usr/include/freetype2'])         # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details. 
     
    8282    wxPath="#/ExtLibs/wxWidgets"; 
    8383 
    84     wxEnv.Append(CPPPATH = [wxPath+'/include']) 
     84    wxEnv.Append(CPPPATH=[wxPath+'/include']) 
     85    wxEnv.Append(LIBS=Split("advapi32 comctl32 comdlg32 gdi32 ole32 oleaut32 opengl32 rpcrt4 shell32 user32 winspool wsock32")) 
    8586 
    8687    # TODO: Move this into the SConstruct file (including the wx include path above). 
     
    9697    LibPath += "_lib" 
    9798 
    98     wxEnv.Append(LIBPATH = [wxPath+LibPath]) 
     99    wxEnv.Append(LIBPATH=[wxPath+LibPath]) 
    99100 
    100101    if buildMode=="dbg": 
    101         wxEnv.Append(CPPPATH = [wxPath+LibPath+"/mswud"]) 
    102         wxEnv.Append(LIBS = Split("wxbase29ud wxbase29ud_net wxjpegd wxmsw29ud_adv wxmsw29ud_core wxmsw29ud_gl wxmsw29ud_aui wxmsw29ud_propgrid wxregexud")) 
     102        wxEnv.Append(CPPPATH=[wxPath+LibPath+"/mswud"]) 
     103        wxEnv.Append(LIBS=Split("wxbase29ud wxbase29ud_net wxjpegd wxmsw29ud_adv wxmsw29ud_core wxmsw29ud_gl wxmsw29ud_aui wxmsw29ud_propgrid wxregexud")) 
    103104    else: 
    104         wxEnv.Append(CPPPATH = [wxPath+LibPath+"/mswu"]) 
    105         wxEnv.Append(LIBS = Split("wxbase29u wxbase29u_net wxjpeg wxmsw29u_adv wxmsw29u_core wxmsw29u_gl wxmsw29u_aui wxmsw29u_propgrid wxregexu")) 
     105        wxEnv.Append(CPPPATH=[wxPath+LibPath+"/mswu"]) 
     106        wxEnv.Append(LIBS=Split("wxbase29u wxbase29u_net wxjpeg wxmsw29u_adv wxmsw29u_core wxmsw29u_gl wxmsw29u_aui wxmsw29u_propgrid wxregexu")) 
    106107 
    107108elif sys.platform=="linux2": 
    108109    # Geht es auch ohne die naechste Zeile? Woher weiss es, dass es freetype linken soll??? 
    109     wxEnv.Append(LIBS = Split("wx_gtk2u_gl-2.9 wx_gtk2u_aui-2.9 wx_gtk2u_propgrid-2.9 wx_gtk2u_xrc-2.9 wx_gtk2u_qa-2.9 wx_gtk2u_html-2.9 wx_gtk2u_adv-2.9 wx_gtk2u_core-2.9 wx_baseu_xml-2.9 wx_baseu_net-2.9 wx_baseu-2.9")) 
     110    wxEnv.Append(LIBS=Split("wx_gtk2u_gl-2.9 wx_gtk2u_aui-2.9 wx_gtk2u_propgrid-2.9 wx_gtk2u_xrc-2.9 wx_gtk2u_qa-2.9 wx_gtk2u_html-2.9 wx_gtk2u_adv-2.9 wx_gtk2u_core-2.9 wx_baseu_xml-2.9 wx_baseu_net-2.9 wx_baseu-2.9")) 
    110111    wxEnv.ParseConfig(Dir("#/ExtLibs/wxWidgets").abspath + "/build-gtk/wx-config --cxxflags --libs std,gl") 
    111112 
     
    117118if sys.platform=="win32": 
    118119    envCafu.Append(LIBS=Split("SceneGraph MatSys SoundSys cfsLib cfsCoreLib cfs_png cfs_jpeg bulletcollision minizip z lua ClipSys GuiSysNullEditor")) 
    119     envCafu.Append(LIBS=Split("lightwave"))    # For the GuiSys::ModelWindowT class. 
    120     envCafu.Append(LIBS=Split("advapi32 comctl32 comdlg32 gdi32 ole32 oleaut32 opengl32 rpcrt4 shell32 user32 winspool wsock32")) 
     120    envCafu.Append(LIBS=Split("lightwave"))     # For the GuiSys::ModelWindowT class. 
    121121 
    122     WinResource=envCafu.RES("Ca3DE/Cafu.rc")    # + envCafu.RES("Ca3DE/Dialog1.rc") 
     122    WinResource = envCafu.RES("Ca3DE/Cafu.rc")  # + envCafu.RES("Ca3DE/Dialog1.rc") 
    123123 
    124124elif sys.platform=="linux2": 
    125125    # -Wl,-rpath,.           is so that also the . directory is searched for dynamic libraries when they're opened. 
    126126    # -Wl,--export-dynamic   is so that the exe exports its symbols so that the MatSys, SoundSys and game .so libs can in turn resolve theirs. 
    127     envCafu.Append(LINKFLAGS = ['-Wl,-rpath,.', '-Wl,--export-dynamic']) 
     127    envCafu.Append(LINKFLAGS=['-Wl,-rpath,.', '-Wl,--export-dynamic']) 
    128128    envCafu.Append(LIBS=Split("MatSys SoundSys SceneGraph cfsLib cfsCoreLib cfs_png cfs_jpeg bulletdynamics bulletcollision bulletmath openal alut mpg123 ogg vorbis vorbisfile minizip z lua lightwave ClipSys GuiSysNullEditor")) 
    129129 
     
    152152    envCafu.Append(LINKCOM=" -Wl,--allow-multiple-definition -Wl,--whole-archive -lcfsLib -lbulletdynamics -lbulletcollision -lbulletmath -lopenal -lalut -lmpg123 -logg -lvorbis -lvorbisfile -Wl,--no-whole-archive -llightwave -lz") 
    153153 
    154     WinResource=[] 
     154    WinResource = [] 
    155155 
    156156EngineCommonAndServerObjs = envCafu.StaticObject(Split("""Ca3DE/AppCafu.cpp Ca3DE/MainCanvas.cpp Ca3DE/MainFrame.cpp Ca3DE/ConDefs.cpp 
     
    166166envCaWE = wxEnv.Clone() 
    167167envCaWE.Append(CPPPATH=['ExtLibs/lua/src', 'ExtLibs/noise/src']) 
    168 envCaWE.Append(LIBS = Split("SceneGraph MatSys cfsCoreLib cfsLib ClipSys cfs_png cfs_jpeg bulletcollision noise lua minizip lightwave z")) 
     168envCaWE.Append(LIBS=Split("SceneGraph MatSys cfsCoreLib cfsLib ClipSys cfs_png cfs_jpeg bulletcollision noise lua minizip lightwave z")) 
    169169 
    170170if sys.platform=="win32": 
    171171    envCaWE.Append(CPPPATH=['ExtLibs/freetype/include'])    # Windows builds use our local copy, Linux builds (must) use the systems freetype library instead. 
    172     envCaWE.Append(LIBS = Split("freetype")) 
    173     envCaWE.Append(LIBS = Split("advapi32 comctl32 comdlg32 gdi32 ole32 oleaut32 opengl32 rpcrt4 shell32 user32 winspool wsock32")) 
     172    envCaWE.Append(LIBS=Split("freetype")) 
    174173 
    175     WinResource=envCaWE.RES("CaWE/CaWE.rc") 
     174    WinResource = envCaWE.RES("CaWE/CaWE.rc") 
    176175 
    177176elif sys.platform=="linux2": 
    178     envCaWE.Append(CPPPATH=['/usr/include/freetype2'])      # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details. 
    179     envCaWE.Append(LINKFLAGS = ['-Wl,--export-dynamic'])    # Need this so that the Renderer DLLs can have their unresolved symbols dynamically resolved at load time. 
     177    envCaWE.Append(CPPPATH=['/usr/include/freetype2'])  # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details. 
     178    envCaWE.Append(LINKFLAGS=['-Wl,--export-dynamic'])  # Need this so that the Renderer DLLs can have their unresolved symbols dynamically resolved at load time. 
    180179 
    181     WinResource=[] 
     180    WinResource = [] 
    182181 
    183 SourceFilesList=(Glob("CaWE/*.cpp") 
     182SourceFilesList = (Glob("CaWE/*.cpp") 
    184183    +Glob("CaWE/FontWizard/*.cpp") 
    185184    +Glob("CaWE/GuiEditor/*.cpp")+Glob("CaWE/GuiEditor/Commands/*.cpp")+Glob("CaWE/GuiEditor/EditorData/*.cpp")