Reflection matrix calculation

Source: Internet
Author: User
Bytes.
For details about the calculation, see the d3d sample as follows: Code

D3dxmatrixa16 matviewsaved;
M_pd3ddevice -> Gettransform (d3dts_view, & Matviewsaved ); // Obtain view Matrix
// Define a flip reference plane. You can define the position and normal as needed.
D3dxvector3 vpoint ( 0 , 0 , 0 );
D3dxvector3 vnormal ( 0 , 1 , 0 )
;
D3dxmatrixa16 matview, matreflect;
D3dxplane plane;
D3dxplanefrompointnormal ( & Plane, & Vpoint, & Vnormal ); // Generate this plane
D3dxmatrixreflect ( & Matreflect, & Plane ); // Obtain the reflection matrix of the plane.
D3dxmatrixmultiply ( & Matview, & Matreflect, & Matviewsaved ); // Use the reflection matrix to flip the view matrix. The camera is flipped to the reflection position.
M_pd3ddevice -> Settransform (d3dts_view, & Matview ); // Set view matrix so that the content rendered by the camera is flipped
// Sets the shear plane so that the content on the reflector is rendered and the content on the plane is discarded.
M_pd3ddevice -> Setclipplane ( 0 , Plane );
M_pd3ddevice -> Setrenderstate (d3drs_clipplaneenable, 0x01 );
// (I wonder if this function works in the shader)

 

// If it is rendered to the material, you need to use the projection matrix to paste the material to the actual reflected object. You can also convert an object point to screen coordinates and then map it. The principle is the same.

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.