青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Working with Morphing Animation(1)

Morphing in Action

Back in the early 90s, a revolutionary computer−graphics animation technique known as morphing hit the big league and was brought into the mainstream, thanks to a man known as Michael Jackson. No, I'm not referring to one of his plastic surgery fiascos−rather, the use of morphing in one of his music videos. Yep, the King of Pop used morphing techniques in his video for the song "Black or White" and created an animation phenomenon that continues to this day.

In case you haven't seen the video, let me explain. It includes a segment in which a person is grooving to the tune, and the camera is centered on that person's face. Every few seconds, the person's face morphs into another person's face. This continues while the face morphs more than 10 times. The results of the morphing in the video are incredible, and I still remember them clearly to this day!

As the years rolled by, morphing eventually made its way to gaming. Whereas the older days of morphing involved digitally editing video footage to smoothly change one image into another (such as in "Black or White" ), nowadays morphing (or at least the morphing we're going to discuss here) involves the smooth change of 3D meshes over time.

Probably the most popular example of morphing in gaming has got to be with id's Quake. In Quake, all of the characters' animation sequences are constructed from a series of morphing meshes. One mesh slowly changes shape to a second mesh, the second mesh changes shape to match a third mesh, and so on.

Spaced over a short period of time and using enough meshes from which to morph, all animation sequences are smooth and extremely easy to process. Even the lowliest of computer systems can run Quake decently. That's because morphing animation is extremely easy to work with, as you'll see in the next few chapters.

So as you can surmise, morphing−or tweening, as it is sometimes referred to (such as in the DirectX SDK)−is the process of changing one shape into another over time. For you, those shapes are meshes. The process of morphing a mesh involves slowly changing the coordinates of the mesh vertices, starting at one mesh's shape and progressing to another.

The mesh that contains the orientation of the vertices at the beginning of the morphing cycle is called the source mesh. The second mesh, which contains the orientation of the vertices at the end of the morphing cycle, is called the target mesh. Take a closer look at these two meshes to better understand the whole morphing process.

 

Defining Source and Target Meshes

The source and target meshes you'll deal with are everyday ID3DXMesh objects. However, you can't use just any two meshes for a morphing operation; there are some rules to follow. First, each mesh must share the same number of vertices. The morphing operation merely moves vertices from the source mesh positions to match the target mesh positions. This brings up the second rule: Each vertex in the source mesh must have a matching vertex (that is, a matching index number) in the target mesh. Take the meshes shown in Figure 8.1 as an example.

Vertex ordering is important here. For a vertex to move from the source position to the target position, it must share the same index number. If you were to renumber the order, the vertices would move in the wrong direction while morphing and produce some funky−looking results such as those shown in Figure 8.2:

As long as you design the meshes to have the same number of vertices and so that the vertex ordering matches up, you'll do just fine. As for getting the actual mesh data, I'll leave that in your capable hands. You can use the D3DXLoadMeshFromX function to load your meshes. After you've got two valid meshes loaded and ready to use, you can begin morphing them!

 

Morphing the Meshes

Now that you have two meshes to work with (the source and target meshes), you can begin the morphing process. Remember that morphing is the technique of changing one shape to another. You want the vertices in the source mesh, in their initial positions, to gradually move to match the positions of the target mesh's vertices.

You can measure the time period used to track the motion of the vertices from the source mesh coordinates to the target mesh coordinates using a scalar value (ranging from 0 to 1). With a scalar value of 0 the vertices will be positioned at the source mesh coordinates, whereas with a scalar value of 1 the vertices will be positioned at the target mesh coordinates. As Figure 8.3 illustrates, any scalar value between 0 and 1 will place the vertices somewhere between the source mesh and target mesh coordinates.

It is quite simple to calculate the coordinates in which to position a vertex between the source mesh coordinates and target mesh coordinates. Take a vertex from the source mesh and multiply the vertex's coordinates by the inversed scalar value (1.0−scalar). Using the inversed scalar means that the original vertex coordinates will use 100 percent of the vertex's coordinate position when the scalar is at 0.0, and zero percent of the vertex's coordinate position when the scalar is at 1.0.

Next, using the same indexed vertex's coordinates from the target mesh, multiply the vertex's coordinates by the scalar value. Adding the two resulting values gives you the final coordinates to use for the vertex during the morphing animation.

At first, this concept of multiplying the vertex coordinates by a scalar value and adding the results together might seem strange. If you're unsure of the math, perform the following calculations to see that the results are indeed correct. Use a one−dimensional value to represent the vertex coordinates. Set the source vertex coordinate to 10 and the target vertex coordinate to 20. To make things easy, use a scalar value of 0.5, which should give you a resulting morphing vertex coordinate of 15.

Multiplying the source coordinate (10) by 1−0.5 gives you 5. Multiplying the target coordinate (20) by 0.5 gives you 10. Adding the two results (5 and 10) gives you 15. Isn't that special−it comes out to the correct value after all!

This procedure would resemble the following code, assuming that the vertex's source coordinates are stored in vecSource, the target coordinates are stored in vecTarget, and the scalar is stored in Scalar.

// vecSource = D3DXVECTOR3 with source coordinates
// vecTarget = D3DXVECTOR3 with target coordinates
// Scalar = FLOAT with scalar value

// Multiply source coordinates by inversed scalar
D3DXVECTOR3 vecSourcePos = vecSource * (1.0f−Scalar);

// Multiply target coordinates by scalar
D3DXVECTOR3 vecTargetPos = vecTarget * Scalar;

// Add the two resulting vectors together
D3DXVECTOR vecPos = vecSourcePos + vecTargetPos;

After that last bit of code, the vecPos vector will contain the coordinates to use for positioning a vertex during the morphing animation. Of course, you would repeat the same calculations for each vertex in the source mesh. In the next section, you'll get to see how to perform these calculations to build your own morphing meshes. Before that, however, I'd like to mention something about timing your morphing animations.

Up to this point, I've been ignoring the factor of time−both the length of the animation cycle (how long the morphing animation takes to progress from the source coordinates to the target coordinates) and exactly what point in time you are sampling the coordinates from in the animation sequence. Assuming you are measuring time in milliseconds, with the animation's length stored as Length (a FLOAT value) and the time at which you are sampling the coordinates stored as Time (also a FLOAT value), you can compute a proper scalar value to use in your calculations as follows:

Scalar = Time / Length;

Using the calculations you've already seen in this section, you can use the scalar value to compute the coordinates of the vertices to build your morphing mesh.

That's the second time I've mentioned building a morphing mesh, so I won't keep delaying things. Read on to see how to build a morphing mesh you can use to render. Although I previously hinted at using a vertex shader, first I will show you the easiest way to build a morphing mesh−by manipulating the mesh's vertex buffers directly.


posted on 2008-04-28 16:59 lovedday 閱讀(843) 評論(1)  編輯 收藏 引用

評論

# re: Working with Morphing Animation(1) 2008-09-21 15:26 Li_Prominent

兄弟,摘抄“Advanced Animation with DirectX”的文章應該注明啊。
而且你摘地不完全啊。
少了Vertex Shader 那部分精華內容。  回復  更多評論   

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            六月丁香综合| 亚洲二区精品| 亚洲午夜视频在线| 正在播放欧美一区| 久久久免费观看视频| 欧美国产日本韩| 亚洲欧美卡通另类91av| 亚洲国产一区二区精品专区| 亚洲午夜激情免费视频| 久久午夜视频| 亚洲欧美日韩精品| 久久精品理论片| 国产伦精品一区二区三区免费| 在线日韩一区二区| 久久久久看片| 久久三级福利| 国产美女一区| 亚久久调教视频| 亚洲一区二区网站| 国产精品视屏| 亚洲国产精品悠悠久久琪琪| 美女91精品| 亚洲综合色噜噜狠狠| 午夜在线播放视频欧美| 久久久亚洲国产天美传媒修理工| 亚洲综合三区| 亚洲电影av在线| 亚洲激情欧美| 国产精品日韩欧美一区二区三区| 欧美亚洲专区| 亚洲影院免费| 国产精品99久久99久久久二8| 国内一区二区三区在线视频| 国产精品永久| 欧美高清视频一区二区三区在线观看| 欧美成人激情在线| 久久免费高清| 欧美激情导航| 久久av在线看| 亚洲日本aⅴ片在线观看香蕉| 亚洲人午夜精品免费| 日韩一级精品视频在线观看| 国产精品美女999| 欧美成人午夜剧场免费观看| 久久久久国产精品麻豆ai换脸| 亚洲一区二区免费看| 欧美一区二区私人影院日本| 亚洲无限av看| 亚洲一区二区高清视频| 一区二区三区四区五区在线| 一区二区av在线| 亚洲精品日韩在线观看| 在线观看欧美激情| 一区免费视频| 亚洲国产欧美一区二区三区同亚洲| 激情欧美一区二区三区| 亚洲成色精品| 亚洲一区免费视频| 亚洲欧美中文字幕| 久久久精品999| 久久国内精品视频| 毛片一区二区三区| 亚洲理伦电影| 欧美亚洲视频| 性色av一区二区三区在线观看| 久久久久久久成人| 免费看亚洲片| 国产精品蜜臀在线观看| 国产日韩在线一区二区三区| 亚洲高清一区二区三区| 亚洲精品影视在线观看| 亚洲调教视频在线观看| 狠狠色丁香久久综合频道| 亚洲黄一区二区三区| 欧美一区2区三区4区公司二百 | 亚洲日本欧美| 91久久在线视频| 亚洲午夜免费视频| 91久久久一线二线三线品牌| 午夜精品一区二区三区在线| 免费观看成人鲁鲁鲁鲁鲁视频| 国产欧美精品xxxx另类| 亚洲电影毛片| 一本久久综合亚洲鲁鲁| 久久久久久久一区二区| 亚洲调教视频在线观看| 奶水喷射视频一区| 美国十次了思思久久精品导航| 日韩视频免费观看高清在线视频| 久久这里有精品视频| 国产精品久久福利| 亚洲精品一二| 久久亚洲高清| 欧美在线亚洲一区| 国产农村妇女毛片精品久久莱园子| 亚洲国产欧美一区二区三区久久| 香蕉亚洲视频| 狠狠色丁香婷婷综合久久片| 亚洲精品一区二区三区婷婷月| 亚洲欧美韩国| 欧美影视一区| 久久人人爽爽爽人久久久| 米奇777在线欧美播放| 欧美国产第一页| 亚洲一区亚洲| 欧美+日本+国产+在线a∨观看| 欧美.www| 国产精品红桃| 亚洲国产中文字幕在线观看| 亚洲午夜一区| 欧美成人精品在线视频| 99国产精品一区| 久久亚洲综合网| 国产精品综合av一区二区国产馆| 亚洲风情亚aⅴ在线发布| 亚洲欧美国产高清va在线播| 欧美激情精品久久久六区热门 | 你懂的一区二区| 亚洲一二三级电影| 久久久久99| 在线视频你懂得一区 | 欧美日韩免费精品| 亚洲国产综合91精品麻豆| 久久夜色精品国产噜噜av| 亚洲男人影院| 国内偷自视频区视频综合| 亚洲第一精品电影| 国产亚洲女人久久久久毛片| 亚洲日本在线观看| 国产午夜精品福利| 91久久中文字幕| 亚洲国产精品高清久久久| 亚洲一区二区三区激情| 一本色道久久99精品综合| 老鸭窝毛片一区二区三区| 久久嫩草精品久久久精品| 欧美国产精品久久| 久久亚洲综合| 性娇小13――14欧美| 久久久www成人免费精品| 亚洲视频图片小说| 久久精品日韩欧美| 亚洲一区二区三区视频播放| 久久琪琪电影院| 校园激情久久| 欧美日韩的一区二区| 看欧美日韩国产| 国产精品一级二级三级| 最新69国产成人精品视频免费| 国产欧美日本在线| 洋洋av久久久久久久一区| 亚洲国产99精品国自产| 欧美影院视频| 欧美中文在线字幕| 国产精品久久久久久久久久免费看 | 这里是久久伊人| 久久久久久夜精品精品免费| 午夜精品久久久久久久久| 欧美手机在线视频| 99精品福利视频| 欧美一区二区三区四区在线| 国产精品成人观看视频国产奇米| 欧美精品亚洲精品| 久久精品视频亚洲| 中文国产亚洲喷潮| 国产欧美一区二区白浆黑人| 在线中文字幕日韩| 亚洲视屏一区| 国产精品网站在线| 欧美 日韩 国产在线| 欧美激情一区二区三区全黄| 亚洲欧美一区二区三区久久| 欧美激情免费观看| 久久综合精品国产一区二区三区| 韩国成人理伦片免费播放| 99国产麻豆精品| 欧美伦理一区二区| 久久久综合激的五月天| 欧美午夜电影一区| 久久久久久一区二区| 欧美国产一区二区在线观看| 欧美国产一区二区| 一区二区免费在线观看| 国产精品v欧美精品v日本精品动漫 | 亚洲国产高清自拍| 亚洲国产精品v| 欧美性大战xxxxx久久久| 亚洲欧美日韩成人| 亚洲激情不卡| 久久久噜噜噜久噜久久| 99精品国产在热久久婷婷| 欧美日韩中文字幕在线视频| 午夜精品电影| 一区二区久久| 亚洲精品久久久久中文字幕欢迎你 | 亚洲一区二区三区高清| 韩日欧美一区| 国产精品羞羞答答| 欧美激情第一页xxx| 牛夜精品久久久久久久99黑人|