33 m_aryMeshes.RemoveAll();
36 {
Std_TraceMsg(0,
"Caught Error in desctructor of VsMeshMgr\r\n",
"", -1,
false,
true);}
39 std::string VsMeshMgr::FileCreateTime(std::string strFilename)
42 WIN32_FILE_ATTRIBUTE_DATA wfad;
45 GetFileAttributesEx(strFilename.c_str(), GetFileExInfoStandard, &wfad);
46 FileTimeToSystemTime(&wfad.ftLastWriteTime, &st);
48 ss << st.wMonth <<
'/' << st.wDay <<
'/' << st.wYear <<
" " << st.wHour <<
":" << st.wMinute <<
":" << st.wSecond;
53 osg::Node *VsMeshMgr::LoadMesh(std::string strFilename)
55 std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair;
58 if(!FindMesh(strFilename, MeshPair,
false))
59 return AddMesh(strFilename);
62 std::string strCreateDate = FileCreateTime(strFilename);
66 if(strCreateDate == MeshPair.first)
67 return MeshPair.second.get();
70 ReleaseMesh(strFilename);
71 return AddMesh(strFilename);
76 osg::Node *VsMeshMgr::AddMesh(std::string strFilename)
78 osg::ref_ptr<osg::Node> lpTempMesh = osgDB::readNodeFile(strFilename.c_str());
82 std::string strFileCreateTime = FileCreateTime(strFilename);
83 std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair2(strFileCreateTime, lpTempMesh);
86 return lpTempMesh.get();
93 void VsMeshMgr::ReleaseMesh(std::string strFilename)
96 std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair;
97 if(!FindMesh(strFilename, MeshPair,
false))
return;
99 MeshPair.second.release();
104 bool VsMeshMgr::ContainesMesh(std::string strFilename)
106 std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair;
108 if(FindMesh(strFilename, MeshPair,
false))
125 bool VsMeshMgr::FindMesh(std::string strFilename, std::pair<std::string, osg::ref_ptr<osg::Node>> &MeshPair,
bool bThrowError)
127 CStdMap<std::string, std::pair<std::string, osg::ref_ptr<osg::Node>> >::iterator oPos;
130 if(oPos != m_aryMeshes.end())
132 MeshPair = oPos->second;
136 THROW_TEXT_ERROR(Vs_Err_lMeshIDNotFound, Vs_Err_strMeshNotFound,
" Mesh Filename: " + strFilename);
VsMeshMgr()
Default constructor.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual ~VsMeshMgr()
Destructor.
Declares the vortex MeshMgr class.