Directx10 dragon book notes-Chapter 1 after-school questions implement flame Animation

Source: Internet
Author: User

I couldn't find the flame picture. I found a few record files, right in bolt animations for Chapter 9 downloaded from directx10 in d3dcoder.net.


There are many images in it. Since C ++ is also a beginner, it is too late to get String concatenation functions. Only a maximum of frames of BMP can be defined and loaded one by one.

The specific Code is based on the "Crate" example project, that is, the code of the wooden box.

The added code is as follows:

ID3D10ShaderResourceView* mDiffusePic[9];
I have defined a shaderview that can hold nine images.

Then start loading from the file

HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt001.bmp", 0, 0, &mDiffusePic[0], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt002.bmp", 0, 0, &mDiffusePic[1], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt003.bmp", 0, 0, &mDiffusePic[2], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt004.bmp", 0, 0, &mDiffusePic[3], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt005.bmp", 0, 0, &mDiffusePic[4], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt006.bmp", 0, 0, &mDiffusePic[5], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt007.bmp", 0, 0, &mDiffusePic[6], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt008.bmp", 0, 0, &mDiffusePic[7], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt009.bmp", 0, 0, &mDiffusePic[8], 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"BoltAnim/Bolt001.bmp", 0, 0, &mDiffuseMapRV, 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"WoodCrate01.dds", 0, 0, &mDiffuseMapRV1, 0 ));HR(D3DX10CreateShaderResourceViewFromFile(md3dDevice, L"defaultspec.dds", 0, 0, &mSpecMapRV, 0 ));

If you know that boltanim/bolt00+i316.bmp is concatenated into a function parameter, please let me know, because this will allow you to call the dozens of images, and there is no need for me to copy 9 times in this way.

When everything is stored in mdiffusepic, it begins to be drawn.

At first, the wooden box was drawn with a fixed texture map mdiffusemaprv.

Here we use the defined mdiffusepic, and change the image at intervals in the drawscene function.

In this way, frame animation is quickly formed.

// Every quarter second, generate a random wave.static float t_base = 0.0f;static int flag=0;if( (mTimer.getGameTime() - t_base) >= 0.15f ){t_base += 0.15f;mfxDiffuseMapVar->SetResource(mDiffusePic[(flag++)%9]);}

This is mainly the above function.

Because it is my reading notes, no source code is provided for all projects. It is just convenient for you to check for missing ones when learning this book. The above are the core code that requires attention.

Directx10 dragon book notes-Chapter 1 after-school questions implement flame Animation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.