Thread: [Gcblue-commits] gcb_wx/src/sim tc3DViewer.cpp,1.24,1.25 tcGameObject.cpp,1.8,1.9 tcGoalTracker.cpp,
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-01-10 21:55:34
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1:/tmp/cvs-serv22071/src/sim Modified Files: tc3DViewer.cpp tcGameObject.cpp tcGoalTracker.cpp tcSimState.cpp Log Message: Added better 3D model class for animation support Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tc3DViewer.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tc3DViewer.cpp 3 Jan 2004 00:45:13 -0000 1.24 --- tc3DViewer.cpp 10 Jan 2004 21:55:31 -0000 1.25 *************** *** 56,59 **** --- 56,60 ---- #include "tc3DSky.h" #include "cspSky.h" + #include "tc3DModel.h" *************** *** 481,484 **** --- 482,486 ---- void tc3DViewer::LoadModel(tcGameObject *obj) { + #if 0 if (obj->model.valid()) return; // model already loaded obj->model = new osg::Group; *************** *** 501,504 **** --- 503,507 ---- fprintf(stderr,"Error loading 3D model: %s\n", model_name.c_str()); } + #endif } *************** *** 567,586 **** { tcGameObject *childObj = gameObj->children.at(n); ! if (!childObj->model.valid()) ! { ! LoadModel(childObj); ! } ! if (childObj->model->getNumParents() == 0) { if (useRelativeChildPos) { ! wxASSERT(gameObj->model->getNumChildren() == 1); ! osg::Transform *parentxform = gameObj->model.get()->getChild(0)->asTransform(); ! wxASSERT(parentxform); ! if (parentxform) parentxform->addChild(childObj->model.get()); } else { ! worldObjects->addChild(childObj->model.get()); } } --- 570,583 ---- { tcGameObject *childObj = gameObj->children.at(n); ! if (childObj->model->GetNumParents() == 0) { if (useRelativeChildPos) { ! // should be done as part of the GameObject::AddChild? ! gameObj->model->AddChild(childObj->model); } else { ! worldObjects->addChild(childObj->model->GetNode().get()); } } *************** *** 603,613 **** tcGameObject *gameObj; simState->maPlatformState.GetNextAssoc(poolpos,nKey,gameObj); ! if (!gameObj->model.valid()) ! { ! LoadModel(gameObj); ! } ! if (gameObj->model->getNumParents()==0) { ! worldObjects->addChild(gameObj->model.get()); } UpdateChildModels(gameObj); --- 600,607 ---- tcGameObject *gameObj; simState->maPlatformState.GetNextAssoc(poolpos,nKey,gameObj); ! wxASSERT(gameObj->model); // model should be created with gameObj ! if (gameObj->model->GetNumParents()==0) { ! worldObjects->addChild(gameObj->model->GetNode().get()); } UpdateChildModels(gameObj); *************** *** 849,853 **** { // set camera position to ! const osg::BoundingSphere& bs = obj->model->getBound(); cameraRange = 4*bs.radius(); if (cameraRange < 12.0f) cameraRange = 12.0f; --- 843,847 ---- { // set camera position to ! const osg::BoundingSphere& bs = obj->model->GetNode()->getBound(); cameraRange = 4*bs.radius(); if (cameraRange < 12.0f) cameraRange = 12.0f; *************** *** 912,916 **** HWND hwnd = (HWND)parent->GetHandle(); // returns handle to this window ! render_surface = new tcRenderSurface(hwnd); render_surface.get()->ref(); // prevents heap exception in debug mode, memory is modified after delete camera->setRenderSurface(render_surface.get()); --- 906,910 ---- HWND hwnd = (HWND)parent->GetHandle(); // returns handle to this window ! render_surface = new tcRenderSurface(hwnd); // leaks memory! render_surface.get()->ref(); // prevents heap exception in debug mode, memory is modified after delete camera->setRenderSurface(render_surface.get()); Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcGameObject.cpp 8 Dec 2003 03:06:36 -0000 1.8 --- tcGameObject.cpp 10 Jan 2004 21:55:31 -0000 1.9 *************** *** 27,30 **** --- 27,31 ---- #include "tcGameObject.h" #include "tcDatabase.h" + #include "tc3DModel.h" tcMapData* tcGameObject::mapData = NULL; *************** *** 126,129 **** --- 127,131 ---- mfDamageLevel = 0; mpDBObject = NULL; + model = NULL; } *************** *** 291,295 **** mnID = o.mnID; mnModelType = MTYPE_OBJECT; ! model = o.model; mpDBObject = o.mpDBObject; mzClass = o.mzClass; --- 293,297 ---- mnID = o.mnID; mnModelType = MTYPE_OBJECT; ! model = new tc3DModel(o.model); // straight copy is wrong, don't know if this is right mpDBObject = o.mpDBObject; mzClass = o.mzClass; *************** *** 315,318 **** --- 317,322 ---- mpDBObject = obj; mnID = NULL_INDEX; // remains NULL index for child + model = obj->Get3DModel(); + model->SetupUpdate(this); } *************** *** 323,325 **** --- 327,330 ---- { ClearChildren(); + if (model) delete model; } Index: tcGoalTracker.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGoalTracker.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcGoalTracker.cpp 20 Nov 2003 23:41:45 -0000 1.2 --- tcGoalTracker.cpp 10 Jan 2004 21:55:31 -0000 1.3 *************** *** 44,48 **** { delete allianceGoals[i]; ! allianceGoals[i] = new tcGoal(); // set default goal (always unresolved) } } --- 44,48 ---- { delete allianceGoals[i]; ! allianceGoals[i] = new tcGoal(); // set default goal (always unresolved) (leaks memory) } } Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcSimState.cpp 5 Jan 2004 02:48:03 -0000 1.22 --- tcSimState.cpp 10 Jan 2004 21:55:31 -0000 1.23 *************** *** 37,40 **** --- 37,41 ---- #include "tcAeroAirObject.h" #include "tcAirDBObject.h" + #include "tc3DModel.h" *************** *** 554,562 **** mpCommandInterface->DisplayInfoMessage(s.GetBuffer()); } ! if (int nParents = pobj->model->getNumParents()) { // remove child model from parent to delete from scenegraph wxASSERT(nParents==1); ! pobj->model->getParent(0)->removeChild(pobj->model.get()); } maPlatformState.RemoveKey(nKey); --- 555,563 ---- mpCommandInterface->DisplayInfoMessage(s.GetBuffer()); } ! if (int nParents = pobj->model->GetNumParents()) { // remove child model from parent to delete from scenegraph wxASSERT(nParents==1); ! pobj->model->DetachFromParent(); } maPlatformState.RemoveKey(nKey); *************** *** 976,983 **** child->parent = NULL; // remove model from parent to allow model to be repositioned in scene graph ! if (int parentCount = child->model->getNumParents()) { wxASSERT(parentCount == 1); ! child->model->getParent(0)->removeChild(child->model.get()); } AddPlatform(child); --- 977,984 ---- child->parent = NULL; // remove model from parent to allow model to be repositioned in scene graph ! if (int parentCount = child->model->GetNumParents()) { wxASSERT(parentCount == 1); ! child->model->DetachFromParent(); } AddPlatform(child); *************** *** 1227,1231 **** /********************************************************************/ void tcSimState::RandInit() { ! int nPlatforms = 20; // number of platforms to add Clear(); --- 1228,1232 ---- /********************************************************************/ void tcSimState::RandInit() { ! int nPlatforms = 12; // number of platforms to add Clear(); *************** *** 1367,1372 **** { // remove child model from parent to allow repositioning in scenegraph ! wxASSERT(landing_unit->model->getNumParents()==1); ! landing_unit->model->getParent(0)->removeChild(landing_unit->model.get()); // remove from platformstate container maPlatformState.RemoveKeyWithoutDelete(key); --- 1368,1373 ---- { // remove child model from parent to allow repositioning in scenegraph ! wxASSERT(landing_unit->model->GetNumParents()==1); ! landing_unit->model->DetachFromParent(); // remove from platformstate container maPlatformState.RemoveKeyWithoutDelete(key); |