Using a first-person camera (cfirstpersoncamera) in dxut)

Source: Internet
Author: User

First declare the camera: cfirstpersoncamera g_camera; // camera
Then, set the projection matrix in the device initialization function:
// Create and set the Projection Matrix
Float faspectratio = pbackbuffersurfacedesc-> width/(float) pbackbuffersurfacedesc-> height;
G_camera.setprojparams (d3dx_pi/4, faspectratio, 0.1f, 00000000f );
Pd3ddevice-> settransform (d3dts_projection, g_camera.getprojmatrix ());
Then, set the observation matrix in the action of each frame:
G_camera.framemove (felapsedtime); // update the camera Information
Pd3ddevice-> settransform (d3dts_view, g_camera.getviewmatrix (); // sets the observation matrix
Then add the camera's message response to the message response function:
// Add it to the msgproc Function
G_camera.handlemessages (hwnd, umsg, wparam, lparam );
This is OK and I hope it will help you.

 

Note that g_pd3ddevice-> present (null, null) already exists in cfirstpersoncamera. This operation submits the background information to the foreground, you must stop writing this when writing your own rendering function. Otherwise, the model will flash.

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.