void BlMeshBase::LoadMeshNode() { std::string strPath = m_lpThisAB->GetSimulator()->ProjectPath(); std::string strMeshFile; if(m_lpThisRB->IsCollisionObject() && m_lpThisMesh->CollisionMeshType() == "CONVEX") strMeshFile = m_lpThisMesh->ConvexMeshFile(); else strMeshFile = m_lpThisMesh->MeshFile(); std::string strFile = AnimatSim::GetFilePath(strPath, strMeshFile); m_osgBaseMeshNode = GetBlSimulator()->MeshMgr()->LoadMesh(strFile); if(!m_osgBaseMeshNode.valid()) CreateDefaultMesh(); m_osgBaseMeshNode->setName(m_lpThisAB->Name() + "_MeshNodeBase"); //Enforce turning on of lighting for this object. Some meshes have this turned off by default (3DS in particular) //This did not fix the problem. //m_osgBaseMeshNode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON ); CStdFPoint vScale(1, 1, 1); //If this is a convex collision object then it does not get scaled here. That is done //when it is converted into a collision mesh by the editor. Otherwise use the scaling. if( !(m_lpThisMesh->IsCollisionObject() && m_lpThisMesh->CollisionMeshType() == "CONVEX") ) vScale= m_lpThisMesh->Scale(); osg::Matrix osgScaleMatrix = osg::Matrix::identity(); osgScaleMatrix.makeScale(vScale.x, vScale.y, vScale.z); m_osgMeshNode = new osg::MatrixTransform(osgScaleMatrix); m_osgMeshNode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); m_osgMeshNode->addChild(m_osgBaseMeshNode.get()); m_osgMeshNode->setName(m_lpThisAB->Name() + "_MeshNode"); }
MeshManager::MeshManager() { CreateDefaultMesh(); }