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

天行健 君子當(dāng)自強(qiáng)而不息

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) 評(píng)論(1)  編輯 收藏 引用

評(píng)論

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

兄弟,摘抄“Advanced Animation with DirectX”的文章應(yīng)該注明啊。
而且你摘地不完全啊。
少了Vertex Shader 那部分精華內(nèi)容。  回復(fù)  更多評(píng)論   


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲精品系列| 国产亚洲欧美aaaa| 一区二区不卡在线视频 午夜欧美不卡'| 亚洲精品欧洲精品| 国产精品视频区| 国产精品hd| 欧美大片在线影院| 浪潮色综合久久天堂| 欧美亚洲免费在线| 亚洲精选一区二区| 一二三四社区欧美黄| 欧美黄色一区二区| 久久精品国产精品亚洲| 亚洲男女自偷自拍| 亚洲免费在线看| 亚洲欧美日韩成人高清在线一区| 亚洲精品综合久久中文字幕| …久久精品99久久香蕉国产 | 国产精品视频在线观看| 欧美伦理91i| 欧美三级日本三级少妇99| 欧美凹凸一区二区三区视频| 噜噜噜噜噜久久久久久91| 久久这里有精品视频| 欧美黄色免费网站| 欧美日韩一区在线播放| 欧美精品福利视频| 一本色道久久精品| 国产精品99久久不卡二区| 欧美日韩国产成人在线观看| 野花国产精品入口| 在线一区亚洲| 国产亚洲精品激情久久| 欧美视频免费看| 99国产精品久久久久久久久久| 亚洲人成在线观看网站高清| 久久中文欧美| 亚洲人成7777| 亚洲高清不卡一区| 麻豆成人av| 中文在线不卡| 99精品欧美一区二区蜜桃免费| 亚洲一级电影| 老色鬼久久亚洲一区二区| 亚洲欧洲精品成人久久奇米网| 亚洲另类一区二区| 另类av导航| 欧美国产精品中文字幕| 在线日韩av永久免费观看| 蜜臀av一级做a爰片久久| 欧美大片免费| 午夜精品久久久久| 久久久在线视频| 99riav久久精品riav| 亚洲午夜精品| 欧美国产欧美亚洲国产日韩mv天天看完整 | 国产一区二区成人久久免费影院| 亚洲欧美日韩国产综合| 欧美国产欧美亚洲国产日韩mv天天看完整 | av成人黄色| 欧美国产高清| 欧美日韩情趣电影| 欧美影院成人| 欧美激情第4页| 久久精品视频一| 欧美va亚洲va日韩∨a综合色| 9久草视频在线视频精品| 亚洲视频网站在线观看| 欧美综合国产| 亚洲欧美另类在线观看| 美女在线一区二区| 国产精品v亚洲精品v日韩精品 | 亚洲人成网站777色婷婷| 欧美在线影院在线视频| 一区二区三区日韩精品视频| 美女图片一区二区| 久热综合在线亚洲精品| 国产精品推荐精品| 国产精品99久久久久久久vr| 久久www免费人成看片高清| 亚洲欧美日韩在线播放| 免费短视频成人日韩| 亚洲视频一区在线| 有坂深雪在线一区| 亚洲午夜免费视频| 欧美亚洲综合久久| 国产精品色婷婷| 亚洲一区二区三区精品在线观看 | 一区二区三欧美| 久久精彩免费视频| 日韩午夜av电影| 亚洲日本激情| 欧美大色视频| 久久成人精品一区二区三区| 欧美a级理论片| 亚洲无亚洲人成网站77777| 国产一区二区三区高清| 在线成人www免费观看视频| 国产精品免费福利| 欧美黄色成人网| 国产一区二区三区丝袜| 欧美一区日本一区韩国一区| 欧美 日韩 国产 一区| 在线综合欧美| 激情欧美一区| 国产喷白浆一区二区三区| 一本到12不卡视频在线dvd| 韩国av一区二区三区四区| 欧美 亚欧 日韩视频在线| 亚洲欧洲日产国产综合网| 一区二区三区欧美视频| 男人的天堂亚洲| 亚洲精品视频在线播放| 亚洲欧美视频在线| 免费毛片一区二区三区久久久| 欧美精品一区二区三区视频| 欧美成人精品在线视频| 精品二区久久| 免费一级欧美片在线播放| 欧美一级二区| 91久久精品国产91性色tv| 国产精品jizz在线观看美国| 欧美福利网址| 国产精品国产三级国产aⅴ浪潮| 欧美一区二区三区免费大片| 欧美96在线丨欧| 久久免费视频观看| 国产精品av免费在线观看| 欧美国产另类| 尤物精品国产第一福利三区| 亚洲素人在线| 亚洲天堂黄色| 欧美国产在线视频| 国产精品大全| 亚洲欧美精品suv| 欧美人在线观看| 亚洲人成网站色ww在线| 伊人一区二区三区久久精品| 亚洲欧美成人一区二区在线电影| 亚洲香蕉在线观看| 欧美色网在线| 日韩亚洲一区在线播放| 亚洲色图综合久久| 欧美日韩亚洲国产一区| 91久久黄色| 中文国产成人精品| 欧美人与禽性xxxxx杂性| 日韩午夜黄色| 午夜伦欧美伦电影理论片| 国产精品qvod| 亚洲欧美日韩网| 久久噜噜亚洲综合| 狠狠色狠狠色综合日日小说| 久久成人综合网| 欧美不卡视频| 亚洲免费激情| 欧美三级网址| 亚洲国产精品一区二区三区| 91久久黄色| 欧美婷婷在线| 亚洲小视频在线| 久久久久国产精品一区| 黑人巨大精品欧美一区二区小视频| 久久国产精品久久久久久电车| 久久人人爽国产| 最新亚洲激情| 欧美日韩日本网| 午夜精彩视频在线观看不卡| 久久五月天婷婷| 日韩一级在线观看| 国产精品欧美经典| 另类激情亚洲| 一区二区三区欧美在线| 久久国产精品电影| 亚洲国产精品久久久久秋霞蜜臀 | 欧美伦理a级免费电影| 香蕉亚洲视频| 亚洲欧洲综合| 久久婷婷亚洲| 亚洲伊人一本大道中文字幕| 黄色成人免费网站| 国产精品精品视频| 欧美xxx成人| 久久se精品一区精品二区| 亚洲精选成人| 欧美成人第一页| 久久久福利视频| 亚洲一区二区三区四区视频| 亚洲高清免费视频| 国产亚洲美州欧州综合国| 欧美日韩国产精品成人| 欧美一区二区三区视频在线观看| 亚洲精品在线免费观看视频| 麻豆乱码国产一区二区三区| 香蕉乱码成人久久天堂爱免费 | 久久亚洲美女| 亚洲影院污污.| 亚洲日产国产精品| 欧美成人午夜视频| 亚洲精品日韩综合观看成人91|