(This article is written on: 21:50:03)
[About d3dfvf_xyz and d3dfvf_xyzrhw]
1: If you use the vertex format d3dfvf_xyz, direct3d performs views, projections, world transformations, and Ray calculations before you can get the objects you have drawn in the window. The coordinate system is the left-hand Coordinate System in d3d. the X axis increments to the right, and the Y axis increments upwards.
2: If the vertex format d3dfvf_xyzrhw is used, it indicates that the vertex used by direct3d is already in the screen coordinate system and does not perform views, projections, world transformations, or light computing, because the d3dfvf_xyzrhw Mark tells it that the vertex has been processed and the vertex is directly subjected to the grating operation. Any conversion using settransform is invalid. So his coordinate system is the screen coordinate system. The X axis increments to the right, and the Y axis increments downward.
★Note: texture coordinates use the screen coordinate system.
[Metadata type: d3dprimitivetype]
D3dprimitivetype is the primitive type. It is the 1st parameter of drawprimitive () and drawprimitiveup.
Its types include:
■ D3dpt_pointlist: the elements to be drawn are vertices.
■ D3dpt_linelist: the elements to be drawn are some line segments (rule: points 1 and 2 are connected to form a line segment, and points 3 and 4 are connected to form another line segment)
■ D3dpt_linestrip: the element to be drawn is the connected line segment (rule: a line segment is formed when points 1 and 2 are connected, and a line segment is formed when points 2 and 3 are connected)
■ D3dpt_trianglelist: the elements to be drawn are discrete triangles (rule: points 1, 2, and 3 form a triangle, and points 4, 5, and 6 form another triangle)
■ D3dpt_trianglestrip: the elements to be drawn are connected triangles (rule: points 1, 2, and 3 constitute a triangle, points 2, 3, and 4 constitute another triangle)
■ D3dpt_trianglefan, points 1, 3, and 4 form another triangle)
Example of left-hand coordinates in d3dfvf_xyz format
Key code:
Struct customvertex
{
Float x, y, z;
Unsigned long color;
Float tu, TV;
};
# Define d3dfvf_vertex (d3dfvf_xyz | d3dfvf_diffuse | d3dfvf_tex1)
Customvertex objvertex [] =
{
// V1, V2, V3 V1, V3, V4
{0, 0, 0, Col, 0, 1}, // V1
{0,256, 0, Col, 0, 0} // v2
{256,256, 0, Col, 1, 0}, // v3
{256, 0, 0, Col, 1, 1}, // v4
};
//...
G_d3ddevice-> drawprimitive (d3dpt_trianglefan, 0, 2 );
//...
Screen coordinate example in d3dfvf_xyzrhw format
Key code:
Struct customvertex
{
Float X, Y, Z, rhw;
Unsigned long Col;
Float tu, TV;
};
# Define d3dfvf_vertex (d3dfvf_xyzrhw | d3dfvf_diffuse | d3dfvf_tex1)
Customvertex objvertex [] =
{
// V1, V2, V3 V1, V3, V4
{0, 0, 0, 1, Col, 0, 0}, // V1
{256, 0, 0, 1, Col, 1, 0}, // v2
{256,256, 0, 1, Col, 1, 1}, // v3
{0,256, 0, 1, Col, 0, 1} // v4
};
//...
G_d3ddevice-> drawprimitive (d3dpt_trianglefan, 0, 2 );
//...
[About backend removal: d3dcull_mode]
Note:
■ By default, d3d regards clockwise as the front, so triangle vertices are usually defined in clockwise order.
■ Check whether the format d3dfvf_xyz or d3dfvf_xyzrhw is used.
Setrenderstate (d3drs_cullmode, d3dcull_none): Do not remove the back, that is, draw both the front and back.
Setrenderstate (d3drs_cullmode, d3dcull_cw): removes the clockwise direction from the back.
Setrenderstate (d3drs_cullmode, d3dcull_ccw): removes the backend from the clockwise direction (the default value is used in Blanking ).