Thread: [Gcblue-commits] gcb_wx/src/graphics tc3DModel.cpp,1.34,1.35 tc3DViewer.cpp,1.31,1.32 tcDatabaseInfo
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2006-03-28 02:44:58
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1528/src/graphics Modified Files: tc3DModel.cpp tc3DViewer.cpp tcDatabaseInfoWindow.cpp tcDatabaseViewer.cpp Log Message: Index: tcDatabaseInfoWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcDatabaseInfoWindow.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcDatabaseInfoWindow.cpp 27 Mar 2006 01:08:17 -0000 1.3 --- tcDatabaseInfoWindow.cpp 28 Mar 2006 02:44:55 -0000 1.4 *************** *** 271,274 **** --- 271,278 ---- + void tcDatabaseInfoWindow::SetDatabaseClassName(const std::string& className) + { + databaseClassName = className; + } void tcDatabaseInfoWindow::SetDatabaseObject(long id) Index: tcDatabaseViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcDatabaseViewer.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcDatabaseViewer.cpp 27 Mar 2006 01:08:17 -0000 1.1 --- tcDatabaseViewer.cpp 28 Mar 2006 02:44:55 -0000 1.2 *************** *** 33,40 **** #include "common/tinyxml.h" #include "tcButton.h" #include "tcDatabaseObject.h" #include "tcDatabaseIterator.h" #include "tcDatabaseInfoWindow.h" ! #ifdef _DEBUG --- 33,41 ---- #include "common/tinyxml.h" #include "tcButton.h" + #include "tcDatabase.h" #include "tcDatabaseObject.h" #include "tcDatabaseIterator.h" #include "tcDatabaseInfoWindow.h" ! #include "tc3DViewer.h" #ifdef _DEBUG *************** *** 132,136 **** if (r.Inside(pos)) { ! return true; } --- 133,137 ---- if (r.Inside(pos)) { ! SelectDisplayClass(info[n].className); return true; } *************** *** 179,183 **** int oldState = item.drawState; ! if (item.className == displayName) { item.drawState = BrowseItem::ON; --- 180,184 ---- int oldState = item.drawState; ! if (item.className == displayClassName) { item.drawState = BrowseItem::ON; *************** *** 239,242 **** --- 240,260 ---- x += width + 16.0f; + + std::string caption; + + switch (n) + { + case 0: caption = "Surface naval"; break; + case 1: caption = "Submarine"; break; + case 2: caption = "Air, fixed wing"; break; + case 3: caption = "Air, rotary wing"; break; + case 4: caption = "Land"; break; + case 5: caption = "Missile"; break; + case 6: caption = "Torpedo"; break; + case 7: caption = "Ballistic"; break; + default: caption = "Error"; break; + } + + button->SetCaption(caption); } *************** *** 285,288 **** --- 303,321 ---- + void tcDatabaseViewer::SelectDisplayClass(const std::string& className) + { + databaseInfoWindow->SetDatabaseClassName(className); + if (viewer) + { + viewer->SetDatabaseViewClass(className); + } + } + + + void tcDatabaseViewer::Set3DViewer(tc3DViewer* viewer_) + { + viewer = viewer_; + } + /** * *************** *** 293,297 **** tcXmlWindow(parent, pos, size, "xml/database_viewer.xml", name), basePosition(20, 50), ! classificationMask(0) { --- 326,332 ---- tcXmlWindow(parent, pos, size, "xml/database_viewer.xml", name), basePosition(20, 50), ! classificationMask(0), ! displayClassName(""), ! viewer(0) { Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** tc3DModel.cpp 23 Mar 2006 01:11:02 -0000 1.34 --- tc3DModel.cpp 28 Mar 2006 02:44:55 -0000 1.35 *************** *** 500,503 **** --- 500,506 ---- } + /** + * Use this for accessing mode of tcDatabaseObject since transform is not valid + */ osg::Node* tc3DModel::GetModelNode() { Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** tc3DViewer.cpp 26 Mar 2006 00:32:14 -0000 1.31 --- tc3DViewer.cpp 28 Mar 2006 02:44:55 -0000 1.32 *************** *** 64,68 **** #include "tcParticleEffect.h" #include "tcSensorTrackIterator.h" ! --- 64,68 ---- #include "tcParticleEffect.h" #include "tcSensorTrackIterator.h" ! #include "tcDatabase.h" *************** *** 485,488 **** --- 485,511 ---- } + void tc3DViewer::SetDatabaseView(bool state) + { + databaseViewEnabled = state; + } + + void tc3DViewer::SetDatabaseViewClass(const std::string& databaseClass) + { + // clear previous objects from databaseViewGroup + size_t nChildren = databaseViewGroup->getNumChildren(); + databaseViewGroup->removeChild(0, nChildren); + + database::tcDatabaseObject* obj = database::tcDatabase::Get()->GetObject(databaseClass); + if (obj != 0) + { + tc3DModel* model = obj->Get3DModel(); + wxASSERT(model); + osg::ref_ptr<osg::Node> node = model->GetModelNode(); + wxASSERT(node.valid()); + databaseViewGroup->addChild(node.get()); + SetCameraRange(1.5f * node->getBound().radius()); + } + } + /** * *************** *** 961,966 **** guiView->draw(); ! ! if (isActive && sceneView.valid()) { sceneView->update(); --- 984,994 ---- guiView->draw(); ! if (isActive && databaseViewEnabled) ! { ! databaseView->update(); ! databaseView->cull(); ! databaseView->draw(); ! } ! else if (isActive && sceneView.valid()) { sceneView->update(); *************** *** 975,988 **** sceneView->cull(); sceneView->draw(); - - glFinish(); - Swap(); - } - else - { - glFinish(); - Swap(); } lastGameTime = gameTime; } --- 1003,1012 ---- sceneView->cull(); sceneView->draw(); } + + glFinish(); + Swap(); + lastGameTime = gameTime; } *************** *** 1029,1032 **** --- 1053,1072 ---- } + /** + * Version for 3D database object view + */ + void tc3DViewer::UpdateCameraDatabaseView() + { + float camx = cosf(cameraEl)*sinf(cameraAz); + float camy = cosf(cameraEl)*cosf(cameraAz); + float camz = sinf(cameraEl); + cameraPosition = osg::Vec3(camx,camy,camz)*cameraRange; + + cameraTarget = cameraTargetOffset; + + databaseView->setViewMatrixAsLookAt(cameraPosition, cameraTarget, osg::Vec3(0,0,1)); + + } + void tc3DViewer::UpdateCamera() { *************** *** 1187,1191 **** if (gameObj->model->GetNumParents()==0) { ! worldObjects->addChild(gameObj->model->GetNode().get()); } UpdateChildModels(gameObj); --- 1227,1231 ---- if (gameObj->model->GetNumParents()==0) { ! worldObjects->addChild(gameObj->model->GetNode().get()); } UpdateChildModels(gameObj); *************** *** 1363,1366 **** --- 1403,1449 ---- /** + * Creates scene view to display 3D objects for database viewer + */ + void tc3DViewer::InitDatabaseView(const wxPoint& pos, const wxSize& size) + { + databaseView = new osgUtil::SceneView(); + + if (!displaySettings.valid()) + { + wxASSERT(databaseView->getDisplaySettings()==NULL); + displaySettings = new osg::DisplaySettings; + displaySettings->setDepthBuffer(true); + } + + databaseView->setDisplaySettings(displaySettings.get()); + databaseView->setDefaults(); + databaseView->setState(sceneView->getState()); + + + wxWindow* parent = wxWindow::GetParent(); + wxSize parentSize = parent->GetSize(); + int parentHeight = parentSize.GetHeight(); + int correctedY = parentHeight - (pos.y + size.GetHeight()); + + // Update projection matrix + float aspectRatio = (float)size.GetWidth() / (float)size.GetHeight(); + float zmid = sqrtf(zmin*zmax); + databaseView->setProjectionMatrixAsPerspective(45.0, aspectRatio, zmin, zmid); + + + databaseView->setViewport(pos.x, correctedY, size.GetWidth(), size.GetHeight()); + databaseView->setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR); + databaseView->setLightingMode(osgUtil::SceneView::NO_SCENEVIEW_LIGHT); + databaseView->setCullingMode(osg::CullStack::NO_CULLING); + + // set up the clear mask. + osgUtil::RenderStage *stage = databaseView->getRenderStage(); + stage->setClearMask(GL_DEPTH_BUFFER_BIT); + stage->setClearDepth(1.0f); + + } + + + /** * */ *************** *** 1892,1895 **** --- 1975,1983 ---- static long lastHook = -1; + if (databaseViewEnabled) + { + UpdateCameraDatabaseView(); + return; + } if (lastHook != hookID) *************** *** 2022,2025 **** --- 2110,2115 ---- lookAtTarget = true; usePolarOffset = true; + databaseViewEnabled = false; + cameraLongitude = 0; cameraLatitude = 0; *************** *** 2042,2045 **** --- 2132,2137 ---- InitGuiView(); + InitDatabaseView(pos, size); + osgDB::Registry::instance()->setDataFilePathList("3d"); *************** *** 2080,2083 **** --- 2172,2178 ---- orthoProjection->addChild(hudObjects.get()); + databaseViewGroup = new osg::Group(); + databaseView->setSceneData(databaseViewGroup.get()); + InitState(); |