Ogre : How to actually get morph animations to work in the engine
来源:互联网 发布:淘宝优惠助手 编辑:程序博客网 时间:2024/06/10 07:34
Introduction
Ogre features both Morph animation and Pose animation. The difference between these two techniques is explained in the manual. However, what is not explained there, is how to actually get morph animations to work in the engine. This article provides explanation of this.
Code in the engine
Morph animation works like skeletal animation from the in-engine point of view. If there is a morph animation in the mesh, then you can get it to animate like this:
Morph AnimationState usage
//get the animation Ogre::AnimationState* state = entity->getAnimationState("morph"); state->setEnabled(true); //do this every frame to play the animation float time = 0.1f; state->addTime(time);
An example shader
You can let OGRE do software blending of the morph animation, but you can also do it in hardware. The shader will only get morph data from the engine if its AnimationState is enabled, so the code above is needed.
Morph.material
vertex_program Cg_Morph_VP cg { source Morph.cg entry_point Morph_VP profiles vs_1_1 includes_morph_animation true default_params { param_named_auto worldViewProjMatrix worldviewproj_matrix param_named_auto animationPhase animation_parametric } } material Morph { technique { pass { vertex_program_ref Cg_Morph_VP { } } } }
Morph.cg
Note that the second position is put in the first free texture coordinate.
void Morph_VP ( float3 position1 : POSITION, float2 uv : TEXCOORD0, float3 position2 : TEXCOORD1, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float animationPhase ) { float3 blendedPosition = lerp(position1, position2, animationPhase); oPosition = mul(worldViewProjMatrix, float4(blendedPosition, 1));}
注意事项:
position2是放到TEXCOORD1的位置,如果你自己本身有N个纹理坐标,那么position的位置会被放到末尾,即TEXCOORDN+1
原文链接:http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Morph+animation
- Ogre : How to actually get morph animations to work in the engine
- How to play animations in Cocos2d-x?
- How to change the Push and Pop animations in a navigation based app
- YP.1.7 How Do We Get the Electrons to Do The Work?(双语)
- How to get the object type in javascript:
- In RadGrid, How to get the control inside usercontrol
- how to get the function back trace in php
- How to schedule and get the report in SCOM2012
- How to get the HttpServletRequest in Struts 2
- How to get the JSON results in ExtJS
- How to get the dmesg output in initramfs (debian)
- How to Get the WDK
- How to get JBoss and Apache to work together
- How To Use Animations and Sprite Sheets in Cocos2D
- How to get to the point quickly?
- How to work
- HashMap how to work
- How to get Action Log of Work order
- Strategy Pattern
- CopyOnWriteArrayList源码分析
- OpenCV常用函数记载
- 字符串——正则表达式匹配
- 织梦自增函数[field:global name=autoindex/]的用法
- Ogre : How to actually get morph animations to work in the engine
- Android ActivityThread(主线程或UI线程)简介
- [BZOJ2084]Antisymmetry(二分+hash)
- 数据库索引详解
- dedecms安装教程:留言本添加用户留言时间教程
- 配置tomcat以运行PHP项目
- Android XML布局文件报错Unable to inflate view tag without class attribute
- Java实现 数组实现循环队列
- 一款能用易用好用的Android图片轮播轮子