[Gcblue-commits] gcb_wx/src/graphics ObjectUpdater.cpp,1.10,1.11 tc3DModel.cpp,1.14,1.15 tc3DViewer.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-11-06 15:14:04
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31472/src/graphics Modified Files: ObjectUpdater.cpp tc3DModel.cpp tc3DViewer.cpp tcHookInfo.cpp tcMapView.cpp tcScenarioSelectView.cpp Log Message: Added optical sensor model, fixed generic model display for sensor tracks Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tc3DModel.cpp 14 Sep 2004 02:01:46 -0000 1.14 --- tc3DModel.cpp 6 Nov 2004 15:13:41 -0000 1.15 *************** *** 2,7 **** ** @file tc3DModel.cpp */ ! /* ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tc3DModel.cpp */ ! /* Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 25,31 **** #ifndef WX_PRECOMP #include "wx/wx.h" ! #ifdef WIN32 ! #include "wx/msw/private.h" // for MS Windows specific definitions ! #endif // WIN32 #endif // WX_PRECOMP --- 24,30 ---- #ifndef WX_PRECOMP #include "wx/wx.h" ! //#ifdef WIN32 ! //#include "wx/msw/private.h" // for MS Windows specific definitions ! //#endif // WIN32 #endif // WX_PRECOMP *************** *** 38,41 **** --- 37,41 ---- #include "tcGenericDBObject.h" #include <osg/MatrixTransform> + #include <osg/Switch> #include <osgDB/ReadFile> #include <osgUtil/SmoothingVisitor> *************** *** 207,211 **** { // shallow copy node if larger than detail threshold ! const BoundingSphere& bs = node->getBound(); if (bs.radius() >= _detailThreshold) { --- 207,211 ---- { // shallow copy node if larger than detail threshold ! const osg::BoundingSphere& bs = node->getBound(); if (bs.radius() >= _detailThreshold) { *************** *** 252,255 **** --- 252,294 ---- osg::ref_ptr<osg::Group> tc3DModel::world; + osg::ref_ptr<osg::Node> tc3DModel::unknownAll; + osg::ref_ptr<osg::Node> tc3DModel::unknownAir; + osg::ref_ptr<osg::Node> tc3DModel::unknownLand; + osg::ref_ptr<osg::Node> tc3DModel::unknownSurface; + + bool tc3DModel::useSmoothing = true; + + /** + * Static method to load unknowns models. Should be called + * once at startup + */ + void tc3DModel::LoadUnknowns() + { + if (unknownAll.valid()) return; // models already loaded + fprintf(stdout, "Loading unknowns: "); + + unknownAll = osgDB::readNodeFile("unk_all.3ds"); + unknownAir = osgDB::readNodeFile("air_small.3ds"); + unknownLand = osgDB::readNodeFile("surf_small.3ds"); + unknownSurface = osgDB::readNodeFile("surf_small.3ds"); + + if (!unknownAll.valid()) fprintf(stdout, "FAILED unk_all.3ds "); + if (!unknownAir.valid()) fprintf(stdout, "FAILED air_small.3ds "); + if (!unknownLand.valid()) fprintf(stdout, "FAILED surf_small.3ds "); + if (!unknownSurface.valid()) fprintf(stdout, "FAILED surf_small.3ds "); + fprintf(stdout, "done\n"); + + if (useSmoothing) + { + osgUtil::SmoothingVisitor smoothingVisitor; + + unknownAll->accept(smoothingVisitor); + unknownAir->accept(smoothingVisitor); + unknownLand->accept(smoothingVisitor); + unknownSurface->accept(smoothingVisitor); + } + } + + /** * Adds child to modelTransform of this model. *************** *** 315,318 **** --- 354,360 ---- /** + * Always returns radius of true model without considering generic + * models. + * @see tc3DModel::GetRadiusGeneric * @return radius of bounding sphere in meters */ *************** *** 322,325 **** --- 364,387 ---- } + /** + * @return radius of rendered model, considering generics + */ + float tc3DModel::GetRadiusGeneric() + { + switch (genericMode) + { + case USE_TRUE_MODEL: return GetRadius(); + case USE_UNKNOWN_GENERIC: return unknownAll.get()->getBound().radius(); + case USE_AIR_GENERIC: return unknownAir.get()->getBound().radius(); + case USE_LAND_GENERIC: return unknownLand.get()->getBound().radius(); + case USE_SURFACE_GENERIC: return unknownSurface.get()->getBound().radius(); + case DISABLE_MODEL: return unknownAll.get()->getBound().radius(); + default: + fprintf(stderr, "Error - tc3DModel::GetRadiusGeneric - invalid genericMode\n"); + return 1.0f; + } + + } + void tc3DModel::Load(std::string model_name) { *************** *** 392,395 **** --- 454,486 ---- /** + * Sets generic display mode for model. + * Mode controls switch selection at root + * Options for mode are + * USE_TRUE_MODEL = 0, + * USE_UNKNOWN_GENERIC = 1, + * USE_AIR_GENERIC = 2, + * USE_LAND_GENERIC = 3, + * USE_SURFACE_GENERIC = 4, + * DISABLE_MODEL = 5 + */ + void tc3DModel::SetGenericMode(int mode) + { + if (mode == DISABLE_MODEL) + { + genericMode = DISABLE_MODEL; + root->setAllChildrenOff(); + return; + } + + if ((mode < 0) || (mode > 5)) + { + fprintf(stderr, "Error - tc3DModel::SetGenericMode - Mode out of range\n"); + return; + } + root->setSingleChildOn(mode); + genericMode = mode; + } + + /** * Called once per instance to set and configure update callback. * Bind switchVariable for animations *************** *** 440,444 **** tc3DModel::tc3DModel() { - useSmoothing = true; } --- 531,534 ---- *************** *** 452,462 **** { wxASSERT(source->modelNode.valid()); // error if modelNode not loaded yet ! modelTransform = new osg::MatrixTransform; modelTransform->setDataVariance(osg::Object::DYNAMIC); modelGroup = new osg::LOD; ! modelTransform->addChild(modelGroup.get()); animationInfo.clear(); --- 542,562 ---- { wxASSERT(source->modelNode.valid()); // error if modelNode not loaded yet ! wxASSERT(unknownAll.valid()); modelTransform = new osg::MatrixTransform; modelTransform->setDataVariance(osg::Object::DYNAMIC); + + root = new osg::Switch; + modelTransform->addChild(root.get()); + modelGroup = new osg::LOD; ! root->addChild(modelGroup.get(), true); ! root->addChild(unknownAll.get(), false); ! root->addChild(unknownAir.get(), false); ! root->addChild(unknownLand.get(), false); ! root->addChild(unknownSurface.get(), false); ! genericMode = USE_TRUE_MODEL; ! animationInfo.clear(); Index: tcScenarioSelectView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcScenarioSelectView.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcScenarioSelectView.cpp 2 Nov 2004 04:23:56 -0000 1.6 --- tcScenarioSelectView.cpp 6 Nov 2004 15:13:41 -0000 1.7 *************** *** 219,222 **** --- 219,224 ---- { loadedScenarioCaption = caption; + tcOptions::Get()->SetOptionString("LastScenarioPath", filePath.c_str()); + tcOptions::Get()->SetOptionString("LastScenarioName", caption.c_str()); } else Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcMapView.cpp 3 Nov 2004 16:36:43 -0000 1.6 --- tcMapView.cpp 6 Nov 2004 15:13:41 -0000 1.7 *************** *** 1600,1603 **** --- 1600,1604 ---- if (bBearingOnly) { + symbolColor._v[3] = 0.5f; DrawLineR(xv, yv, xv_passive, yv_passive, symbolColor); } Index: tcHookInfo.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcHookInfo.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcHookInfo.cpp 2 Nov 2004 04:23:56 -0000 1.4 --- tcHookInfo.cpp 6 Nov 2004 15:13:41 -0000 1.5 *************** *** 36,39 **** --- 36,41 ---- #include "commandlist.h" #include "simmath.h" + #include "tcDatabase.h" + #include "tcTime.h" #ifdef _DEBUG *************** *** 67,74 **** // classification ClassificationToString(pTrack->mnClassification, zBuff); color.set(0.4f, 1.0f, 0.4f, 1.0f); ! DrawTextR(zBuff, ftextx-2.0f, ftexty, defaultFont.get(), color, fontSizeLarge, LEFT_BASE_LINE); ! ftexty += 20.0f; // speed, heading, altitude, terrain info --- 69,101 ---- // classification ClassificationToString(pTrack->mnClassification, zBuff); + strcat(zBuff, " track"); color.set(0.4f, 1.0f, 0.4f, 1.0f); ! if (pSMTrack->mnDatabaseID == -1) ! { ! DrawTextR(zBuff, ftextx-2.0f, ftexty, defaultFont.get(), ! color, fontSizeLarge, LEFT_BASE_LINE); ! ftexty += 20.0f; ! } ! else // track is identified, look up class name ! { ! if (tcDatabaseObject* databaseObj = database->GetObject(pSMTrack->mnDatabaseID)) ! { ! s = databaseObj->mzClass.mz; ! } ! else // error, not found in database ! { ! s = "Error"; ! } ! ! DrawTextR(s.c_str(), ftextx-2.0f, ftexty, ! defaultFont.get(), color, fontSizeLarge, LEFT_BASE_LINE); ! ftexty += 15.0f; ! ! DrawTextR(zBuff, ftextx, ftexty, ! defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ! ftexty += 20.0f; ! } ! // speed, heading, altitude, terrain info *************** *** 136,144 **** strcpy(zBuff,"Error"); } ! DrawTextR(zBuff, ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ftexty += 15; } //*********** draw engagement info ************** DrawTrackEngaged(pSMTrack, ftextx, ftexty); --- 163,229 ---- strcpy(zBuff,"Error"); } ! DrawTextR(zBuff, ftextx + 3.0f, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ftexty += 15; } + ftexty += 5; + + /* Platform ambiguity list, update if at least one emitter + ** is detected, and detailed identification is not + ** available */ + if ((nEmitters > 0) && (pSMTrack->mnDatabaseID == -1)) + { + unsigned nCandidates = pSMTrack->ambiguityList.size(); + if (nCandidates) + { + sprintf(zBuff, "Ambiguity list (%d):", nCandidates); + DrawTextR(zBuff, ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); + ftexty+=15; + } + else + { + DrawTextR("Ambiguity list not available", ftextx, ftexty, defaultFont.get(), + color, fontSize, LEFT_BASE_LINE); + ftexty += 15; + } + + unsigned int currentCount = tcTime::Get()->Get30HzCount(); + if (currentCount - lastCycleCount > 75) // 2.5 seconds + { + lastCycleCount = currentCount; + if (nCandidates > 4) + { + ambiguityIdx += 4; + } + } + if (ambiguityIdx >= nCandidates) ambiguityIdx = 0; + + for (unsigned int n=ambiguityIdx; (n < ambiguityIdx+4) && (n < nCandidates); n++) + { + long candidateID = pSMTrack->ambiguityList[n]; + tcDatabaseObject* dbObj = mpSS->mpDatabase->GetObject(candidateID); + if (dbObj) + { + strcpy(zBuff, dbObj->mzClass.mz); + } + else + { + strcpy(zBuff, "Error"); + } + DrawTextR(zBuff, ftextx + 3.0f, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); + + ftexty += 10; + } + + } + + + + + + + + //*********** draw engagement info ************** DrawTrackEngaged(pSMTrack, ftextx, ftexty); *************** *** 250,254 **** s = pHookedObj->mzUnit.mz; color.set(0.4f, 1.0f, 0.4f, 1.0f); ! DrawTextR(s.c_str(), ftextx-2.0f, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ftexty += 20.0f; --- 335,339 ---- s = pHookedObj->mzUnit.mz; color.set(0.4f, 1.0f, 0.4f, 1.0f); ! DrawTextR(s.c_str(), ftextx-2.0f, ftexty, defaultFont.get(), color, fontSizeLarge, LEFT_BASE_LINE); ftexty += 20.0f; *************** *** 500,514 **** mpSS = NULL; mpOptions = NULL; mpUserInfo = NULL; drawEngagedMode = 1; } /***********************************************************************************/ tcHookInfo::~tcHookInfo() { ! /* ! if (mpPen != NULL) {delete mpPen;} ! if (mpFont != NULL) {delete mpFont;} ! if (mpFontLarge != NULL) {delete mpFontLarge;} ! if (mpBrush != NULL) {delete mpBrush;} ! */ } --- 585,597 ---- mpSS = NULL; mpOptions = NULL; + database = tcDatabase::Get(); mpUserInfo = NULL; drawEngagedMode = 1; + ambiguityIdx = 0; + lastCycleCount = 0; } /***********************************************************************************/ tcHookInfo::~tcHookInfo() { ! } Index: ObjectUpdater.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/ObjectUpdater.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ObjectUpdater.cpp 2 Nov 2004 04:23:56 -0000 1.10 --- ObjectUpdater.cpp 6 Nov 2004 15:13:41 -0000 1.11 *************** *** 1,6 **** --- 1,33 ---- + /** + ** @file ObjectUpdater.cpp + */ + /* Copyright (C) 2003-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" + #include "ObjectUpdater.h" #include "tcGameObject.h" #include "tc3DModel.h" #include "tc3DViewer.h" + #include "tcSimState.h" + #include "tcOptions.h" + #include "tcSensorMap.h" + #include <osg/MatrixTransform> #include "tcParticleEffect.h" *************** *** 12,16 **** using namespace osg; ! tc3DViewer* ObjectUpdater::viewer = NULL; --- 39,45 ---- using namespace osg; ! tc3DViewer* ObjectUpdater::viewer = 0; ! tcSimState* ObjectUpdater::simState = 0; ! Sensor::tcSensorMap* ObjectUpdater::sensorMap = 0; *************** *** 33,36 **** --- 62,66 ---- }; + void ObjectUpdater::UpdateAnimations() { *************** *** 55,59 **** } ! void ObjectUpdater::operator()(Node* node, NodeVisitor* nv) { float yaw, pitch, roll; --- 85,171 ---- } ! /** ! * Omits child (captive object) updates ! */ ! void ObjectUpdater::UpdateTrack(Node* node) ! { ! tcGameObject* gameObject = model->GetGameObj(); ! wxASSERT(gameObject); ! ! unsigned int ownAlliance = simState->mpUserInfo->GetOwnAlliance(); ! tcSensorMapTrack* track = sensorMap->GetSensorMapTrack(gameObject->mnID, ownAlliance); ! ! int n3DCheatMode = tcOptions::Get()->mn3DCheatMode; ! ! if ((n3DCheatMode == 0) || (track == 0) || (track->IsBearingOnly())) ! { ! model->SetGenericMode(tc3DModel::DISABLE_MODEL); ! return; ! } ! ! int genericMode = 0; ! ! // first case assumes track identification is never wrong (currently true) ! if (track->mnDatabaseID != -1) genericMode = tc3DModel::USE_TRUE_MODEL; ! else if (track->IsSurface()) genericMode = tc3DModel::USE_SURFACE_GENERIC; ! else if (track->IsAir()) genericMode = tc3DModel::USE_AIR_GENERIC; ! else if (track->IsMissile()) genericMode = tc3DModel::USE_AIR_GENERIC; ! else genericMode = tc3DModel::USE_UNKNOWN_GENERIC; ! ! model->SetGenericMode(genericMode); ! ! ! ! float yaw, pitch, roll; ! float x, y, z; ! yaw = track->mfHeading_rad; ! pitch = 0; ! roll = 0; ! ! // if object is close to camera, use predicted track for position ! if (distanceFromCamera < 10e3) ! { ! tcTrack predicted; ! track->GetPrediction(predicted, simState->GetTime()); ! x = viewer->LonToX(predicted.mfLon_rad); ! y = viewer->LatToY(predicted.mfLat_rad); ! z = predicted.GetOrGuessAltitude(); ! } ! else ! { ! x = viewer->LonToX(track->mfLon_rad); ! y = viewer->LatToY(track->mfLat_rad); ! z = track->GetOrGuessAltitude(); ! } ! ! ! float yawCorrection = C_PI; // 180 degrees added to yaw for different 3D model convention ! ! ! // not correct for child objects ! osg::Vec3 cameraDelta = osg::Vec3(x,y,z) - viewer->GetCameraPosition(); ! distanceFromCamera = cameraDelta.length(); ! model->SetDistanceFromCamera(distanceFromCamera); ! ! ! if ((model->IsSmokeEnabled())&&(track->IsMissile())) ! { ! model->UpdateSmokePosition(x, y, z); ! } ! ! osg::Matrix m = ! osg::Matrix::rotate(osg::inRadians(roll),0.0f,1.0f,0.0f)* ! osg::Matrix::rotate(-osg::inRadians(pitch),1.0f,0.0f,0.0f)* ! osg::Matrix::rotate(-osg::inRadians(yaw + yawCorrection),0.0f,0.0f,1.0f)*osg::Matrix::translate(x,y,z) ! ; ! ! UpdaterCallbackVisitor cv(m); ! node->accept(cv); ! ! } ! ! ! ! void ObjectUpdater::UpdateTrue(Node* node) { float yaw, pitch, roll; *************** *** 62,147 **** float yawCorrection = 0; ! tcGameObject *gameObject = model->GetGameObj(); if (gameObject) { ! if (!gameObject->parent) ! { ! tcKinematics *kin = &gameObject->mcKin; ! yaw = kin->mfHeading_rad; ! pitch = kin->mfPitch_rad; ! roll = kin->mfRoll_rad; ! x = viewer->LonToX(kin->mfLon_rad); ! y = viewer->LatToY(kin->mfLat_rad); ! z = kin->mfAlt_m; ! yawCorrection = C_PI; // 180 degrees added to yaw for different 3D model convention ! } ! else ! { ! if (useRelativeChildPos) ! { ! tsRelativePosition *pos = &gameObject->rel_pos; ! yaw = pos->yaw; ! pitch = pos->pitch; ! roll = pos->roll; ! x = -pos->dx; // backwards because of 180 deg model issue ! y = pos->dz; // backwards because of 180 deg model issue ! z = pos->dy; ! isVisible = pos->isVisible; ! } ! else ! { ! // not implemented correctly, just a test mode ! tcKinematics *kin = &gameObject->parent->mcKin; ! yaw = kin->mfHeading_rad; ! pitch = kin->mfPitch_rad; ! roll = kin->mfRoll_rad; ! x = viewer->LonToX(kin->mfLon_rad); ! y = viewer->LatToY(kin->mfLat_rad); ! z = kin->mfAlt_m + 60.0f; ! yawCorrection = C_PI; ! } ! } ! ! // not correct for child objects ! osg::Vec3 cameraDelta = osg::Vec3(x,y,z) - viewer->GetCameraPosition(); ! distanceFromCamera = cameraDelta.length(); ! model->SetDistanceFromCamera(distanceFromCamera); ! ! /* ! if ((distanceFromCamera <= 20)&&(gameObject->parent == 0)) ! { ! int xx = 8; ! } ! */ ! /* ! if ((abs(x) < 4000)&&(gameObject->parent == 0)) ! { ! int xx = 8; ! osg::Vec3 camPos = viewer->GetCameraPosition(); ! } ! */ ! ! ! if (model->IsSmokeEnabled()) ! { ! model->UpdateSmokePosition(x, y, z); ! } ! osg::Matrix m = ! osg::Matrix::rotate(osg::inRadians(roll),0.0f,1.0f,0.0f)* ! osg::Matrix::rotate(-osg::inRadians(pitch),1.0f,0.0f,0.0f)* ! osg::Matrix::rotate(-osg::inRadians(yaw + yawCorrection),0.0f,0.0f,1.0f)*osg::Matrix::translate(x,y,z) ! ; ! if (isVisible) ! { ! UpdaterCallbackVisitor cv(m); ! node->accept(cv); ! } ! } ! UpdateAnimations(); - // must call any nested node callbacks and continue subgraph traversal. - NodeCallback::traverse(node,nv); } --- 174,261 ---- float yawCorrection = 0; ! tcGameObject* gameObject = model->GetGameObj(); ! ! model->SetGenericMode(tc3DModel::USE_TRUE_MODEL); ! ! if (!gameObject->parent) ! { ! tcKinematics* kin = &gameObject->mcKin; ! yaw = kin->mfHeading_rad; ! pitch = kin->mfPitch_rad; ! roll = kin->mfRoll_rad; ! x = viewer->LonToX(kin->mfLon_rad); ! y = viewer->LatToY(kin->mfLat_rad); ! z = kin->mfAlt_m; ! ! yawCorrection = C_PI; // 180 degrees added to yaw for different 3D model convention ! } ! else ! { ! tsRelativePosition *pos = &gameObject->rel_pos; ! yaw = pos->yaw; ! pitch = pos->pitch; ! roll = pos->roll; ! x = -pos->dx; // backwards because of 180 deg model issue ! y = pos->dz; // backwards because of 180 deg model issue ! z = pos->dy; ! isVisible = pos->isVisible; ! } ! ! // not correct for child objects ! osg::Vec3 cameraDelta = osg::Vec3(x,y,z) - viewer->GetCameraPosition(); ! distanceFromCamera = cameraDelta.length(); ! model->SetDistanceFromCamera(distanceFromCamera); ! ! ! if (model->IsSmokeEnabled()) ! { ! model->UpdateSmokePosition(x, y, z); ! } ! ! osg::Matrix m = ! osg::Matrix::rotate(osg::inRadians(roll),0.0f,1.0f,0.0f)* ! osg::Matrix::rotate(-osg::inRadians(pitch),1.0f,0.0f,0.0f)* ! osg::Matrix::rotate(-osg::inRadians(yaw + yawCorrection),0.0f,0.0f,1.0f)*osg::Matrix::translate(x,y,z) ! ; ! if (isVisible) ! { ! UpdaterCallbackVisitor cv(m); ! node->accept(cv); ! } ! } ! ! ! /** ! * Main update method. ! * Updates position and attitude of object ! * Fix this so that the track-only mode does not require a game object to be ! * present. ! */ ! void ObjectUpdater::operator()(Node* node, NodeVisitor* nv) ! { ! tcGameObject* gameObject = model->GetGameObj(); ! int displayMode = tcOptions::Get()->mn3DCheatMode; ! if (gameObject) { ! if ((displayMode == 3) || simState->mpUserInfo->IsOwnAlliance(gameObject->mnAlliance)) ! { ! UpdateTrue(node); ! } ! else ! { ! UpdateTrack(node); ! } ! UpdateAnimations(); ! // must call any nested node callbacks and continue subgraph traversal. ! NodeCallback::traverse(node,nv); ! } ! else // no game object available ! { ! fprintf(stderr, "Error - ObjectUpdater::operator() - called with null game obj\n"); ! } } *************** *** 150,154 **** { model = NULL; ! useRelativeChildPos = true; } --- 264,272 ---- { model = NULL; ! if (!simState) ! { ! simState = tcSimState::Get(); ! sensorMap = simState->GetSensorMap(); ! } } *************** *** 156,160 **** model(mod) { ! useRelativeChildPos = true; } --- 274,282 ---- model(mod) { ! if (!simState) ! { ! simState = tcSimState::Get(); ! sensorMap = simState->GetSensorMap(); ! } } Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tc3DViewer.cpp 29 Oct 2004 02:50:43 -0000 1.4 --- tc3DViewer.cpp 6 Nov 2004 15:13:41 -0000 1.5 *************** *** 88,91 **** --- 88,94 ---- { + /** + * This code was taken from one of the osg sources + */ class PrintCullVistor : public osgUtil::CullVisitor { *************** *** 112,121 **** } ! void apply(Geode& node) { if (isCulled(node)) return; // push the node's state. ! StateSet* node_state = node.getStateSet(); if (node_state) pushStateSet(node_state); --- 115,124 ---- } ! void apply(osg::Geode& node) { if (isCulled(node)) return; // push the node's state. ! osg::StateSet* node_state = node.getStateSet(); if (node_state) pushStateSet(node_state); *************** *** 123,131 **** handle_cull_callbacks_and_traverse(node); ! RefMatrix& matrix = getModelViewMatrix(); for(unsigned int i=0;i<node.getNumDrawables();++i) { ! Drawable* drawable = node.getDrawable(i); ! const BoundingBox &bb =drawable->getBound(); if( drawable->getCullCallback() ) --- 126,134 ---- handle_cull_callbacks_and_traverse(node); ! osg::RefMatrix& matrix = getModelViewMatrix(); for(unsigned int i=0;i<node.getNumDrawables();++i) { ! osg::Drawable* drawable = node.getDrawable(i); ! const osg::BoundingBox &bb = drawable->getBound(); if( drawable->getCullCallback() ) *************** *** 134,139 **** continue; } ! ! //else { if (node.isCullingActive() && isCulled(bb)) continue; --- 137,141 ---- continue; } ! else { if (node.isCullingActive() && isCulled(bb)) continue; *************** *** 147,151 **** // push the geoset's state on the geostate stack. ! StateSet* stateset = drawable->getStateSet(); if (stateset) pushStateSet(stateset); --- 149,153 ---- // push the geoset's state on the geostate stack. ! osg::StateSet* stateset = drawable->getStateSet(); if (stateset) pushStateSet(stateset); *************** *** 559,562 **** --- 561,570 ---- + void tc3DViewer::AttachSimState(tcSimState *ss) + { + simState = ss; + } + + /** * Adds text drawable to textGeode. Take care with reference count *************** *** 734,738 **** depth->setRange(0, 1); depth->setWriteMask(true); ! terrainState->setAttributeAndModes(depth,StateAttribute::ON); terrainState->setRenderBinDetails(-2, "RenderBin"); --- 742,746 ---- depth->setRange(0, 1); depth->setWriteMask(true); ! terrainState->setAttributeAndModes(depth, osg::StateAttribute::ON); terrainState->setRenderBinDetails(-2, "RenderBin"); *************** *** 1045,1053 **** * @return object position in world coordinates. */ ! osg::Vec3 tc3DViewer::GetObjectPosition(tcGameObject *obj) { ! float x = LonToX(obj->mcKin.mfLon_rad); ! float y = LatToY(obj->mcKin.mfLat_rad); ! float z = obj->mcKin.mfAlt_m; return osg::Vec3(x,y,z); } --- 1053,1094 ---- * @return object position in world coordinates. */ ! osg::Vec3 tc3DViewer::GetObjectPosition(tcGameObject* obj) { ! int n3DCheatMode = tcOptions::Get()->mn3DCheatMode; ! ! float x, y, z; ! if (n3DCheatMode == 3) ! { ! x = LonToX(obj->mcKin.mfLon_rad); ! y = LatToY(obj->mcKin.mfLat_rad); ! z = obj->mcKin.mfAlt_m; ! } ! else ! { ! tcSensorMap* sensorMap = simState->GetSensorMap(); ! unsigned int ownAlliance = simState->mpUserInfo->GetOwnAlliance(); ! if (ownAlliance == obj->mnAlliance) ! { ! x = LonToX(obj->mcKin.mfLon_rad); ! y = LatToY(obj->mcKin.mfLat_rad); ! z = obj->mcKin.mfAlt_m; ! } ! else if (tcSensorMapTrack* track = ! sensorMap->GetSensorMapTrack(obj->mnID, ownAlliance)) ! { ! tcTrack predicted; ! track->GetPrediction(predicted, simState->GetTime()); ! x = LonToX(predicted.mfLon_rad); ! y = LatToY(predicted.mfLat_rad); ! z = predicted.GetOrGuessAltitude(); ! } ! else ! { ! x = LonToX(obj->mcKin.mfLon_rad); ! y = LatToY(obj->mcKin.mfLat_rad); ! z = obj->mcKin.mfAlt_m; ! } ! } ! return osg::Vec3(x,y,z); } *************** *** 1339,1343 **** osg::Vec3 upperLeft(20.0f, (float)mnHeight - 40.0f, 0.0f); osg::Vec3 upperRight((float)mnWidth - 150.0f, (float)mnHeight - 40.0f, 0.0f); ! osg::Vec3 bottomCenter(0.5 * (float)mnWidth, 40.0f, 0.0f); osg::Vec4 color(0.4f, 0.4f, 0.8f, 0.8f); --- 1380,1385 ---- osg::Vec3 upperLeft(20.0f, (float)mnHeight - 40.0f, 0.0f); osg::Vec3 upperRight((float)mnWidth - 150.0f, (float)mnHeight - 40.0f, 0.0f); ! osg::Vec3 bottomCenter(0.5 * (float)mnWidth, 0.2f*(float)mnHeight, 0.0f); ! osg::Vec3 topCenter(0.5 * (float)mnWidth, 0.8f*(float)mnHeight, 0.0f); osg::Vec4 color(0.4f, 0.4f, 0.8f, 0.8f); *************** *** 1350,1353 **** --- 1392,1398 ---- AddTextObject(2, bottomCenter, 16.0, osg::Vec4(0.9f, 0.9f, 0.7f, 0.9f), osgText::Text::AlignmentType::CENTER_CENTER); + + AddTextObject(3, topCenter, 16.0, osg::Vec4(0.9f, 0.9f, 0.7f, 0.9f), + osgText::Text::AlignmentType::CENTER_CENTER); } *************** *** 1357,1360 **** --- 1402,1406 ---- ClearTextObject(1); ClearTextObject(2); + ClearTextObject(3); } *************** *** 1466,1470 **** osg::StateSet *stateSet = rootnode->getOrCreateStateSet(); wxASSERT(stateSet); ! osg::StateAttribute *sa = stateSet->getAttribute(StateAttribute::POLYGONMODE); osg::PolygonMode *pm = dynamic_cast<osg::PolygonMode*>(sa); if (pm == NULL) --- 1512,1516 ---- osg::StateSet *stateSet = rootnode->getOrCreateStateSet(); wxASSERT(stateSet); ! osg::StateAttribute *sa = stateSet->getAttribute(osg::StateAttribute::POLYGONMODE); osg::PolygonMode *pm = dynamic_cast<osg::PolygonMode*>(sa); if (pm == NULL) *************** *** 1500,1505 **** { // set camera position to ! const osg::BoundingSphere& bs = obj->model->GetNode()->getBound(); ! cameraRange = 4*bs.radius(); if (cameraRange < 12.0f) cameraRange = 12.0f; } --- 1546,1552 ---- { // set camera position to ! //const osg::BoundingSphere& bs = obj->model->GetNode()->getBound(); ! //cameraRange = 4*bs.radius(); ! cameraRange = 2 * obj->model->GetRadiusGeneric(); if (cameraRange < 12.0f) cameraRange = 12.0f; } *************** *** 1620,1623 **** --- 1667,1672 ---- CreateScene(); + + tc3DModel::LoadUnknowns(); } |