[Gcblue-commits] gcb_wx/src/graphics ObjectUpdater.cpp,1.18,1.19 tc3DModel.cpp,1.26,1.27 tc3DViewer.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-07-14 23:42:37
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15641/src/graphics Modified Files: ObjectUpdater.cpp tc3DModel.cpp tc3DViewer.cpp tcContainerGui.cpp tcHookInfo.cpp tcOOBView.cpp tcPlatformGui.cpp tcPopupControl.cpp tcStoresGui.cpp Log Message: Fixed shaking object bug Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tc3DModel.cpp 1 Jun 2005 00:13:30 -0000 1.26 --- tc3DModel.cpp 14 Jul 2005 23:42:22 -0000 1.27 *************** *** 68,71 **** --- 68,92 ---- std::vector<tcAnimationInfo>& animationInfo; // vector of animation state info to update + /** + * @return pivot parent group if this node has a pivot, otherwise return 0, set immediate child (pivotRotate) and childIdx + */ + osg::Group* GetPivotParent(osg::Group* node, osg::Group*& pivotRotate, unsigned int& childIdx) + { + pivotRotate = 0; + childIdx = 0; + + osg::Transform* pivotTranslate = node->asTransform(); + if (pivotTranslate == 0) return 0; + + pivotRotate = pivotTranslate->getParent(0); + if (pivotRotate == 0) return 0; + + osg::Group* parent = pivotRotate->getParent(0); + if (parent == 0) return 0; + + childIdx = parent->getChildIndex(pivotRotate); + return parent; + } + public: AnimationProcessor(std::vector<tcAnimationInfo>& ai) *************** *** 107,129 **** if (node.getNumParents() == 1) { ! osg::BoundingSphere bs = node.getBound(); ! osg::Matrix untransMatrix; ! osg::Matrix transMatrix; ! untransMatrix.setTrans(-bs.center()); ! transMatrix.setTrans(bs.center()); ! osg::MatrixTransform *untranslateTransform = new osg::MatrixTransform(untransMatrix); ! osg::MatrixTransform *translateTransform = new osg::MatrixTransform(transMatrix); osg::MatrixTransform *rotateTransform = new osg::MatrixTransform; // temporarily hold node to avoid delete when removing from parent osg::ref_ptr<osg::Node> temp = &node; ! osg::Group *parent = node.getParent(0); ! unsigned childIdx = parent->getChildIndex(&node); ! parent->setChild(childIdx, translateTransform); // replace child with transform ! untranslateTransform->addChild(&node); ! rotateTransform->addChild(untranslateTransform); ! translateTransform->addChild(rotateTransform); info->switchVariable = NULL; --- 128,174 ---- if (node.getNumParents() == 1) { ! osg::MatrixTransform *rotateTransform = new osg::MatrixTransform; + rotateTransform->setDataVariance(osg::Object::DYNAMIC); // temporarily hold node to avoid delete when removing from parent osg::ref_ptr<osg::Node> temp = &node; ! osg::Group *parent = node.getParent(0); ! unsigned childIdx; ! osg::Group* pivotRotate; ! if (osg::Group* pivotParent = GetPivotParent(parent, pivotRotate, childIdx)) // check if this is a pivot ! { ! osg::ref_ptr<osg::Group> temp = pivotRotate; ! pivotParent->setChild(childIdx, rotateTransform); ! rotateTransform->addChild(pivotRotate); ! ! if (tcOptions::Get()->OptionStringExists("Log3DModelDetails")) ! { ! fprintf(stdout, "added animation info (with pivot) for: %s\n", name.c_str()); ! } ! } ! else ! { ! childIdx = parent->getChildIndex(&node); ! osg::BoundingSphere bs = node.getBound(); ! osg::Matrix untransMatrix; ! osg::Matrix transMatrix; ! untransMatrix.setTrans(-bs.center()); ! transMatrix.setTrans(bs.center()); ! osg::MatrixTransform *untranslateTransform = new osg::MatrixTransform(untransMatrix); ! osg::MatrixTransform *translateTransform = new osg::MatrixTransform(transMatrix); + parent->setChild(childIdx, translateTransform); // replace child with transform + + untranslateTransform->addChild(&node); + rotateTransform->addChild(untranslateTransform); + translateTransform->addChild(rotateTransform); + + if (tcOptions::Get()->OptionStringExists("Log3DModelDetails")) + { + fprintf(stdout, "added animation info for: %s\n", name.c_str()); + } + } info->switchVariable = NULL; *************** *** 131,138 **** info->bound = true; ! if (tcOptions::Get()->OptionStringExists("Log3DModelDetails")) ! { ! std::cout << "added animation info for: " << name <<"\n"; ! } } else --- 176,181 ---- info->bound = true; ! ! } else Index: tcOOBView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcOOBView.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcOOBView.cpp 28 Jun 2005 02:51:34 -0000 1.9 --- tcOOBView.cpp 14 Jul 2005 23:42:22 -0000 1.10 *************** *** 391,396 **** void tcOOBView::Draw() { ! static int nFrameCount = 0; ! //if ((nFrameCount++ % 4)!=0) {return 1;} // draw every fourth call --- 391,396 ---- void tcOOBView::Draw() { ! static int frameCount = 0; ! if ((frameCount++ % 5) !=0 ) return; Index: tcHookInfo.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcHookInfo.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcHookInfo.cpp 25 Jun 2005 22:10:35 -0000 1.12 --- tcHookInfo.cpp 14 Jul 2005 23:42:22 -0000 1.13 *************** *** 56,61 **** void tcHookInfo::DrawTrack(tnPoolIndex anID) { - - tcSensorMapTrack *pSMTrack; std::string s; char zBuff[128]; --- 56,59 ---- *************** *** 65,69 **** osg::Vec4 color; ! if (!(pSMTrack = mpSS->mcSensorMap.GetSensorMapTrack(anID, nOwnAlliance))) {return;} const tcTrack *pTrack = pSMTrack->GetTrack(); --- 63,68 ---- osg::Vec4 color; ! tcSensorMapTrack* pSMTrack = mpSS->mcSensorMap.GetSensorMapTrack(anID, nOwnAlliance); ! if (pSMTrack == 0) return; const tcTrack *pTrack = pSMTrack->GetTrack(); *************** *** 466,470 **** wxASSERT(mpSS); ! if ((nFrameCount++ % 8) != 0) return; // use to skip draw updates --- 465,469 ---- wxASSERT(mpSS); ! if ((nFrameCount++ % 4) != 0) return; // use to skip draw updates Index: tcStoresGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcStoresGui.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcStoresGui.cpp 22 Jun 2005 01:22:08 -0000 1.3 --- tcStoresGui.cpp 14 Jul 2005 23:42:23 -0000 1.4 *************** *** 225,230 **** if (stores == 0) return; ! tcStoresDBObject* databaseObj = stores->GetDatabaseObject(); ! wxASSERT(databaseObj); size_t nSlots = 16; // use magic number for now --- 225,230 ---- if (stores == 0) return; ! tcStoresDBObject* storesData = stores->GetDatabaseObject(); ! wxASSERT(storesData); size_t nSlots = 16; // use magic number for now Index: tcPopupControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcPopupControl.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcPopupControl.cpp 1 Jun 2005 00:13:31 -0000 1.9 --- tcPopupControl.cpp 14 Jul 2005 23:42:22 -0000 1.10 *************** *** 49,59 **** Thaw(); - /* - mpBrush->SetColor(Color(0,0,0,0)); - pGraphics->SetCompositingMode(CompositingModeSourceCopy); - pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); - pGraphics->SetCompositingMode(CompositingModeSourceOver); - */ - if (mpPanel != NULL) { --- 49,52 ---- Index: tcPlatformGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcPlatformGui.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcPlatformGui.cpp 28 Jun 2005 02:51:34 -0000 1.4 --- tcPlatformGui.cpp 14 Jul 2005 23:42:22 -0000 1.5 *************** *** 123,127 **** tcContainerSlot& slot = slots[n]; tcContainerItem* item = slot.GetItem(); ! tcLauncherContainerItem* launcherItem = dynamic_cast<tcLauncherContainerItem*>(item); bool isMouseOver = slot.IsMouseOver(); --- 123,127 ---- tcContainerSlot& slot = slots[n]; tcContainerItem* item = slot.GetItem(); ! bool isMouseOver = slot.IsMouseOver(); Index: ObjectUpdater.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/ObjectUpdater.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ObjectUpdater.cpp 1 Jun 2005 00:13:30 -0000 1.18 --- ObjectUpdater.cpp 14 Jul 2005 23:42:22 -0000 1.19 *************** *** 81,86 **** { osg::MatrixTransform *xform = info.transform; ! osg::Matrix matrix = xform->getMatrix(); ! double angle = info.omega * viewer->GetGameTime(); // scale rotation rate by platform speed for propeller animation type --- 81,87 ---- { osg::MatrixTransform *xform = info.transform; ! //osg::Matrix matrix = xform->getMatrix(); ! double dt = viewer->GetGameTimeStep(); ! double theta = info.omega * dt; // change in angle // scale rotation rate by platform speed for propeller animation type *************** *** 92,100 **** if (gameObject->mcKin.mfSpeed_kts < 50.0f) { ! angle *= gameObject->mcKin.mfSpeed_kts; } } ! xform->setMatrix(matrix.rotate(angle , info.axis)); } } --- 93,103 ---- if (gameObject->mcKin.mfSpeed_kts < 50.0f) { ! theta *= gameObject->mcKin.mfSpeed_kts; } } + ! xform->preMult(osg::Matrix::rotate(theta , info.axis)); ! //xform->setMatrix(matrix.rotate(angle , info.axis)); } } Index: tcContainerGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcContainerGui.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcContainerGui.cpp 12 Jun 2005 20:46:58 -0000 1.2 --- tcContainerGui.cpp 14 Jul 2005 23:42:22 -0000 1.3 *************** *** 307,311 **** // clear mouseover state since OnMouseMove sometimes not called before leaving window size_t nSlots = slots.size(); ! bool foundSlot = false; for (size_t n=0; n<nSlots; n++) { --- 307,311 ---- // clear mouseover state since OnMouseMove sometimes not called before leaving window size_t nSlots = slots.size(); ! for (size_t n=0; n<nSlots; n++) { Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tc3DViewer.cpp 9 Jul 2005 14:43:40 -0000 1.21 --- tc3DViewer.cpp 14 Jul 2005 23:42:22 -0000 1.22 *************** *** 940,943 **** --- 940,945 ---- Swap(); } + + lastGameTime = gameTime; } *************** *** 1027,1030 **** --- 1029,1033 ---- const unsigned int limitMask = (~PTYPE_FIXED) & 0xFFF0; + if ((objClassification & limitMask) != 0) { *************** *** 1042,1045 **** --- 1045,1050 ---- if (cameraPosition._v[2] < min_z) cameraPosition._v[2] = min_z; } + + // workaround for sky issue, deactivate sky when camera underwater if (cameraPosition._v[2] < -1.0) *************** *** 1062,1065 **** --- 1067,1071 ---- bool shakeEligible = ((objClassification & (PTYPE_AIR | PTYPE_MISSILE)) != 0) && (cameraRange < 25.0f); + if (shakeAirCamera && shakeEligible) { *************** *** 1229,1233 **** { classification = 0; - fprintf(stderr, "tc3DViewer::GetHookedObjectPositionAndType - graphics error\n"); return lastPos; } --- 1235,1238 ---- *************** *** 1239,1242 **** --- 1244,1249 ---- y = LatToY(obj->mcKin.mfLat_rad); z = obj->mcKin.mfAlt_m; + + classification = obj->mpDBObject->mnType; } else *************** *** 1249,1252 **** --- 1256,1261 ---- y = LatToY(obj->mcKin.mfLat_rad); z = obj->mcKin.mfAlt_m; + + classification = obj->mpDBObject->mnType; } else if (tcSensorMapTrack* track = *************** *** 1258,1261 **** --- 1267,1272 ---- y = LatToY(predicted.mfLat_rad); z = predicted.GetOrGuessAltitude(); + + classification = predicted.mnClassification; } else *************** *** 1264,1267 **** --- 1275,1280 ---- y = lastPos._v[1]; z = lastPos._v[2]; + + classification = 0; fprintf(stderr, "tc3DViewer::GetHookedObjectPositionAndType - graphics error\n"); } *************** *** 1304,1308 **** guiView->setDisplaySettings(displaySettings.get()); guiView->setDefaults(); ! guiView->getState()->setContextID(1); wxWindow* parent = wxWindow::GetParent(); --- 1317,1321 ---- guiView->setDisplaySettings(displaySettings.get()); guiView->setDefaults(); ! //guiView->getState()->setContextID(1); wxWindow* parent = wxWindow::GetParent(); *************** *** 1361,1365 **** sceneView->setDisplaySettings(displaySettings.get()); sceneView->setDefaults(); ! sceneView->getState()->setContextID(0); wxWindow *parent = wxWindow::GetParent(); --- 1374,1378 ---- sceneView->setDisplaySettings(displaySettings.get()); sceneView->setDefaults(); ! //sceneView->getState()->setContextID(0); wxWindow *parent = wxWindow::GetParent(); *************** *** 1431,1435 **** sceneViewFar->setDisplaySettings(displaySettings.get()); sceneViewFar->setDefaults(); ! sceneViewFar->getState()->setContextID(2); wxWindow *parent = wxWindow::GetParent(); --- 1444,1448 ---- sceneViewFar->setDisplaySettings(displaySettings.get()); sceneViewFar->setDefaults(); ! //sceneViewFar->getState()->setContextID(2); wxWindow *parent = wxWindow::GetParent(); *************** *** 1791,1795 **** { static long lastHook = -1; ! if (!simState) return; if (lastHook != hookID) --- 1804,1808 ---- { static long lastHook = -1; ! if (lastHook != hookID) *************** *** 1838,1843 **** updateVisitorFar->setTraversalNumber(frameStampFar->getFrameNumber()); - - } --- 1851,1854 ---- *************** *** 1902,1905 **** --- 1913,1917 ---- cameraLookEl = 0; gameTime = 0; + lastGameTime = 0; simState = NULL; |