Ogiror 中 Hydrax 插件的使用

    最近因为工作原因研究了下Hydrax插件,这个插件非常不错,效果非常的好,可惜的就是效率不高,鸡肋!不过在游戏中这种大场景的水毕竟不是每个场景都存在,所以只要效率过得去就还算是可以的。将工作写成日志 记录我的工作。

 

Hydrax 插件的引导

pElement = XMLNode ->first_node ("water" );        // 先通过XML 读取HYDRAX 插件是否存在

    if (pElement )

        processHydrax (pElement );

 

mHydraxHandle = new Hydrax ::Hydrax (scenemgr , camera , mviewport );

mHydraxModule = new Hydrax ::Module ::ProjectedGrid (// Hydrax parent pointer

        mHydraxHandle ,

        // Noise module

        new Hydrax ::Noise ::Perlin (/*Generic one*/ ),

        // Base plane

        Ogre ::Plane (Ogre ::Vector3 (0,1,0), Ogre ::Vector3 (0,0,0)),

        // Normal mode

        Hydrax ::MaterialManager ::NM_RTT ,// NM_VERTEX, NM_RTT  // 顶点模式

        // Projected grid options

        Hydrax ::Module ::ProjectedGrid ::Options (60)); 

 

//lee  读取水配置文件

mHydraxHandle ->loadCfg (XMLfilename );

// Create water

mHydraxHandle ->create ();

 

 

void DotSceneLoader::UpdataHydrax(float timePassed) 
{
 if (mHydraxHandle)
 {
  Ogre::Vector3 col = mHydraxHandle->getWaterColor();
  Ogre::Vector3 original = col;

  float height = mHydraxHandle->getSunPosition().y / 10.0f;

  if(height < -99.0f)
  {
   col = original * 0.1f;
   height = 9999.0f;
  }
  else if(height < 1.0f)
  {
   col = original * (0.1f + (0.009f * (height + 99.0f)));
   height = 100.0f / (height + 99.001f);
  }
  else if(height < 2.0f)
  {
   col += original;
   col /= 2.0f;
   float percent = (height - 1.0f);
   col = (col * percent) + (original * (1.0f - percent));
  }
  else
  {
   col += original;
   col /= 2.0f;
  }
  mHydraxHandle->setWaterColor(col);// 设置水颜色 
  mHydraxHandle->setSunArea(height);//根据水波 实现太阳在水面上的效果

  mHydraxHandle->update(timePassed);//实时更新
 }
}

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值