Simple Particle System

Source: Internet
Author: User

I will not describe the concept. In fact, it is not too difficult to implement it. You can search for it online, so I will not describe it.

This program uses the announcement board technology instead of the dot genie, which is based on the viewpoint. I will briefly discuss the calculation method.

Let's set a point of P (x, y, z) in the oxyz coordinate system. We need to place the point (x, y, z) in the same Coordinate System in the puvn Coordinate System in the oxyz coordinate system, the location of this in oxygen Z is

X u + Y x V + z x n + p (viewpoint position ). (The Front X is a cross product ). Then we set the four points in the plane in the oxyz coordinate system perpendicular to Z, so the conversion to punv is also perpendicular to Z, because they share the same coordinate point in their own coordinate system, then this is the announcement board. U, V, and n are calculated based on the viewpoint or the visual plane. If the viewpoint is based on, n = (Pos (The position of the announcement board) -Eye (position of the observation point). If it is based on the video plane, U, V, and n are the XYZ of the viewpoint coordinate system.

D3dxvector3 maid [I]. m_currentpos;
D3dxvector3 TMP = maid-eyepos;
Float Dis = d3dxvec3length (& TMP );

D3dxvector3 up (0, 1 );
D3dxvector3 U, V;
D3dxvector3 n = TMP;
D3dxvec3cross (& U, & up, & N );
D3dxvec3normalize (& U, & U); // get the X axis
D3dxvec3cross (& V, & N, & U );
D3dxvec3normalize (& V, & V); // get the Y axis
D3dxvec3normalize (& N, & N); // get the Z axis

D3dxvector3 Q1 (-m_size, m_size, DIS );
D3dxvector3 Q2 (m_size, m_size, DIS );
D3dxvector3 Q3 (m_size,-m_size, DIS );
D3dxvector3 Q4 (-m_size,-m_size, DIS );

D3dxmatrix MAT (U. x, u. Y, U. Z, 0,
V. X, V. Y, V. Z, 0,
N. X, N. Y, N. Z, 0,
0, 0, 0, 1 );
D3dxvec3transformcoord (& Q1, & Q1, & mat );
D3dxvec3transformcoord (& Q2, & Q2, & mat );
D3dxvec3transformcoord (& Q3, & Q3, & mat );
D3dxvec3transformcoord (& Q4, & Q4, & mat );

P [Index]. u = 0; P [Index]. V = 0; P [index ++]. Pos = Q1 + eyepos;
P [Index]. U = 1; p [Index]. V = 0; P [index ++]. Pos = Q2 + eyepos;
P [Index]. U = 1; p [Index]. V = 1; p [index ++]. Pos = Q3 + eyepos;
P [Index]. u = 0; P [Index]. V = 1; p [index ++]. Pos = Q4 + eyepos;
}

Then the following is simple. It is noted that if you use dxut cmodelviewcamera, we only use cfirstpersoncamera. In addition, if you do not close the deep test, some billboards may be blocked. I don't understand why. All images are rendered at a time. Even if we perform a deep test, our Alpha mixture is also open. We should also mix the masked points and the current film source with Alpha, but this is not the case. You can only think like this: draw all the elements at a time using drawprimitive. The Alpha mixture is to mix the backup buffer pixels before the image is drawn with the Alpha of the current element. After the painting is complete, update it again, instead of creating a new buffer for every element, this is too inefficient, So we disable the deep test.

We should add a scripting language to facilitate the compilation of particle types, but I still don't. We will continue to add features later.

 

 

 

Source code: http://download.csdn.net/source/1797269

 

Related Article

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.