每天花30分钟看OGRE--(12)Ogre的模型.mesh里面包含了什么信息(也就是说结构是怎样的呢)?

11.Ogre的模型.mesh里面包含了什么信息(也就是说结构是怎样的呢)?

A:

OgreMeshSerializer.cpp

MeshSerializer::importMesh

// Find the implementation to use

MeshSerializerImplMap::iterator impl = mImplementations.find(ver);

if (impl == mImplementations.end())

{

OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Cannot find serializer implementation for "

"current version " + ver, "MeshSerializer::importMesh");

}

对不同版本mesh的兼容很有意思,读出此.mesh文件的版本,然后找一个对应的Serializer去加载。

clip_image002

clip_image004

找到了,OgreMeshFileFormat.h就是。

/** Definition of the OGRE .mesh file format

.mesh files are binary files (for read efficiency at runtime) and are arranged into chunks

of data, very like 3D Studio's format.

A chunk always consists of:

unsigned short CHUNK_ID : one of the following chunk ids identifying the chunk

unsigned long LENGTH : length of the chunk in bytes, including this header

void* DATA : the data, which may contain other sub-chunks (various data types)

A .mesh file can contain both the definition of the Mesh itself, and optionally the definitions

of the materials is uses (although these can be omitted, if so the Mesh assumes that at runtime the

Materials referred to by name in the Mesh are loaded/created from another source)

A .mesh file only contains a single mesh, which can itself have multiple submeshes.

*/

.mesh文件是二进制的(运行期读起来快啊!),以数据块的形式组织,很像3D Studio的格式。

一个数据块由3部门组成:

CHUNK_ID

LENGTH 单位是字节

DATA

一个.mesh文件包含Mesh本身的定义,也可以包含它用的materials(不包含的话就是运行期从另一个资源加载或者创建)。

一个.mesh文件只包含一个mesh,可以包含多个submesh。

具体请看此文件。大体上就是顶点信息(M_GEOMETRY),动画信息,骨骼信息,LOD (M_MESH_LOD)等。

clip_image006

MeshUpgrader 模型升级工具

MaterialUpgrader 材质升级工具

MeshSerializer ? 估计这个就是导出插件干的事了

Q: Ogre的导出插件都有哪些?最好用的一个是哪个?

A:

OGRE Exporters

http://www.ogre3d.org/wiki/index.php/OGRE_Exporters

OgreMax Scene Exporter

clip_image008

安装上了,3ds max 2010.多了OgreMax菜单。

导出后查看

clip_image010

有源码没?

貌似是要购买才行啊!

导出插件(非商业版)没看到源码!

clip_image012

Viewer倒是有!

clip_image014

http://www.ogremax.com/Documents/OgreMaxWinViewer/source-code.html#usingInYourOwnProject

Using OgreMax Scene Files in Your Own Project

  • If you haven't already done so, you will need to have TinyXML library somewhere, either on your system or directly in your project's source code directory. In either case, be sure you have compiled with the TIXML_USE_STL preprocessor definition, both when building TinyXML (if you use it as a separate library) and when using it in your project. Failing to do this will likely result in your program crashing. For Visual Studio, you can find the preprocessor definitions in the project properties dialog underC/C++->Preprocessor->Preprocessor Definitions.
  • Copy the OgreMaxPlatform, OgreMaxScene, OgreMaxModel, OgreMaxRenderWindowIterator, OgreMaxTypes, OgreMaxUtilites, ProgressCalculator, and Version .cpp/.hpp files from the Common/Code directory and paste them into your own project's code directory.
  • In your application, create an instance of the OgreMaxScene class and call Load(). This instance should exist for as long as you wish to view the loaded scene. When you are destroying your scene, before deleting the scene manager, be sure to call OgreMaxScene::Destroy() (if you have a static instance) or delete the OgreMaxScene object (if you have a dynamic instance) so that the internal objects are deleted in the correct order.
  • To obtain the "extra" data stored in objects call the OgreMaxScene::GetObjectExtraData() method, passing in the object. A pointer to the extra data is returned. The pointer does not need to be deleted. It will, however, be deleted if the OgreMaxScene that loaded it is deleted.
  • When there is a terrain in a scene, there must be a camera and viewport present in order for it to be loaded without errors. This can be achieved with implementing theCreatedSceneManager() callback, as is done in the viewer, and creating the necessary objects before the remainder of the scene is loaded.

Building and Running the Viewer From Source Code

  • Visual Studio 2005 or 2008 must be installed. Other versions of Visual Studio, such as Visual C++ Express, are untested.
  • The Ogre 3D header files and static libraries (along with Ogre 3D's static dependencies) must be available. Ogre 1.6.2 and 1.7.0 are the latest tested versions. Static library support can be disabled by defining removing OGRE_STATIC_LIB from the project preprocessor definitions. Also, the zlib.lib, zziplib.lib, freetype235.lib, FreeImage.lib, LibJPEG.lib, LibMNG.lib, LibPNG.lib, LibTIFF.lib, Plugin_CgProgramManagerStatic.lib, RenderSystem_Direct3D9Static.lib, RenderSystem_GLStatic.lib, Plugin_ParticleFXStatic.lib, Plugin_OctreeSceneManagerStatic.lib and OgreMainStatic.lib references in the linker settings must be removed, and OgreMain.lib added.
  • The Lua header files and libraries must be available. Lua support can be disabled by defining OGREMAX_VIEWER_NO_LUA in the project preprocessor definitions and removing the liblua.lib and libluabind.lib references in the linker settings. The precompiled viewer uses Lua 5.1.1.
  • The Luabind header files and libraries must be available. Note that Luabind depends on Boost. Lua support can be disabled by defining OGREMAX_VIEWER_NO_LUAin the project preprocessor definitions and removing the liblua.lib and libluabind.lib references in the linker settings. The precompiled viewer uses Luabind 0.7 and Boost 1.33.1.
  • The header files and library for this modified Object-Oriented Input System (OIS) must be used. The latest official public release, will also work, though the gamepad mappings will not be correct if a 360 gamepad is used.
  • The wxWidgets header files and libraries must be available. The precompiled viewer uses wxWidgets 2.8.7.
  • The wxPropertyGrid must be available. The precompiled viewer uses wxPropertyGrid 1.2.11.
  • The OgreMaxWinViewer.sln project file may be loaded in Visual Studio and built.
  • Run the output OgreMaxWinViewer.exe file.
  • If creating a non-static build, the appropriate Ogre 3D DLLs must be present on your system in order for the viewer to be successfully run. Modify theOgreMaxWinViewerPlugins.cfg file to reference the appropriate plugins on your system.

OgreXmlConverter可以把mesh与xml互转!

clip_image016

clip_image018

也可以把.skeleton转为.xml文件。

clip_image020

clip_image022

posted @ 2010-01-21 11:06  CG迷途大熊猫  阅读(8689)  评论(3编辑  收藏  举报