[Gcblue-commits] gcb_wx/src/graphics ObjectUpdater.cpp, 1.23, 1.24 tc3DModel.cpp, 1.40, 1.41 tcMapV
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-12-20 00:45:48
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv25403/src/graphics Modified Files: ObjectUpdater.cpp tc3DModel.cpp tcMapView.cpp Log Message: Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** tcMapView.cpp 13 Dec 2006 02:10:58 -0000 1.54 --- tcMapView.cpp 20 Dec 2006 00:45:46 -0000 1.55 *************** *** 2684,2689 **** void tcTacticalMapView::OnLButtonDClick(wxMouseEvent& event) { - if (hookedId.size() != 1) return; - wxPoint pos = event.GetPosition(); --- 2684,2687 ---- Index: ObjectUpdater.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/ObjectUpdater.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ObjectUpdater.cpp 23 Mar 2006 01:11:02 -0000 1.23 --- ObjectUpdater.cpp 20 Dec 2006 00:45:46 -0000 1.24 *************** *** 199,202 **** --- 199,203 ---- } + // TODO make this more efficient osg::Matrix m = osg::Matrix::rotate(osg::inRadians(roll),0.0f,1.0f,0.0f)* Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** tc3DModel.cpp 20 Nov 2006 00:17:42 -0000 1.40 --- tc3DModel.cpp 20 Dec 2006 00:45:46 -0000 1.41 *************** *** 615,640 **** { if (modelNode.valid()) return; // model already loaded const bool log3Ddetails = tcOptions::Get()->OptionStringExists("Log3DModelDetails"); ! if (log3Ddetails) ! { ! std::cout << "Loading 3D model: " << model_name << " \n"; ! } ! ! modelNode = osgDB::readNodeFile(model_name.c_str()); ! if (!modelNode.valid()) { ! std::cout << "Load of 3D model: " << model_name << " failed.\n"; ! std::cerr << "Load of 3D model: " << model_name << " failed.\n"; ! modelNode = unknownAll.get(); // use unknown model as default } ! if (useSmoothing) ! { ! osgUtil::SmoothingVisitor smoothingVisitor; ! modelNode->accept(smoothingVisitor); ! } if (log3Ddetails) --- 615,632 ---- { if (modelNode.valid()) return; // model already loaded + modelNode = new osg::Group(); const bool log3Ddetails = tcOptions::Get()->OptionStringExists("Log3DModelDetails"); ! osg::Node* mainNode = osgDB::readNodeFile(model_name.c_str()); ! if (mainNode == 0) { ! fprintf(stdout, "Load of 3D model: %s failed.\n", model_name.c_str()); ! fprintf(stderr, "Load of 3D model: %s failed.\n", model_name.c_str()); ! mainNode = unknownAll.get(); // use unknown model as default } ! modelNode->addChild(mainNode); if (log3Ddetails) *************** *** 668,672 **** delete doc; fprintf(stderr, "Error loading XML file %s\n", file_name.c_str()); ! modelNode = unknownAll.get(); // use unknown model as default return; } --- 660,665 ---- delete doc; fprintf(stderr, "Error loading XML file %s\n", file_name.c_str()); ! if (!modelNode.valid()) modelNode = new osg::Group; ! modelNode->addChild(unknownAll.get()); // use unknown model as default return; } *************** *** 674,683 **** TiXmlNode* node = doc->FirstChild("Model"); - if (!node) { delete doc; fprintf(stderr, "Model entry missing in XML file %s\n", file_name.c_str()); ! modelNode = unknownAll.get(); // use unknown model as default return; } --- 667,676 ---- TiXmlNode* node = doc->FirstChild("Model"); if (!node) { delete doc; fprintf(stderr, "Model entry missing in XML file %s\n", file_name.c_str()); ! if (!modelNode.valid()) modelNode = new osg::Group; ! modelNode->addChild(unknownAll.get()); // use unknown model as default return; } *************** *** 690,693 **** --- 683,694 ---- Load(modelFileName); + LoadXmlSubmodels(doc); + + if (useSmoothing) + { + osgUtil::SmoothingVisitor smoothingVisitor; + modelNode->accept(smoothingVisitor); + } + LoadXmlAnimationInfo(doc); *************** *** 844,847 **** --- 845,912 ---- } + + void tc3DModel::LoadXmlSubmodels(TiXmlDocument* doc) + { + if (!modelNode.valid()) + { + wxASSERT(false); + return; + } + + const bool log3Ddetails = tcOptions::Get()->OptionStringExists("Log3DModelDetails"); + + TiXmlNode* current = doc->FirstChild("Submodel"); + while (current) + { + if (TiXmlElement* elt = current->ToElement()) + { + std::string model_name; + double x = 0; + double y = 0; + double z = 0; + double yaw = 0; + double pitch = 0; + double roll = 0; + + model_name = elt->Attribute("File"); + elt->Attribute("X", &x); + elt->Attribute("Y", &y); + elt->Attribute("Z", &z); + elt->Attribute("Yaw", &yaw); + elt->Attribute("Pitch", &pitch); + elt->Attribute("Roll", &roll); + + osg::Matrix m = + osg::Matrix::rotate(osg::inDegrees(roll),0.0f,1.0f,0.0f)* + osg::Matrix::rotate(osg::inDegrees(pitch),1.0f,0.0f,0.0f)* + osg::Matrix::rotate(-osg::inDegrees(yaw),0.0f,0.0f,1.0f)* + osg::Matrix::translate(x,y,z) + ; + + osg::MatrixTransform* transform = new osg::MatrixTransform(m); + transform->setDataVariance(osg::Object::STATIC); + + osg::Node* node = osgDB::readNodeFile(model_name.c_str()); + if (node == 0) + { + fprintf(stdout, "Load of 3D model: %s failed.\n", model_name.c_str()); + fprintf(stderr, "Load of 3D model: %s failed.\n", model_name.c_str()); + } + + transform->addChild(node); + modelNode->addChild(transform); + + if (log3Ddetails) + { + fprintf(stdout, "tc3DModel--Loaded 3D submodel: %s\n", model_name.c_str()); + } + + } + + current = current->NextSibling("Submodel"); + } + } + + /** * *************** *** 1097,1101 **** engineSmokeSources = source->engineSmokeSources; ! modelNode = dynamic_cast<osg::Node*>(source->modelNode->clone(ModelCopyOp(this,true,0))); // add children with varying level of detail --- 1162,1166 ---- engineSmokeSources = source->engineSmokeSources; ! modelNode = dynamic_cast<osg::Group*>(source->modelNode->clone(ModelCopyOp(this,true,0))); // add children with varying level of detail |