Thread: [Gcblue-commits] gcb_wx/src/graphics tcMapOverlay.cpp,NONE,1.1 tc3DWindow.cpp,1.17,1.18 tcMapObject.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-31 03:51:21
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27747/src/graphics Modified Files: tc3DWindow.cpp tcMapObject.cpp tcMapView.cpp tcSmoker.cpp Added Files: tcMapOverlay.cpp Log Message: Added map overlay, fixed smoke trail roll bug, improved FOV calc for autopoint launchers, database tweaks --- NEW FILE: tcMapOverlay.cpp --- /** ** @file tcMapOverlay.cpp */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP #include "tcMapOverlay.h" #include "tcMapObject.h" #include "tcMapObject.h" #ifdef _DEBUG #define new DEBUG_NEW #endif void tcMapOverlay::AddMapObject(tcMapObject *obj) { overlayObjects.push_back(obj); redraw = true; } void tcMapOverlay::ClearMapObjects() { for (size_t n=0; n < overlayObjects.size(); n++) { delete overlayObjects[n]; } overlayObjects.clear(); redraw = true; } void tcMapOverlay::Draw() { if (!redraw) return; for (size_t n=0; n < overlayObjects.size(); n++) { overlayObjects[n]->Draw(this); } FinishDraw(); redraw = false; } void tcMapOverlay::OnSize(wxSizeEvent& event) { tc3DWindow::OnSize(event); } void tcMapOverlay::Redraw() { redraw = true; } tcMapOverlay::tcMapOverlay(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) : tc3DWindow(parent, pos, size, name, 0), redraw(false) { } tcMapOverlay::~tcMapOverlay() { ClearMapObjects(); } Index: tcSmoker.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcSmoker.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcSmoker.cpp 27 Jan 2005 01:01:50 -0000 1.2 --- tcSmoker.cpp 31 Mar 2005 03:51:13 -0000 1.3 *************** *** 131,135 **** // create rotation matrix (using euler angles for now) const osg::Vec3 xaxis(-1, 0, 0); ! const osg::Vec3 yaxis(0, 1, 0); const osg::Vec3 zaxis(0, 0, 1); --- 131,135 ---- // create rotation matrix (using euler angles for now) const osg::Vec3 xaxis(-1, 0, 0); ! const osg::Vec3 yaxis(0, -1, 0); const osg::Vec3 zaxis(0, 0, 1); Index: tcMapObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapObject.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcMapObject.cpp 2 Nov 2004 04:23:56 -0000 1.6 --- tcMapObject.cpp 31 Mar 2005 03:51:12 -0000 1.7 *************** *** 32,35 **** --- 32,36 ---- #include "math_constants.h" #include "simmath.h" + #include <osg/Geometry> #ifdef _DEBUG *************** *** 41,45 **** tcMapView* tcMapObject::mapView = NULL; ! void tcMapObject::Draw() { if (!isActive) return; --- 42,102 ---- tcMapView* tcMapObject::mapView = NULL; ! osg::ref_ptr<osg::Geometry> tcMapObject::marker; ! ! void tcMapObject::LoadMarker() ! { ! float w = 10.0f; ! ! marker = new osg::Geometry; ! ! osg::Vec4Array* colors = new osg::Vec4Array; ! colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); ! marker->setColorArray(colors); ! marker->setColorBinding(osg::Geometry::BIND_OVERALL); ! ! marker->setUseDisplayList(true); ! ! // set state ! osg::StateSet* stateSet = marker->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::ON); ! ! // ugly, this could get out of sync with map render bin offset ! //stateSet->setRenderBinDetails(12, "RenderBin"); ! ! // create vertex array ! osg::Vec3Array* vertices = new osg::Vec3Array; ! marker->setVertexArray(vertices); ! ! vertices->push_back(osg::Vec3(-w, w, 0)); ! vertices->push_back(osg::Vec3(-w, -w, 0)); ! vertices->push_back(osg::Vec3(w, -w, 0)); ! vertices->push_back(osg::Vec3(w, w, 0)); ! ! // create texture coordinates ! osg::Vec2Array* texcoords = new osg::Vec2Array(4); ! (*texcoords)[0].set(0.0f, 1.0f); ! (*texcoords)[1].set(0.0f, 0.0f); ! (*texcoords)[2].set(1.0f, 0.0f); ! (*texcoords)[3].set(1.0f, 1.0f); ! marker->setTexCoordArray(0,texcoords); ! ! marker->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); ! ! // add texture ! osg::Image* image = tc3DWindow::LoadImage("marker.png"); ! ! osg::Texture2D* texture = new osg::Texture2D; ! texture->setDataVariance(osg::Object::STATIC); ! texture->setImage(image); ! ! osg::StateSet* stateset = marker->getOrCreateStateSet(); ! stateset->setTextureAttributeAndModes(0, texture, ! osg::StateAttribute::ON); ! } ! ! void tcMapObject::Draw(tc3DWindow* host) { if (!isActive) return; *************** *** 50,55 **** if (markerEnabled) { ! mapView->DrawLineR(x-8, y-8, x+8, y+8, color); ! mapView->DrawLineR(x+8, y-8, x-8, y+8, color); } } --- 107,112 ---- if (markerEnabled) { ! host->DrawLineR(x-8, y-8, x+8, y+8, color); ! host->DrawLineR(x+8, y-8, x-8, y+8, color); } } *************** *** 102,105 **** --- 159,164 ---- isActive = true; markerEnabled = true; + + if (!marker.valid()) LoadMarker(); } *************** *** 111,115 **** /********** tcMapTextObject **************/ ! void tcMapTextObject::Draw() { if (!isActive) return; --- 170,174 ---- /********** tcMapTextObject **************/ ! void tcMapTextObject::Draw(tc3DWindow* host) { if (!isActive) return; *************** *** 119,129 **** ! mapView->DrawTextR(caption.c_str(), x+5.0f, y, mapView->GetDefaultFont(), color, 16.0, LEFT_BASE_LINE); if (markerEnabled) // avoids parent draw overhead this way { ! mapView->DrawLineR(x-8, y-8, x+8, y+8, color); ! mapView->DrawLineR(x+8, y-8, x-8, y+8, color); } --- 178,189 ---- ! host->DrawTextR(caption.c_str(), x+5.0f, y, mapView->GetDefaultFont(), color, 16.0, LEFT_BASE_LINE); if (markerEnabled) // avoids parent draw overhead this way { ! host->DrawGeometryR(marker.get(), x, y); ! //mapView->DrawLineR(x-8, y-8, x+8, y+8, color); ! //mapView->DrawLineR(x+8, y-8, x-8, y+8, color); } *************** *** 135,139 **** } ! tcMapTextObject::tcMapTextObject(std::string text, double x, double y, bool useRel) : tcMapObject(x, y, useRel), caption(text) { --- 195,199 ---- } ! tcMapTextObject::tcMapTextObject(const std::string& text, double x, double y, bool useRel) : tcMapObject(x, y, useRel), caption(text) { Index: tc3DWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DWindow.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tc3DWindow.cpp 4 Mar 2005 00:46:17 -0000 1.17 --- tc3DWindow.cpp 31 Mar 2005 03:51:12 -0000 1.18 *************** *** 1841,1844 **** --- 1841,1847 ---- lineStateSet->setRenderBinDetails(baseRenderBin + lineRenderBin, "RenderBin"); + osg::StateSet* groupStateSet = groupRoot->getOrCreateStateSet(); + groupStateSet->setRenderBinDetails(baseRenderBin + geometryRenderBin, "RenderBin"); + size_t nChildren = children.size(); *************** *** 1885,1888 **** --- 1888,1892 ---- lineRenderBin(1), // using 1 causes dropouts at some 3D viewer window sizes!? rectRenderBin(1), + geometryRenderBin(1), textRenderBin(2), fontSize(12.0), *************** *** 1926,1929 **** --- 1930,1934 ---- groupStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); groupStateSet->setMode(GL_BLEND, osg::StateAttribute::ON); + groupStateSet->setRenderBinDetails(baseRenderBin + geometryRenderBin, "RenderBin"); textRoot = new osg::Geode; Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tcMapView.cpp 19 Mar 2005 15:31:08 -0000 1.21 --- tcMapView.cpp 31 Mar 2005 03:51:12 -0000 1.22 *************** *** 39,42 **** --- 39,43 ---- #include "tcString.h" #include "tcMapObject.h" + #include "tcMapOverlay.h" #include <osg/Image> *************** *** 265,275 **** } ! /***********************************************************************************/ void tcMapView::SetViewCenterZoom(wxPoint pscreen, float afZoom) { ! //SetView(ScreenToGeo(TranslatePoint(pscreen)),mfLonWidth/afZoom); ! SetView(ScreenToGeo(pscreen),mfLonWidth/afZoom); } ! /***********************************************************************************/ void tcMapView::SetView(tcPoint center, float afLonSpan) { --- 266,280 ---- } ! /** ! * ! */ void tcMapView::SetViewCenterZoom(wxPoint pscreen, float afZoom) { ! SetView(ScreenToGeo(pscreen), mfLonWidth/afZoom); } ! ! /** ! * ! */ void tcMapView::SetView(tcPoint center, float afLonSpan) { *************** *** 598,602 **** { tcMapObject* obj = specialGraphics[n]; ! obj->Draw(); } } --- 603,607 ---- { tcMapObject* obj = specialGraphics[n]; ! obj->Draw(this); } } *************** *** 725,728 **** --- 730,735 ---- if (mnGameMode != GAMEMODE_NORMAL) {DrawIndicator(1);} + overlay->Draw(); + DrawBorder(); *************** *** 778,781 **** --- 785,792 ---- } + tcMapOverlay* tcTacticalMapView::GetMapOverlay() const + { + return overlay; + } /** *************** *** 2183,2186 **** --- 2194,2204 ---- } + void tcTacticalMapView::SetView(tcPoint center, float afLonSpan) + { + tcMapView::SetView(center, afLonSpan); + + overlay->Redraw(); + } + /** * OnLeaveWindow event handler *************** *** 2368,2371 **** --- 2386,2397 ---- return; // old returned false } + + void tcTacticalMapView::OnSize(wxSizeEvent& event) + { + overlay->OnSize(event); + + tcMapView::OnSize(event); + } + /** * *************** *** 2427,2430 **** --- 2453,2470 ---- } + void tcTacticalMapView::SetActive(bool abActive) + { + overlay->SetActive(abActive); + tcMapView::SetActive(abActive); + } + + void tcTacticalMapView::SetBaseRenderBin(int n) + { + tcMapView::SetBaseRenderBin(n); + + wxASSERT(overlay); + overlay->SetBaseRenderBin(n - 5); + } + void tcTacticalMapView::SetGroupHook(std::vector<long>& hookedUnits) { *************** *** 2492,2495 **** --- 2532,2539 ---- } + overlay = new tcMapOverlay(parent, pos, size); + overlay->SetBaseRenderBin(5); + overlay->SetActive(true); + tc3DWindow::MoveToTop(); // so that color elevation map is underneath |