[Gcblue-commits] gcb_wx/src/graphics tc3DWindow.cpp,1.30,1.31 tcContainerGui.cpp,1.6,1.7 tcHookInfo.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2006-01-02 15:41:05
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21272/src/graphics Modified Files: tc3DWindow.cpp tcContainerGui.cpp tcHookInfo.cpp tcMapView.cpp tcOOBView.cpp Log Message: Game windows use common window as parent Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** tcMapView.cpp 24 Dec 2005 07:41:20 -0000 1.41 --- tcMapView.cpp 2 Jan 2006 15:40:53 -0000 1.42 *************** *** 325,330 **** tcMapView::tcMapView(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) : ! tc3DWindow(parent, pos, size, name, 0), terrainView(NULL) { --- 325,331 ---- tcMapView::tcMapView(wxWindow *parent, const wxPoint& pos, const wxSize& size, + tc3DWindow* graphicsHost, const wxString& name) : ! tc3DWindow(parent, pos, size, name, graphicsHost), terrainView(NULL) { *************** *** 2642,2648 **** tcTacticalMapView::tcTacticalMapView(wxWindow *parent, ! const wxPoint& pos, const wxSize& size, const wxString& name) : ! tcMapView(parent, pos, size, name), scrollActive(false), lastScrollTime(0), --- 2643,2650 ---- tcTacticalMapView::tcTacticalMapView(wxWindow *parent, ! const wxPoint& pos, const wxSize& size, ! tc3DWindow* graphicsHost, const wxString& name) : ! tcMapView(parent, pos, size, graphicsHost, name), scrollActive(false), lastScrollTime(0), *************** *** 2992,2997 **** tcWorldMapView::tcWorldMapView(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) : ! tcMapView(parent, pos, size, name) { terrainView = new tcTerrainView(parent, pos, size, false); --- 2994,3000 ---- tcWorldMapView::tcWorldMapView(wxWindow *parent, const wxPoint& pos, const wxSize& size, + tc3DWindow* graphicsHost, const wxString& name) : ! tcMapView(parent, pos, size, graphicsHost, name) { terrainView = new tcTerrainView(parent, pos, size, false); Index: tcHookInfo.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcHookInfo.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcHookInfo.cpp 18 Dec 2005 04:10:33 -0000 1.16 --- tcHookInfo.cpp 2 Jan 2006 15:40:53 -0000 1.17 *************** *** 666,680 **** tcHookInfo::tcHookInfo(wxWindow *parent, const wxPoint& pos, const wxSize& size, ! const wxString& name) : ! tc3DWindow(parent, pos, size, name) { ! mnHookID = NULL_INDEX; ! mpSS = NULL; ! mpOptions = NULL; ! database = tcDatabase::Get(); ! mpUserInfo = NULL; ! drawEngagedMode = 1; ! ambiguityIdx = 0; ! lastCycleCount = 0; } /***********************************************************************************/ --- 666,682 ---- tcHookInfo::tcHookInfo(wxWindow *parent, const wxPoint& pos, const wxSize& size, ! const wxString& name, ! tc3DWindow* graphicsHost) : ! tc3DWindow(parent, pos, size, name, graphicsHost), ! mnHookID(NULL_INDEX), ! mpSS(0), ! mpOptions(0), ! database(tcDatabase::Get()), ! mpUserInfo(0), ! drawEngagedMode(1), ! ambiguityIdx(0), ! lastCycleCount(0) { ! } /***********************************************************************************/ Index: tcContainerGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcContainerGui.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcContainerGui.cpp 26 Dec 2005 22:14:03 -0000 1.6 --- tcContainerGui.cpp 2 Jan 2006 15:40:53 -0000 1.7 *************** *** 2,7 **** ** @file tcContainerGui.cpp */ ! /* ! ** Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tcContainerGui.cpp */ ! /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 120,124 **** tc3DWindow* tcContainerGui::parent = 0; ! int tcContainerGui::windowLayer = 2; std::list<tcContainerGui*> tcContainerGui::openContainers; --- 119,123 ---- tc3DWindow* tcContainerGui::parent = 0; ! int tcContainerGui::windowLayer = 4; std::list<tcContainerGui*> tcContainerGui::openContainers; *************** *** 266,270 **** isLButtonDown = true; ! if ((point.y <= 15) || (point.y >= mnHeight)) { windowDragOn = true; --- 265,269 ---- isLButtonDown = true; ! if ((point.y <= 20) || (point.y >= mnHeight)) { windowDragOn = true; Index: tcOOBView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcOOBView.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcOOBView.cpp 14 Jul 2005 23:42:22 -0000 1.10 --- tcOOBView.cpp 2 Jan 2006 15:40:53 -0000 1.11 *************** *** 801,815 **** tcOOBView::tcOOBView(wxWindow *parent, const wxPoint& pos, const wxSize& size, ! const wxString& name) : ! tcXmlWindow(parent, pos, size, "xml/oobview.xml", name), ! mpMapView(0), ! mnAlliance(0), ! mnSelectedKey(NULL_INDEX), ! mbMouseDrag(false), ! mfRowSpacing(12.0f), ! mfYOffset(40.0f), ! mfXOffset(5.0f), ! mfXIndent(15.0f), ! displayMode(SHOW_OWN) { mpSimState = tcSimState::Get(); --- 801,816 ---- tcOOBView::tcOOBView(wxWindow *parent, const wxPoint& pos, const wxSize& size, ! const wxString& name, ! tc3DWindow* graphicsHost) : ! tcXmlWindow(parent, pos, size, "xml/oobview.xml", name, graphicsHost), ! mpMapView(0), ! mnAlliance(0), ! mnSelectedKey(NULL_INDEX), ! mbMouseDrag(false), ! mfRowSpacing(12.0f), ! mfYOffset(40.0f), ! mfXOffset(5.0f), ! mfXIndent(15.0f), ! displayMode(SHOW_OWN) { mpSimState = tcSimState::Get(); Index: tc3DWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DWindow.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tc3DWindow.cpp 26 Dec 2005 22:14:03 -0000 1.30 --- tc3DWindow.cpp 2 Jan 2006 15:40:53 -0000 1.31 *************** *** 325,328 **** --- 325,331 ---- void tc3DWindow::UpdateBackgroundQuadVertices() { + //UpdateBackgroundShape(); + //return; + wxASSERT(backgroundQuad.valid()); *************** *** 341,344 **** --- 344,350 ---- void tc3DWindow::CreateBackgroundQuad() { + //CreateBackgroundShape(); + //return; + wxASSERT(!backgroundQuad.valid()); *************** *** 385,388 **** --- 391,497 ---- + /** + * Version to create rounded background quads + */ + void tc3DWindow::CreateBackgroundShape() + { + //wxASSERT(!backgroundQuad.valid()); + + backgroundQuad = new osg::Geometry; + + + + osg::Vec3Array* vertices = new osg::Vec3Array; + osg::Vec2Array* texcoords = new osg::Vec2Array; + + float xc = 0.5; // normalized coords (0-1) + float yc = 0.5; + float rx = 0.5; + float ry = 0.5; + float xp = xc; + float yp = yc + ry; + float width = float(mnWidth); + float height = float(mnHeight); + + int nAngles = 32; + float dangle = C_TWOPI / float(nAngles); + float angle = dangle; + for (int k=0; k<nAngles; k++) + { + float x = xc + rx * sinf(angle); + float y = yc + ry * cosf(angle); + + vertices->push_back(osg::Vec3(width*xc, height*yc, 0)); + texcoords->push_back(osg::Vec2(xc, yc)); + + vertices->push_back(osg::Vec3(width*x, height*y, 0)); + texcoords->push_back(osg::Vec2(x, y)); + + vertices->push_back(osg::Vec3(width*xp, height*yp, 0)); + texcoords->push_back(osg::Vec2(xp, yp)); + + + + xp = x; + yp = y; + angle += dangle; + } + + + backgroundQuad->setVertexArray(vertices); + backgroundQuad->dirtyDisplayList(); + + backgroundQuad->setTexCoordArray(0,texcoords); + + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); + backgroundQuad->setColorArray(colors); + backgroundQuad->setColorBinding(osg::Geometry::BIND_OVERALL); + + backgroundQuad->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLES,0,3*nAngles)); + + /* + osg::StateSet* stateSet = backgroundQuad->getOrCreateStateSet(); + stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); + stateSet->setMode(GL_DEPTH_WRITEMASK, osg::StateAttribute::OFF); + stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + //stateSet->setMode(GL_BLEND, osg::StateAttribute::OFF); + stateSet->setRenderBinDetails(baseRenderBin + backgroundRenderBin, "RenderBin"); + */ + + /* + osg::Depth* depth = new osg::Depth(osg::Depth::ALWAYS, 1, 1, false); + depth->setWriteMask(0); + stateSet->setAttribute(depth); + */ + } + + /** + * Call after window size change + */ + void tc3DWindow::UpdateBackgroundShape() + { + wxASSERT(backgroundQuad.valid()); + + osg::Vec2Array* texcoords = dynamic_cast<osg::Vec2Array*>(backgroundQuad->getTexCoordArray(0)); + wxASSERT(texcoords != 0); + + osg::Vec3Array* vertices = new osg::Vec3Array(); + + float width = float(mnWidth); + float height = float(mnHeight); + + for (size_t k=0; k<texcoords->size(); k++) + { + osg::Vec2& t = texcoords->at(k); + vertices->push_back(osg::Vec3(width*t.x(), height*t.y(), 0)); + } + + backgroundQuad->setVertexArray(vertices); + backgroundQuad->dirtyDisplayList(); + + } + + /** * @return wxString with IMAGE_PATH prepended to <fileName> *************** *** 660,721 **** void tc3DWindow::Draw() { ! static int counter = 0; ! ! static float x1 = 0.5f * float(mnWidth); ! static float y1 = 0.5f * float(mnHeight); ! ! static float x2 = 0.5f * float(mnWidth); ! static float y2 = 0.5f * float(mnHeight); ! ! static float x3 = 0.5f * float(mnWidth); ! static float y3 = 0.5f * float(mnHeight); ! ! ! ! wxString s = wxString::Format("Test count %d", counter); ! ! // update random positions ! const float a = 1.0f / float(RAND_MAX); ! ! float xbias = -0.001f * (x1 - 0.5 * float(mnWidth)); ! float ybias = -0.001f * (y1 - 0.5 * float(mnHeight)); ! x1 += 4.0f * (a * float(rand()) - 0.5f + xbias); ! y1 += 4.0f * (a * float(rand()) - 0.5f + ybias); ! ! xbias = -0.001f * (x2 - 0.5 * float(mnWidth)); ! ybias = -0.001f * (y2 - 0.5 * float(mnHeight)); ! x2 += 4.0f * (a * float(rand()) - 0.5f + xbias); ! y2 += 4.0f * (a * float(rand()) - 0.5f + ybias); ! ! xbias = -0.001f * (x3 - 0.5 * float(mnWidth)); ! ybias = -0.001f * (y3 - 0.5 * float(mnHeight)); ! x3 += 4.0f * (a * float(rand()) - 0.5f + xbias); ! y3 += 4.0f * (a * float(rand()) - 0.5f + ybias); ! ! ! DrawImage(defaultTexture.get(), x2, y2, 16, 16); ! ! DrawImage(testSymbol.get(), x3, y3, 40, 40); ! ! DrawLine(x2, y2, 50, 50, osg::Vec4(1.0f, 1.0f, 0.2f, 1.0f)); ! ! ! DrawText(s.c_str(), x1, y1, defaultFont.get(), osg::Vec4(1.0, 1.0, 1.0, 1.0), ! 12.0f, CENTER_CENTER); ! ! DrawText("(0,0)", 0, 0, defaultFont.get(), osg::Vec4(1.0, 1.0, 1.0, 1.0), ! 12.0f, CENTER_CENTER); ! ! DrawText("(w-10,h-10)", mnWidth-10, mnHeight-10, defaultFont.get(), ! osg::Vec4(1.0, 1.0, 1.0, 1.0), 12.0f, CENTER_CENTER); ! ! DrawRectangle(x2 + 5, y2 + 5, 10, 30, osg::Vec4(1.0f, 0.2f, 0.2f, 1.0f)); ! ! DrawBorder(); ! ! counter++; ! ! HideUnusedObjects(); } --- 769,775 ---- void tc3DWindow::Draw() { ! DrawChildren(); + FinishDraw(); } *************** *** 733,740 **** for(size_t n=0;n<nChildren;n++) { ! wxASSERT(children[n]); ! //graphics->TranslateTransform(children[n]->mrectWindow.left, children[n]->mrectWindow.top); ! children[n]->Draw(); ! //graphics->TranslateTransform(-children[n]->mrectWindow.left, -children[n]->mrectWindow.top); } } --- 787,795 ---- for(size_t n=0;n<nChildren;n++) { ! tc3DWindow* child = children[n]; ! wxASSERT(child); ! ! if (child->IsActive()) child->Draw(); ! } } *************** *** 2002,2005 **** --- 2057,2062 ---- { + wxASSERT(viewer); + wxWindow::SetBackgroundColour(*wxBLACK); wxWindow::Show(FALSE); *************** *** 2099,2104 **** SetName(name.c_str()); - wxASSERT(viewer); - --- 2156,2159 ---- |