반응형
리소스 경로는 resource.cfg 파일에 정의되어 있어야 한다.
임의의 경로에 있는 mesh를 읽어들이는 코드는 다음과 같다.
// "source" should contain the pathname to your mesh file
Ogre::String source;
/*
An alternate (better) way of doing the following would be to
use the FileStreamDataStream class, which avoids having to use
the more esoteric "stat" struct and stdio APIs. For more, see
http://www.ogre3d.org/docs/api/html/classOgre_1_1FileStreamDataStream.html
This prevents having to create and fill a MemoryDataStream instance, as
the FileStreamDataStream can be used directly in the "stream" c'tor below.
*/
FILE* pFile = fopen( source.c_str(), "rb" );
if (!pFile)
OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND,"File " + source + " not found.", "OgreMeshLoaded");
struct stat tagStat;
stat( source.c_str(), &tagStat );
MemoryDataStream* memstream = new MemoryDataStream(source, tagStat.st_size, true);
fread( (void*)memstream->getPtr(), tagStat.st_size, 1, pFile );
fclose( pFile );
// give the resource a name -- it can be the full pathname if you like, since it's
// just going to be the key in an STL associative tree container
MeshPtr pMesh = MeshManager::getSingleton().createManual("LocalMesh",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// this part does the actual load into the live Mesh object created above
MeshSerializer meshSerializer;
DataStreamPtr stream(memstream);
meshSerializer.importMesh(stream, pMesh.getPointer());
// and finally, now that we have a named Mesh resource, we can use it
// in our createEntity() call...
Entity* pF35_1 = m_pSceneMgr->createEntity("LocalMesh_Ent", "LocalMesh");
반응형
'Programming' 카테고리의 다른 글
[C#] 현재 실행되는 실행 파일의 경로 얻기 (0) | 2021.03.12 |
---|---|
[OGRE] ManualObject to Mesh (0) | 2021.03.12 |
[C#] 속도 측정용 간단 코드 (0) | 2021.03.12 |
[MFC,OGRE] MFC에서 OGRE 사용하기 (0) | 2021.03.12 |
[OGRE] 매뉴얼 객체로 좌표축 만들기 (0) | 2021.03.12 |