天龙的地形实现技术
2011-01-07 10:34
204 查看
天龙的地形实现技术 1 收藏
天龙的场景主文件为.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()));
相关文章推荐
- 天龙的地形实现技术 1
- 天龙的地形实现技术
- 天龙的地形实现技术
- 第一人称游戏技术 - 实现在高低不平的3D地形上行走效果
- Ogre实现天龙地形
- (原创) 三维地形可视化快速实现技术方法研究 ——以江西庐山为例
- 数据结构习作之应用 "栈(Stack)" 实现: 解析算术表达式及计算求值 (C#/Java) (技术含量少许)
- Android技术——视图切换(一)利用ActionBar实现Tab导航
- CI-持续集成(2)-软件工业“流水线”技术实现(转)
- 路由器实现pat技术的几条命令
- 使用JAVA技术实现新一代OSS/BSS
- Spring技术内幕3Spring AOP的实现
- php技术生成静态页面的实现
- HTTP Live Streaming直播(iOS直播)技术分析与实现
- HTTP Live Streaming直播(iOS直播)技术分析与实现
- PRC 技术实现:Hessian 基于DSA算法实现对时间戳签名验证
- 消灭中间商!他们用区块链技术实现流量的点对点交易
- 安卓蓝牙技术之中央BluetoothGatt和周边BluetoothGattServer的实现
- 微信小游戏「跳一跳」技术手段高分秘籍实现
- 体验C++中接口与实现分离的技术