Generate the U, V, {w} coordinates of the subdivided vertex in ts. We will generate a new vertex position based on the control point and U, W, {w} coordinate, in the subdivision of the Quadrilateral above, we use the bilinear difference method to obtain new vertex positions, all of which are on a plane. In this tutorial, we use the parameter equation to generate a polygon. When the Tess factor increases, we can obtain an approximate sphere.
The code for generating new vertex in DS is:
// The Position of the vertex on the current surface
Float3 position = float3 (0.0, 0.0, 0.0 );
Float Pi2 = 6.28318530;
Float Pi = Pi2/2;
Float r = 3.0;
Float Fi = pI * uvwcoord. X;
Float Theta = Pi2 * uvwcoord. Y;
Float sinfi, cosfi, sintheta, costheta;
Sincos (FI, sinfi, cosfi );
Sincos (Theta, sintheta, costheta );
Position = float3 (R * sinfi * costheta, R * sinfi * sintheta, R * cosfi );
In modelclass, the initial control point has only one point, and the body element semantics is:
Devicecontext-> iasetprimitivetopology (d3d11_primitive_topology_1_control_point_patchlist );
The Tess factor is 1 and there is no subdivision, so there is nothing. For 2, a quad is generated from a vertex. For 3, it is a triangle ,...
After the program is executed, we press the up and down arrow keys to see the process of gradually becoming a circle from a quadrilateral. After the program is executed, the interface is as follows:
Complete code can be found:
Project File mytutoriald3d11_56
Download Code:
Http://files.cnblogs.com/mikewolf2002/d3d1150-58.zip
Http://files.cnblogs.com/mikewolf2002/pictures.zip