[Gcblue-commits] gcb_wx/src/graphics tcAltitudeBarControl.cpp,NONE,1.1 tcControl.cpp,NONE,1.1 cspSky
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-11-23 23:32:36
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29552/src/graphics Modified Files: cspSky.cpp tc3DModel.cpp tc3DTerrain.cpp tc3DViewer.cpp tcMapView.cpp tcMessageCenter.cpp tcMessageChannel.cpp tcParticleEffect.cpp tcTerrainTextureFactory.cpp Added Files: tcAltitudeBarControl.cpp tcControl.cpp Log Message: Text message "message center" GUI screen Index: tc3DTerrain.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DTerrain.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tc3DTerrain.cpp 1 Nov 2004 03:17:17 -0000 1.16 --- tc3DTerrain.cpp 23 Nov 2004 23:30:55 -0000 1.17 *************** *** 33,36 **** --- 33,37 ---- #include <osg/Depth> #include <osg/PolygonMode> + #include <osg/Texture2D> #include <Demeter/Loader.h> #include "simmath.h" *************** *** 49,52 **** --- 50,126 ---- } + /** + * + */ + void tc3DTerrain::InitWaterSurface() + { + waterSurface = new osg::Geometry; + + osg::Vec3Array* vertices = new osg::Vec3Array(8); + (*vertices)[0] = osg::Vec3(1e5, 1e5, 0); + (*vertices)[1] = osg::Vec3(-1e5, 1e5, 0); + (*vertices)[2] = osg::Vec3(-1e5, -1e5, 0); + (*vertices)[3] = osg::Vec3(1e5, -1e5, 0); + (*vertices)[4] = osg::Vec3(1e5, -1e5, 0); + (*vertices)[5] = osg::Vec3(-1e5, -1e5, 0); + (*vertices)[6] = osg::Vec3(-1e5, 1e5, 0); + (*vertices)[7] = osg::Vec3(1e5, 1e5, 0); + + + waterSurface->setVertexArray(vertices); + + + osg::Vec2Array* texcoords = new osg::Vec2Array(8); + const float k_tex = 500.0f; // larger repeats texture more + (*texcoords)[0].set(0.0f, k_tex); + (*texcoords)[1].set(0.0f, 0.0f); + (*texcoords)[2].set(k_tex, 0.0f); + (*texcoords)[3].set(k_tex, k_tex); + (*texcoords)[4].set(0.0f, k_tex); + (*texcoords)[5].set(0.0f, 0.0f); + (*texcoords)[6].set(k_tex, 0.0f); + (*texcoords)[7].set(k_tex, k_tex); + waterSurface->setTexCoordArray(0, texcoords); + + + osg::Vec3Array* normals = new osg::Vec3Array(2); + (*normals)[0].set(0.0f, 0.0f, 1.0f); + (*normals)[1].set(0.0f, 0.0f, -1.0f); + waterSurface->setNormalArray(normals); + waterSurface->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE); + + + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); + waterSurface->setColorArray(colors); + waterSurface->setColorBinding(osg::Geometry::BIND_OVERALL); + + + waterSurface->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,8)); + + waterSurface->setUseDisplayList(true); + + + + osg::StateSet* stateSet = waterSurface->getOrCreateStateSet(); + stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); + //stateSet->setMode(GL_DEPTH_WRITEMASK, osg::StateAttribute::ON); + stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON); + stateSet->setMode(GL_BLEND, osg::StateAttribute::ON); + stateSet->setMode(GL_FOG, osg::StateAttribute::ON); + //stateSet->setRenderBinDetails(baseRenderBin + rectRenderBin, "RenderBin"); + + waterTexture = new osg::Texture2D; + waterTexture->setImage(osgDB::readImageFile("water2b.bmp")); + waterTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::MIRROR); + waterTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::MIRROR); + + stateSet->setTextureAttributeAndModes(0, waterTexture.get(), + osg::StateAttribute::ON); + + wxASSERT(terrainNode.valid()); + terrainNode->addDrawable(waterSurface.get()); + } + void tc3DTerrain::CheckElevations() { *************** *** 107,111 **** float height = mapData->GetTerrainHeight(lon_deg, lat_deg, gameTime); long idx = i*GRID_DIM + j; ! elevationArray[idx] = (height < 0) ? 0.001f*height : height; } } --- 181,186 ---- float height = mapData->GetTerrainHeight(lon_deg, lat_deg, gameTime); long idx = i*GRID_DIM + j; ! //elevationArray[idx] = (height < 0) ? 0.001f*height : height; ! elevationArray[idx] = height; } } *************** *** 261,264 **** --- 336,341 ---- float detailThreshold = 6.0f; terrain->SetDetailThreshold(detailThreshold); + + InitWaterSurface(); } Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tc3DModel.cpp 6 Nov 2004 15:13:41 -0000 1.15 --- tc3DModel.cpp 23 Nov 2004 23:30:55 -0000 1.16 *************** *** 322,329 **** void tc3DModel::DisableSmoke() { ! if (smokeTrail.valid()) { smokeTrail->DetachFromSceneGraph(); ! smokeTrail.release(); smokePlacer = 0; } --- 322,329 ---- void tc3DModel::DisableSmoke() { ! if (smokeTrail) { smokeTrail->DetachFromSceneGraph(); ! smokeTrail = 0; smokePlacer = 0; } *************** *** 339,342 **** --- 339,351 ---- smokeTrail->AddToSceneGraph(world.get()); smokePlacer = smokeTrail->GetParticlePlacer(); + + if (smokeMode == tcParticleEffect::BUBBLES) + { + smokeSource.set(0, -GetRadius(), 0); + } + else + { + smokeSource.set(0, 0, 0); + } } *************** *** 521,525 **** wxASSERT(smokePlacer); if (smokePlacer == 0) return; ! smokePlacer->setCenter(x, y, z); } --- 530,551 ---- wxASSERT(smokePlacer); if (smokePlacer == 0) return; ! wxASSERT(gameObj); ! ! const osg::Vec3 xaxis(-1, 0, 0); ! const osg::Vec3 yaxis(0, 1, 0); ! const osg::Vec3 zaxis(0, 0, 1); ! ! osg::Vec3 pos(x, y, z); ! ! // heading, pitch, roll ! osg::Matrixf rotation; ! ! rotation.makeRotate(gameObj->mcKin.mfHeading_rad, zaxis, ! gameObj->mcKin.mfPitch_rad, xaxis, ! gameObj->mcKin.mfRoll_rad, yaxis); ! osg::Vec3 smokeOffset = rotation * smokeSource; ! pos = pos + smokeOffset; ! ! smokePlacer->setCenter(pos.x(), pos.y(), pos.z()); } *************** *** 538,542 **** */ tc3DModel::tc3DModel(const tc3DModel* source) ! : smokePlacer(0), distanceFromCamera(1e10) { --- 564,568 ---- */ tc3DModel::tc3DModel(const tc3DModel* source) ! : smokePlacer(0), smokeTrail(0), distanceFromCamera(1e10) { *************** *** 588,591 **** --- 614,618 ---- tc3DModel::~tc3DModel() { + } Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tc3DViewer.cpp 6 Nov 2004 15:13:41 -0000 1.5 --- tc3DViewer.cpp 23 Nov 2004 23:30:55 -0000 1.6 *************** *** 353,356 **** --- 353,357 ---- int correctedY = parentHeight - (pos.y + size.GetHeight()); sceneView->setViewport(pos.x,correctedY, size.GetWidth(),size.GetHeight()); + sceneViewFar->setViewport(pos.x,correctedY, size.GetWidth(),size.GetHeight()); mnWidth = size.GetWidth(); *************** *** 428,446 **** { osgUtil::RenderStage* stage = sceneView->getRenderStage(); if (modeCode == 1) { stage->setClearMask(GL_DEPTH_BUFFER_BIT); } else if (modeCode == 2) { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } else { stage->setClearMask(0); } } void tc3DViewer::SetGameTime(double t) { --- 429,501 ---- { osgUtil::RenderStage* stage = sceneView->getRenderStage(); + osgUtil::RenderStage* stageFar = sceneViewFar->getRenderStage(); if (modeCode == 1) { stage->setClearMask(GL_DEPTH_BUFFER_BIT); + stageFar->setClearMask(GL_DEPTH_BUFFER_BIT); } else if (modeCode == 2) { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT); ! stageFar->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } else { stage->setClearMask(0); + stageFar->setClearMask(0); } } + /** + * + */ + void tc3DViewer::SetFogMode(int mode) + { + wxASSERT(foggedObjects.valid()); + wxASSERT(sceneViewFar.valid()); + + osg::StateSet* fogState = foggedObjects->getOrCreateStateSet(); + osg::Fog* fog = dynamic_cast<osg::Fog*>(fogState->getAttribute(osg::StateAttribute::FOG)); + if (!fog) + { + fog = new osg::Fog; + fogState->setAttributeAndModes(fog, osg::StateAttribute::ON); + } + + if (mode == FOG_OFF) + { + fogState->setMode(GL_FOG, osg::StateAttribute::OFF); + sceneViewFar->setClearColor(osg::Vec4(0, 0, 0, 1)); + return; + } + + osg::Vec4 airFog(0.6f, 0.7f, 0.8f, 1.0f); + osg::Vec4 waterFog(0.1f, 0.2f, 0.3f, 1.0f); + + fogState->setMode(GL_FOG, osg::StateAttribute::ON); + + fog->setMode(osg::Fog::EXP); + + if (mode == FOG_AIR) + { + fog->setColor(airFog); // blue-white fog + fog->setStart(5000.0f); + fog->setEnd(60000.0f); + fog->setDensity(0.000006f); + sceneViewFar->setClearColor(airFog); + } + else + { + fog->setColor(waterFog); // dark blue fog + fog->setStart(30.0f); + fog->setEnd(60000.0f); + fog->setDensity(0.0006f); + sceneViewFar->setClearColor(waterFog); + } + + + } + void tc3DViewer::SetGameTime(double t) { *************** *** 697,708 **** foggedObjects = new osg::Group; osg::Fog *fog = new osg::Fog(); ! fog->setColor(osg::Vec4(0.6f,0.7f,0.8f,1.0f)); // blue-white fog fog->setMode(osg::Fog::EXP); fog->setStart(5000.0f); fog->setEnd(60000.0f); ! fog->setDensity(0.000005f); ! /* fog->setMode(osg::Fog::LINEAR); --- 752,767 ---- foggedObjects = new osg::Group; + SetFogMode(FOG_AIR); + /* osg::Fog *fog = new osg::Fog(); ! fog->setColor(osg::Vec4(0.6f, 0.7f, 0.8f, 1.0f)); // blue-white fog fog->setMode(osg::Fog::EXP); fog->setStart(5000.0f); fog->setEnd(60000.0f); ! fog->setDensity(0.000006f); ! */ ! ! /* fog->setMode(osg::Fog::LINEAR); *************** *** 712,719 **** */ osg::StateSet *fogState = foggedObjects->getOrCreateStateSet(); fogState->setAttributeAndModes(fog, osg::StateAttribute::ON); foggedObjects->setStateSet(fogState); ! { worldObjects = new osg::Group; --- 771,779 ---- */ + /* osg::StateSet *fogState = foggedObjects->getOrCreateStateSet(); fogState->setAttributeAndModes(fog, osg::StateAttribute::ON); foggedObjects->setStateSet(fogState); ! */ { worldObjects = new osg::Group; *************** *** 765,770 **** rootnode->addChild(foggedObjects.get()); ! rootnode->addChild(skyTransform.get()); ! rootnode->addChild(orthoProjection.get()); isTerrainActive = true; --- 825,838 ---- rootnode->addChild(foggedObjects.get()); ! rootnodeFar->addChild(skyTransform.get()); ! ! /* For some strange reason, adding the orthoProjection to ! ** rootnodeFar causes line and rect objects in the guiView ! ** (a DIFFERENT SceneView) to drop out. ! ** Adding to rootnode causes a double image of the hud objects, ! ** but this is the lesser of evils. ! ** TODO investigate this. There may be a significant problem ! ** lurking here. */ ! rootnode->addChild(orthoProjection.get()); isTerrainActive = true; *************** *** 848,853 **** guiView->draw(); ! if (isActive && sceneView.valid()) { sceneView->update(); sceneView->cull(); --- 916,925 ---- guiView->draw(); ! if (isActive && sceneView.valid() && sceneViewFar.valid()) { + sceneViewFar->update(); + sceneViewFar->cull(); + sceneViewFar->draw(); + sceneView->update(); sceneView->cull(); *************** *** 950,957 **** cameraTarget = cameraPosition*m; } ! ! if (cameraPosition._v[2] < 1) cameraPosition._v[2] = 1; // limit min camera altitude sceneView->setViewMatrixAsLookAt(cameraPosition, cameraTarget, osg::Vec3(0,0,1)); // update skyTransform based on camera position --- 1022,1054 ---- cameraTarget = cameraPosition*m; } ! // limit min camera altitude unless subsurface obj ! if ((obj->mpDBObject->mnType & PTYPE_SUBSURFACE) != 0) ! { ! if (cameraPosition._v[2] < -480.0) cameraPosition._v[2] = -480.0; ! } ! else ! { ! if (cameraPosition._v[2] < 1) cameraPosition._v[2] = 1; ! } ! // workaround for sky issue, deactivate sky when camera underwater ! if (cameraPosition._v[2] < -1.0) ! { ! if (skyTransform->getNumParents()) ! { ! rootnodeFar->removeChild(skyTransform.get()); ! SetFogMode(FOG_WATER); ! } ! } ! else ! { ! if (isTerrainActive && (skyTransform->getNumParents() == 0)) ! { ! rootnodeFar->addChild(skyTransform.get()); ! SetFogMode(FOG_AIR); ! } ! } sceneView->setViewMatrixAsLookAt(cameraPosition, cameraTarget, osg::Vec3(0,0,1)); + sceneViewFar->setViewMatrixAsLookAt(cameraPosition, cameraTarget, osg::Vec3(0,0,1)); // update skyTransform based on camera position *************** *** 1217,1223 **** // set up the clear mask. osgUtil::RenderStage *stage = sceneView->getRenderStage(); ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); stage->setClearDepth(1.0f); ! stage->setClearColor(osg::Vec4(0,0,0,1.0f)); frameStamp = new osg::FrameStamp; --- 1314,1321 ---- // set up the clear mask. osgUtil::RenderStage *stage = sceneView->getRenderStage(); ! // stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); stage->setClearDepth(1.0f); ! //stage->setClearColor(osg::Vec4(0,0,0,1.0f)); ! stage->setClearMask(GL_DEPTH_BUFFER_BIT); frameStamp = new osg::FrameStamp; *************** *** 1228,1233 **** --- 1326,1400 ---- updateVisitor->setFrameStamp(frameStamp.get()); sceneView->setUpdateVisitor(updateVisitor.get()); + } + + + /** + * + */ + void tc3DViewer::InitSceneViewFar(wxPoint pos, wxSize size) + { + + sceneViewFar = new osgUtil::SceneView(); + + if (!displaySettings.valid()) + { + wxASSERT(sceneViewFar->getDisplaySettings()==NULL); + displaySettings = new osg::DisplaySettings; + displaySettings->setDepthBuffer(true); + } + + // displaySettings->setRGB(true); + //displaySettings->setDoubleBuffer(true); + //displaySettings->setMinimumNumAlphaBits(4); + + sceneViewFar->setDisplaySettings(displaySettings.get()); + sceneViewFar->setDefaults(); + sceneViewFar->getState()->setContextID(2); + + wxWindow *parent = wxWindow::GetParent(); + wxSize parentSize = parent->GetSize(); + int parentHeight = parentSize.GetHeight(); + int correctedY = parentHeight - (pos.y + size.GetHeight()); + + UpdateProjectionMatrix(size); + + sceneViewFar->setViewport(pos.x,correctedY,size.GetWidth(),size.GetHeight()); + sceneViewFar->setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR); + sceneViewFar->setLightingMode(osgUtil::SceneView::NO_SCENEVIEW_LIGHT); + sceneViewFar->setClearColor(osg::Vec4(0, 0, 0, 1.0f)); + //sceneViewFar->setComputeNearFarMode(osgUtil::CullVisitor::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); + /* + NO_CULLING = 0x0, + VIEW_FRUSTUM_CULLING = 0x1, + NEAR_PLANE_CULLING = 0x2, + FAR_PLANE_CULLING = 0x4, + SMALL_FEATURE_CULLING = 0x8, + SHADOW_OCCLUSION_CULLING = 0x10, + ENABLE_ALL_CULLING + */ + sceneViewFar->setCullingMode( + osg::CullStack::NO_CULLING + // osg::CullStack::FAR_PLANE_CULLING + // osg::CullStack::NEAR_PLANE_CULLING + // osg::CullStack::VIEW_FRUSTUM_CULLING + // osg::CullStack::SMALL_FEATURE_CULLING + ); + + // set up the clear mask. + osgUtil::RenderStage *stage = sceneViewFar->getRenderStage(); + stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + stage->setClearDepth(1.0f); + stage->setClearColor(osg::Vec4(0,0,0,1.0f)); + + frameStampFar = new osg::FrameStamp; + frameStampFar->setReferenceTime(gameTime); + sceneViewFar->setFrameStamp(frameStampFar.get()); + + updateVisitorFar = new osgUtil::UpdateVisitor(); + updateVisitorFar->setFrameStamp(frameStampFar.get()); + sceneViewFar->setUpdateVisitor(updateVisitorFar.get()); } + /** * set global state at root node *************** *** 1324,1328 **** if (state) { ! rootnode->addChild(skyTransform.get()); foggedObjects->addChild(terrainNode.get()); foggedObjects->addChild(skyLights.get()); --- 1491,1498 ---- if (state) { ! if (skyTransform->getNumParents() == 0) ! { ! rootnodeFar->addChild(skyTransform.get()); ! } foggedObjects->addChild(terrainNode.get()); foggedObjects->addChild(skyLights.get()); *************** *** 1332,1338 **** else { ! if (!rootnode->removeChild(skyTransform.get()) || ! !foggedObjects->removeChild(terrainNode.get()) || !foggedObjects->removeChild(skyLights.get())) { --- 1502,1514 ---- else { + // skyTransform already removed if camera underwater + rootnodeFar->removeChild(skyTransform.get()); + if (unsigned int nParents = skyTransform->getNumParents()) + { + fprintf(stderr, "tc3DViewer::SetTerrainActive - " + "skyTransform still has (%d) parents after removal\n", nParents); + } ! if (!foggedObjects->removeChild(terrainNode.get()) || !foggedObjects->removeChild(skyLights.get())) { *************** *** 1570,1575 **** frameStamp->setFrameNumber(frameStamp->getFrameNumber()+1); frameStamp->setReferenceTime(gameTime); - updateVisitor->setTraversalNumber(frameStamp->getFrameNumber()); } --- 1746,1757 ---- frameStamp->setFrameNumber(frameStamp->getFrameNumber()+1); frameStamp->setReferenceTime(gameTime); updateVisitor->setTraversalNumber(frameStamp->getFrameNumber()); + + frameStampFar->setFrameNumber(frameStampFar->getFrameNumber()+1); + frameStampFar->setReferenceTime(gameTime); + updateVisitorFar->setTraversalNumber(frameStampFar->getFrameNumber()); + + + } *************** *** 1582,1587 **** wxASSERT(sceneView.valid()); float aspectRatio = (float)windowSize.GetWidth() / (float)windowSize.GetHeight(); ! sceneView->setProjectionMatrixAsPerspective(45.0, aspectRatio, zmin, zmax); } --- 1764,1777 ---- wxASSERT(sceneView.valid()); + float zmid = sqrtf(zmin*zmax); + float aspectRatio = (float)windowSize.GetWidth() / (float)windowSize.GetHeight(); ! ! sceneView->setProjectionMatrixAsPerspective(45.0, aspectRatio, zmin, zmid); ! if (sceneViewFar.valid()) ! { ! sceneViewFar->setProjectionMatrixAsPerspective(45.0, aspectRatio, zmid-20, zmax); ! } ! } *************** *** 1603,1606 **** --- 1793,1797 ---- zmin = 2.0f; zmax = 131072.0f; + zmax = 50000.0f; *************** *** 1630,1633 **** --- 1821,1825 ---- InitSceneView(pos, size); + InitSceneViewFar(pos, size); InitGuiView(); *************** *** 1652,1656 **** --- 1844,1852 ---- rootnode = new osg::Group; + rootnodeFar = new osg::Group; + rootnodeFar->addChild(rootnode.get()); + sceneView->setSceneData(rootnode.get()); + sceneViewFar->setSceneData(rootnodeFar.get()); hudObjects = new osg::MatrixTransform; --- NEW FILE: tcAltitudeBarControl.cpp --- /** ** @file tcAltitudeBarControl.cpp */ /* Copyright (C) 2004 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 #include "tcAltitudeBarControl.h" #include "tc3DWindow.h" #include "tcAirObject.h" #include "tcGameObject.h" #include "tcPlatformObject.h" #include "tcSubObject.h" #include "tcGenericDBObject.h" #include <osg/Texture2D> #include <osg/Vec4> #ifdef _DEBUG #define new DEBUG_NEW #endif /** * */ void tcAltitudeBarControl::Draw(tc3DWindow* graphics) { wxASSERT(graphics); if (!IsActive()) return; if (!obj) return; UpdateDrawParameters(); osgText::Font* font = graphics->GetDefaultFont(); // draw main altitude / depth text float x = barRect.GetRight() + 24.0; float y = barRect.YCenter(); wxString s = wxString::Format("%.0f m", currentValue); graphics->DrawText(s.c_str(), x, y, font, color, fontSizeLarge, CENTER_CENTER); // draw scale text x = barRect.XCenter(); y = isDepth ? barRect.bottom - 7 : barRect.top + 7; s = wxString::Format("%.0f", currentScale); graphics->DrawText(s.c_str(), x, y, font, color, fontSize, CENTER_CENTER); graphics->DrawRectangle(currentRect, color, tc3DWindow::FILL_ON); if (mouseOverBar) { graphics->DrawRectangle(overRect, overColor, tc3DWindow::FILL_ON); } graphics->DrawRectangle(barRect, colorDim, tc3DWindow::FILL_OFF); float x1 = barRect.GetLeft() - 2.0; float x2 = barRect.GetRight() + 2.0; graphics->DrawLine(x1, yGoal, x2, yGoal, neutralColor); // goal line graphics->DrawLine(x1, yTerrain, x2, yTerrain, dangerColor); // terrain line graphics->DrawLine(x1, yLimit, x2, yLimit, warnColor); // max alt or depth line osg::Texture2D* upTex = mouseOverUp ? upOverIcon.get() : upIcon.get(); osg::Texture2D* downTex = mouseOverDown ? downOverIcon.get() : downIcon.get(); graphics->DrawImage(upTex, upRect.XCenter(), upRect.YCenter(), upRect.Width(), upRect.Height()); graphics->DrawImage(downTex, downRect.XCenter(), downRect.YCenter(), downRect.Width(), downRect.Height()); } /** * */ void tcAltitudeBarControl::LoadIcons() { upIcon = tc3DWindow::LoadTexture("up_arrow.png"); upOverIcon = tc3DWindow::LoadTexture("up_arrow_over.png"); downIcon = tc3DWindow::LoadTexture("down_arrow.png"); downOverIcon = tc3DWindow::LoadTexture("down_arrow_over.png"); } /** * */ void tcAltitudeBarControl::OnLButtonDown(wxMouseEvent& event) { wxPoint pos = event.GetPosition(); float x = float(pos.x); float y = float(pos.y); float commandValue = 0; wxASSERT(obj); if (barRect.ContainsPoint(x, y)) { if (isDepth) { // negative val for depth commandValue = (y - barRect.top) * currentScale / barRect.Height(); } else { commandValue = (y - barRect.bottom) * currentScale / barRect.Height(); } } else if (upRect.ContainsPoint(x, y)) { commandValue = isDepth? -currentGoal + 5 : currentGoal + 10; } else if (downRect.ContainsPoint(x, y)) { commandValue = isDepth? -currentGoal - 5 : currentGoal - 10; } else { return; } if (tcAirObject *air = dynamic_cast<tcAirObject*>(obj)) { if (commandValue < 3) commandValue = 3; air->mcGS.SetAltitude(commandValue); } else if (tcSubObject* sub = dynamic_cast<tcSubObject*>(obj)) { if (commandValue > 0) commandValue = 0; sub->mcGS.SetAltitude(commandValue); } } /** * */ void tcAltitudeBarControl::OnLButtonUp(wxMouseEvent& event) { } /** * */ void tcAltitudeBarControl::OnMouseMove(wxMouseEvent& event) { wxPoint pos = event.GetPosition(); float x = float(pos.x); float y = float(pos.y); mouseOverBar = false; mouseOverUp = false; mouseOverDown = false; if (barRect.ContainsPoint(x, y)) { mouseOverBar = true; mousePosition = pos; } else if (upRect.ContainsPoint(x, y)) { mouseOverUp = true; } else if (downRect.ContainsPoint(x, y)) { mouseOverDown = true; } } /** * */ void tcAltitudeBarControl::UpdateDrawParameters() { tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(obj); if (!platform) return; isDepth = platform->mpDBObject->mfMaxDepth_m > 0; float limit, terrain; if (isDepth) { currentValue = -platform->mcKin.mfAlt_m; limit = platform->mpDBObject->mfMaxDepth_m; terrain = -platform->mcTerrain.mfHeight_m; currentGoal = -platform->mcGS.mfGoalAltitude_m; } else { currentValue = platform->mcKin.mfAlt_m; limit = platform->mpDBObject->mfMaxAltitude_m; terrain = platform->mcTerrain.mfHeight_m; currentGoal = platform->mcGS.mfGoalAltitude_m; if (terrain < 0) terrain = 0; } if (currentGoal > limit) currentGoal = limit; else if (currentGoal < 0) currentGoal = 0; // update scale while ((currentScale*increaseScaleThresh < currentGoal) && (currentScale < 40000)) { currentScale *= 2.0; } while ((currentScale*decreaseScaleThresh > currentGoal) && (currentScale > 100)) { currentScale *= 0.5; } if (limit > currentScale) limit = currentScale; if (terrain > currentScale) terrain = currentScale; float k = barRect.Height() / currentScale; if (isDepth) { currentRect.top = barRect.top; currentRect.bottom = currentRect.top - k * currentValue; if (currentRect.bottom < barRect.bottom) currentRect.bottom = barRect.bottom; yGoal = currentRect.top - k * currentGoal; yTerrain = currentRect.top - k * terrain; yLimit = currentRect.top - k * limit; } else { currentRect.bottom = barRect.bottom; currentRect.top = currentRect.bottom + k * currentValue; if (currentRect.top > barRect.top) currentRect.top = barRect.top; yGoal = currentRect.bottom + k * currentGoal; yTerrain = currentRect.bottom + k * terrain; yLimit = currentRect.bottom + k * limit; } currentRect.left = barRect.left; currentRect.right = barRect.right; if (mouseOverBar) { overRect.left = barRect.left; overRect.right = barRect.right; if (isDepth) { overRect.top = barRect.top; overRect.bottom = mousePosition.y; } else { overRect.top = mousePosition.y; overRect.bottom = barRect.bottom; } } /* tcRect overRect; ///< filled semi-transparent rect for mouse over position */ } /** * */ tcAltitudeBarControl::tcAltitudeBarControl(float x, float y, float width, float height) : barRect(x, x+width, y, y+height), fontSize(10.0), fontSizeLarge(14.0), increaseScaleThresh(0.5), decreaseScaleThresh(0.25), mouseOverBar(false), mouseOverUp(false), mouseOverDown(false), currentScale(800), color(0.4, 1, 0.4, 1), colorDim(0.2, 0.5, 0.2, 1), neutralColor(0.8, 0.8, 0.8, 1), dangerColor(0.8, 0.3, 0.3, 1), warnColor(0.8, 0.8, 0.3, 1), overColor(1, 1, 1, 0.5) { float iconSize = 12; upRect.Set(barRect.GetRight() + 20, barRect.GetRight() + 20 + iconSize, barRect.YCenter(), barRect.YCenter() + iconSize); upRect.Offset(-0.5*iconSize, -0.5*iconSize); downRect = upRect; upRect.Offset(0, 0.35*(barRect.Height()-iconSize)); downRect.Offset(0, -0.35*(barRect.Height()-iconSize)); LoadIcons(); } /** * */ tcAltitudeBarControl::~tcAltitudeBarControl() { } Index: tcMessageCenter.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMessageCenter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMessageCenter.cpp 14 Nov 2004 22:52:21 -0000 1.1 --- tcMessageCenter.cpp 23 Nov 2004 23:30:56 -0000 1.2 *************** *** 110,114 **** // move channelTab to next position ! channelTab.Offset(channelTab.Width() + 2.0, 0); channelMap[channelName] = channel; --- 110,114 ---- // move channelTab to next position ! channelTab.Offset(channelTab.Width() + 4.0, 0); channelMap[channelName] = channel; *************** *** 187,190 **** --- 187,196 ---- tcMessageCenter::~tcMessageCenter() { + std::map<std::string, tcMessageChannel*>::iterator iter; + for (iter = channelMap.begin(); iter != channelMap.end(); ++iter) + { + tcMessageChannel* channel = iter->second; + delete channel; + } } Index: tcMessageChannel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMessageChannel.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMessageChannel.cpp 14 Nov 2004 22:52:21 -0000 1.1 --- tcMessageChannel.cpp 23 Nov 2004 23:30:56 -0000 1.2 *************** *** 75,79 **** else if (isMouseOver) { ! buttonColor.set(0.05, 0.05, 0.3, 1); buttonTextColor.set(1, 1, 1, 1); } --- 75,79 ---- else if (isMouseOver) { ! buttonColor.set(0.1, 0.1, 0.5, 1); buttonTextColor.set(1, 1, 1, 1); } Index: cspSky.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/cspSky.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** cspSky.cpp 2 Nov 2004 04:23:56 -0000 1.12 --- cspSky.cpp 23 Nov 2004 23:30:55 -0000 1.13 *************** *** 1372,1375 **** --- 1372,1376 ---- for (i = 0; i < m_nlev; ++i) { double elev = toRadians(m_lev[i]); + if (elev < 0.0) elev = 0.0; // sub horizon colors aren't correct double azimuth = -sun_A - 0.5 * C_PI; *************** *** 1387,1398 **** --- 1388,1402 ---- Color c = m_SkyShader.SkyColor(elev, azimuth+jitter, dark, intensity); azimuth += da; + colors[ci][0] = c.getA(); colors[ci][1] = c.getB(); colors[ci][2] = c.getC(); colors[ci][3] = 1.0; + if (i == m_HorizonIndex) { (*m_HorizonColors)[j] = colors[ci]; horizon_average += colors[ci]; } + ++ci; m_AverageIntensity += intensity; *************** *** 1402,1405 **** --- 1406,1410 ---- m_AverageIntensity /= m_nlev*m_nseg; m_SkyDome->dirtyDisplayList(); + } #endif Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcMapView.cpp 14 Nov 2004 22:52:21 -0000 1.8 --- tcMapView.cpp 23 Nov 2004 23:30:55 -0000 1.9 *************** *** 1242,1245 **** --- 1242,1304 ---- } + + /** + * Creates osg::Geometry object for requested NTDS symbol + */ + osg::Geometry* tcTacticalMapView::DrawNTDSSubsurface(teAffiliation affil) + { + float w = 8.0f; + + osg::Geometry* symbol = CreateSymbolGeometry(); + + // set color + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(GetAffiliationColor(affil)); + symbol->setColorArray(colors); + symbol->setColorBinding(osg::Geometry::BIND_OVERALL); + + // create vertex array + osg::Vec3Array* vertices = new osg::Vec3Array; + symbol->setVertexArray(vertices); + + + switch (affil) + { + case FRIENDLY: + case NEUTRAL: + { + AddArcPrimitive(symbol, vertices, 0, 0, 2*w, -2*w, -90, 90, 32); + break; + } + case UNKNOWN: + { + vertices->push_back(osg::Vec3(w, 0, 0)); + vertices->push_back(osg::Vec3(w, -w, 0)); + vertices->push_back(osg::Vec3(-w, -w, 0)); + vertices->push_back(osg::Vec3(-w, 0, 0)); + + symbol->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,4)); + break; + } + case HOSTILE: + { + vertices->push_back(osg::Vec3(w, 0, 0)); + vertices->push_back(osg::Vec3(0, -w, 0)); + vertices->push_back(osg::Vec3(-w, 0, 0)); + + symbol->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,3)); + break; + } + default: + { + fprintf(stderr, "Error - tcTacticalMapView::DrawNTDSSubsurface\n"); + } + } + + + return symbol; + } + + /** * Creates osg::Geometry objects for NTDS symbol set *************** *** 1266,1269 **** --- 1325,1333 ---- osg::Geometry* pAirRW = DrawNTDSAirRW((teAffiliation)nAffiliation); + // sub + osg::Geometry* pSub = DrawNTDSSubsurface((teAffiliation)nAffiliation); + + + // unknown (small square, not strictly NTDS osg::Geometry* pUnknown = DrawNTDSUnknown((teAffiliation)nAffiliation); *************** *** 1294,1298 **** case SYMBOL_SUBSURFACE: case SYMBOL_SUBMARINE: ! pSymbol = pSurface; break; case SYMBOL_FIXED: --- 1358,1362 ---- case SYMBOL_SUBSURFACE: case SYMBOL_SUBMARINE: ! pSymbol = pSub; break; case SYMBOL_FIXED: *************** *** 1346,1349 **** --- 1410,1419 ---- osg::Geometry* pMissile = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"fixed%s",zAffil); + osg::Geometry* pFixed = CreateTexturedSymbol(zBuff); + + sprintf(zBuff,"sub%s",zAffil); + osg::Geometry* pSub = CreateTexturedSymbol(zBuff); + osg::Geometry* pUnknown = CreateTexturedSymbol("unknown.png"); *************** *** 1372,1377 **** case SYMBOL_SUBSURFACE: case SYMBOL_SUBMARINE: ! pSymbol = pUnknown; break; default: pSymbol = pUnknown; --- 1442,1450 ---- case SYMBOL_SUBSURFACE: case SYMBOL_SUBMARINE: ! pSymbol = pSub; break; + case SYMBOL_FIXED: + pSymbol = pFixed; + break; default: pSymbol = pUnknown; Index: tcParticleEffect.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcParticleEffect.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcParticleEffect.cpp 7 Nov 2004 03:40:44 -0000 1.5 --- tcParticleEffect.cpp 23 Nov 2004 23:30:57 -0000 1.6 *************** *** 187,190 **** --- 187,191 ---- particlePlacer->setApplyJitter(true); + setDefaultAttributes("smoke.rgb", false, false); } *************** *** 206,209 **** --- 207,211 ---- particlePlacer->setApplyJitter(true); + setDefaultAttributes("smoke.rgb", false, false); } break; *************** *** 230,233 **** --- 232,236 ---- //op->setFluidToAir(); //program->addOperator(op); + setDefaultAttributes("smoke.rgb", false, false); } break; *************** *** 254,257 **** --- 257,283 ---- op->setFluidToAir(); program->addOperator(op); + + setDefaultAttributes("smoke.rgb", false, false); + } + break; + case BUBBLES: + { + ptemplate.setLifeTime(20); + ptemplate.setSizeRange(osgParticle::rangef(1.5f, 2.5f)); + //ptemplate.setAlphaRange(osgParticle::rangef(0.1f, 0.3f)); + ptemplate.setColorRange(osgParticle::rangev4( + osg::Vec4(1.0f, 1.0f, 1.0f, 0.02f), + osg::Vec4(1.0f, 1.0f, 1.0f, 0.01f))); + ptemplate.setRadius(1.0f); + ptemplate.setMass(0.05f); + + counter->setRateRange(5, 10); + + shooter->setInitialSpeedRange(0, 0.1); + + accelOp->setAcceleration(osg::Vec3(0, 0, 0)); + + particlePlacer->setApplyJitter(false); + setDefaultAttributes("water01.png", false, false); } break; *************** *** 260,264 **** } ! setDefaultAttributes("smoke.rgb", false, false); setDefaultParticleTemplate(ptemplate); --- 286,291 ---- } ! ! //setDefaultAttributes("water06b.png", false, false); setDefaultParticleTemplate(ptemplate); *************** *** 346,350 **** program->addOperator(accelOp.get()); } ! else { osgParticle::ModularEmitter* modularEmitter = new osgParticle::ModularEmitter; --- 373,380 ---- program->addOperator(accelOp.get()); } ! //else if (smokeModeCode == BUBBLES) ! //{ ! // } ! else { osgParticle::ModularEmitter* modularEmitter = new osgParticle::ModularEmitter; --- NEW FILE: tcControl.cpp --- /** ** @file tcControl.cpp */ /* Copyright (C) 2004 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 #include "tcControl.h" #ifdef _DEBUG #define new DEBUG_NEW #endif bool tcControl::useEnglishUnits = false; /** * */ void tcControl::SetUseEnglishUnits(bool state) { useEnglishUnits = state; } /** * */ bool tcControl::IsActive() const { return isActive; } /** * */ void tcControl::SetActive(bool state) { isActive = state; } /** * */ void tcControl::SetGameObject(tcGameObject* gameObj) { wxASSERT(gameObj); obj = gameObj; } /** * */ tcControl::tcControl() : obj(0), isActive(false) { } /** * */ tcControl::~tcControl() { } Index: tcTerrainTextureFactory.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcTerrainTextureFactory.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcTerrainTextureFactory.cpp 8 Aug 2004 00:31:34 -0000 1.11 --- tcTerrainTextureFactory.cpp 23 Nov 2004 23:30:57 -0000 1.12 *************** *** 339,343 **** { int n = 0; ! seaTexture = osgDB::readImageFile("water2b.bmp"); textureInfo[n].zmin = -1000.0f; textureInfo[n].zlow = -999.0f; --- 339,344 ---- { int n = 0; ! //seaTexture = osgDB::readImageFile("water2b.bmp"); ! seaTexture = osgDB::readImageFile("rock_texture_b.jpg"); // sea bottom now textureInfo[n].zmin = -1000.0f; textureInfo[n].zlow = -999.0f; |