天龙的地形实现技术 1
2009-02-17 00:57
267 查看
天龙的场景主文件为.Scene文件,其中定义了一个场景的灯光,天空,地面,以及所有的实体
偷了两张图片来说明文件格式:
;
scene文件的实际格式
terrain是由和Scene文件同名扩展名为.Terrain的文件定义的
地形的信息保存在heightmao中,实际上是一个193X193的raw格式的文件;前八位标识版本号,后八位中,前四位为宽,后四位为高;
FILE *pFile= fopen("F://OgreSDK//media//Scene//shaolin.Heightmap", "rb" );
if( pFile == NULL )
{
MessageBox(NULL, "加载天龙八部高度图文件%s失败, 文件不存在.","",MB_OK );
return ;
}
size_t uWidth, uHeight;
fseek( pFile, 8, SEEK_CUR );
fread( &uWidth, 1, sizeof(size_t), pFile );
fread( &uHeight, 1, sizeof(size_t), pFile );
size_t uSize=uWidth;
size_t i, uCount = uSize * uSize;
std::vectorheightMap(uCount);
for( i = 0; i < uCount; ++i )
{
float fValue = 0;
fread( &fValue, 1, sizeof(float), pFile );
heightMap[i]=fValue;
}
读取场景的实体时要注意一点,场景文件中记录的四元数是w在前的和平常的习惯不太一样。。。
Ogre::String str = value;
size_t pos = str.find_first_of(' ',0);
size_t pos2 = str.find_first_of(' ',pos+1);
size_t pos3 = str.find_first_of(' ',pos2+1);
quat.w = Ogre::StringConverter::parseReal(str.substr(0,pos));
quat.x = Ogre::StringConverter::parseReal(str.substr(pos+1,pos2));
quat.y = Ogre::StringConverter::parseReal(str.substr(pos2+1,pos3));
quat.z = Ogre::StringConverter::parseReal(str.substr(pos3+1,str.length()));
偷了两张图片来说明文件格式:
;
scene文件的实际格式
terrain是由和Scene文件同名扩展名为.Terrain的文件定义的
地形的信息保存在heightmao中,实际上是一个193X193的raw格式的文件;前八位标识版本号,后八位中,前四位为宽,后四位为高;
FILE *pFile= fopen("F://OgreSDK//media//Scene//shaolin.Heightmap", "rb" );
if( pFile == NULL )
{
MessageBox(NULL, "加载天龙八部高度图文件%s失败, 文件不存在.","",MB_OK );
return ;
}
size_t uWidth, uHeight;
fseek( pFile, 8, SEEK_CUR );
fread( &uWidth, 1, sizeof(size_t), pFile );
fread( &uHeight, 1, sizeof(size_t), pFile );
size_t uSize=uWidth;
size_t i, uCount = uSize * uSize;
std::vectorheightMap(uCount);
for( i = 0; i < uCount; ++i )
{
float fValue = 0;
fread( &fValue, 1, sizeof(float), pFile );
heightMap[i]=fValue;
}
读取场景的实体时要注意一点,场景文件中记录的四元数是w在前的和平常的习惯不太一样。。。
Ogre::String str = value;
size_t pos = str.find_first_of(' ',0);
size_t pos2 = str.find_first_of(' ',pos+1);
size_t pos3 = str.find_first_of(' ',pos2+1);
quat.w = Ogre::StringConverter::parseReal(str.substr(0,pos));
quat.x = Ogre::StringConverter::parseReal(str.substr(pos+1,pos2));
quat.y = Ogre::StringConverter::parseReal(str.substr(pos2+1,pos3));
quat.z = Ogre::StringConverter::parseReal(str.substr(pos3+1,str.length()));
相关文章推荐
- 天龙的地形实现技术
- 天龙的地形实现技术
- 天龙的地形实现技术
- 第一人称游戏技术 - 实现在高低不平的3D地形上行走效果
- (原创) 三维地形可视化快速实现技术方法研究 ——以江西庐山为例
- Ogre实现天龙地形
- 大数据Spark“蘑菇云”行动第53课: Spark大型项目广告点击项目技术骨架实现之Spark+Kafka+Flume实战 项目!!!大项目!!!超大型大数据项目!!!
- 微软软件实现技术授课系列内容之三:Project in C++ Coding Practice
- 黑魔法——“低版本中使用高版本中出现的类”之技术实现原理详解
- C++中接口与实现分离的技术
- 基于CPU实现的Shadow Map(阴影图)技术--(Cg语言实现)
- 软磁盘感应技术的实现
- 使用Cufon技术实现Web自定义字体2
- 基于DeepZoom技术的Bing Maps客户端实现研究
- DotNet语音技术实现(实现电脑发音)
- 微软软件实现技术授课系列内容之五:软件测试基础
- java中的缓存技术该如何实现
- 量化交易——传统技术分析布林通道BollingerBands的原理及实现
- [转]的C#实现三维数字地形漫游(基于Irrlicht)
- 企业门户应用整合中单点登录(SSO)的技术实现与应用