16.Overlay里可以放3d元素?
如果这样的话,就可以用来做3d的新手引导小精灵了!不用再跟巨人一样用序列帧了!
depth_check on时
depth_check off后
代码
material Examples
/
DepthCheck
{ technique { pass { depth_check off texture_unit { texture RustySteel.jpg } texture_unit { texture spheremap.png colour_op_ex add src_texture src_current colour_op_multipass_fallback one one env_map spherical } } } }
|
在c++代码里
代码
Overlay
*
pOverlay
=
OverlayManager::getSingleton().getByName(
"
Core/DebugOverlay
"
);
if (pOverlay)
{
SceneManager * pSM = OGRE_NEW DefaultSceneManager( " Overlay SceneManager " );
SceneNode * pNode = OGRE_NEW SceneNode(pSM, " Overlay Node " );
pNode -> setPosition( - 10 , 10 , - 160 );
Entity * pEnt = mSceneMgr -> createEntity( " head " , " ogrehead.mesh " );
// 如果指定material脚本的话,在脚本里关闭depth check
// pEnt->setMaterialName("Examples/DepthCheck");
pNode -> attachObject(pEnt);
// 如果不指定material脚本的话,关闭每个pass的depth check
for (unsigned int i = 0 ; i < pEnt -> getNumSubEntities(); ++ i)
{
SubEntity * pSubEnt = pEnt -> getSubEntity(i);
if (pSubEnt)
{
Technique * pTech = pSubEnt -> getMaterial() -> getBestTechnique();
if (pTech)
{
for (unsigned int iPass = 0 ; iPass < pTech -> getNumPasses(); ++ iPass)
{
Pass * pPass = pTech -> getPass(iPass);
if (pPass)
{
pPass -> setDepthCheckEnabled( false );
}
}
}
}
}
pOverlay -> add3D(pNode);
}
if (pOverlay)
{
SceneManager * pSM = OGRE_NEW DefaultSceneManager( " Overlay SceneManager " );
SceneNode * pNode = OGRE_NEW SceneNode(pSM, " Overlay Node " );
pNode -> setPosition( - 10 , 10 , - 160 );
Entity * pEnt = mSceneMgr -> createEntity( " head " , " ogrehead.mesh " );
// 如果指定material脚本的话,在脚本里关闭depth check
// pEnt->setMaterialName("Examples/DepthCheck");
pNode -> attachObject(pEnt);
// 如果不指定material脚本的话,关闭每个pass的depth check
for (unsigned int i = 0 ; i < pEnt -> getNumSubEntities(); ++ i)
{
SubEntity * pSubEnt = pEnt -> getSubEntity(i);
if (pSubEnt)
{
Technique * pTech = pSubEnt -> getMaterial() -> getBestTechnique();
if (pTech)
{
for (unsigned int iPass = 0 ; iPass < pTech -> getNumPasses(); ++ iPass)
{
Pass * pPass = pTech -> getPass(iPass);
if (pPass)
{
pPass -> setDepthCheckEnabled( false );
}
}
}
}
}
pOverlay -> add3D(pNode);
}
这样子关闭了pass的depth_check后,如果在场景里也用这个模型并且使用这个pass渲染的时候就没有depth_check了。反正屏幕上用的一般不会在场景里使用,所以也没问题了。
改了下position试了下,发现Overlay坐标系如下
右手坐标系,ViewPort中心是原点.
可以继续YY下,播放角色骨骼动画及声音,以及屏幕上的运动轨迹,就可以用来做新手引导小精灵了!用来做个3D的施法进度条也可以啊!
虽然OGRE的表层元素类和表层容器类被设计为是可供应用程序开发人员扩展的,但是有一些元素是Ogre本身自带的。包括: · Panel · BorderPanel · TextArea |
3D的Overlay Element看来也是可以在脚本中配置的,有兴趣了再弄!
http://www.cnblogs.com/lai3d/archive/2010/01/21/1653635.html