Point, line, and Surface Generation (4) -- Introduction

Source: Internet
Author: User

Similarly, before introducing the above generation, we will first introduce the following basic property setting methods:Polygonattributes object

The construction methods of polygonattributes include:

Polygonattributes ()

Polygonattributes (INT polygonmode, int cullface, float polygonoffset)

Polygonattributes (INT polygonmode, int cullface, float polygonoffset, Boolean backfacenormalflip)

To enableProgramYou can set flags in the setcapability method to achieve specific changes during runtime:

Allow_cull_face_read, allow_cull_face_write, allow_mode_read, allow_mode_write

Allow_offset_read, allow_offset_write, allow_normal_flip_read, allow_normal_flip_write,

Polygonattributes is frequently used in the following ways:

Setcullface (INT cullface), setpolygonmode (INT polygonmode );

There are three values for cullface: cull_back (default value, only the front can be seen) cull_none (both the front and the back can be seen) cull_front (only the back can be seen)

For the surface composed of three points, the rule of judging the front and the back: Use the right hand spiral rule, the right hand around the order of the three points, the direction pointed by the thumb is positive, by default, when the positive direction points to the observer, the image can be displayed. When the positive direction deviates from the observer, the image cannot be displayed.

Polygonmode also has three values:

Polygon_fill (default value, in the form of a plane)

Polygon_point (expressed in the form of a vertex) is represented by a vertex at the given coordinate, and the vertex is not linked. The display effect of this method can also be achieved through pointarray.

Polygon_line (expressed in the form of vertex connections). The line link is used between the vertex and the vertex, which means that the graph is not filled, and linearray can achieve the same display effect, it is a little more complicated.

In the APIS provided by Java3D, the following flat objects are generated:

Trianglearray, quadarray, trianglestriparray, indexedquadarray, indexedtrianglearray, indexedtrianglestriparray, indexedtrianglefanarray

Trianglearray object

Constructor: trianglearray (INT vertexcount, int vertexformat)

Vertexcount: Number of vertex arrays. because it represents the surface of a triangle, the number of vertices must be a multiple of 3.

Quadarray object

Constructor: quadarray (INT vertexcount, int vertexformat)

This object is used to generate a plane. The vertices that constitute a plane must be multiples of four. Each four vertices constitute a plane.

Note: 1. Four points should be in total. If not, the program can still be compiled, but the displayed content is two triangular surfaces.

2. The surface composed of four points should not have concave points. If there are concave points, the display result of the program will be strange.

Trianglestriparray object

Constructor: trianglestriparray (INT vertexcount, int vertexformat, int [] stripvertexcounts)

Similar to linestriparray, this object is used to generate multiple groups of triangular planes. For each set of triangular planes,Its first three points generate a surface. Starting from the fourth point, each point and the two points adjacent to it generate a new triangle surface, the length of the stripvertexcounts array, that is, the number of triangular faces. Each set of subscripts stores the number of vertices used by each group.

Trianglefanarray object

Constructor: trianglefanarray (INT vertexcount, int vetexformat, int [] stripvertexcounts)

Role: SameTrianglestriparray objectThe same is used to generate multiple sets of triangle one-sided. Each set of triangle one-sided uses a certain number of vertices. When each group generates a triangle one-sided, the first three vertices constitute a triangle one-sided,The other vertices and one vertex adjacent to the front and the first vertex in each group generate a triangle one-sided, Stripvertexcounts and triangleatriparray have the same meaning

Indexedtrianglearray object

Constructor:Indexedtrianglearray(INT vertexcount, int vertexformat, int indexcount)

Purpose:Select some vertices from a vertex array to generate the required triangle one-sided. Indexcount indicates the number of vertices generated. The value is three times the number of one-sided triangles. The subscript of the selected vertex is placed in an array index. The graph consists of vertices in the index.

Indexedquadarray object

Role: this object andIndexedtrianglearrayThe object is basically the same,Only the selected point is a multiple of 4.

Indexedtrianglestriparray object

Constructor: indexedtrianglestriparray (INT vertexcount, int vertexformat, int indexcount, int [] stripindexcounts)

Purpose: generate multiple groups of triangle-sided items.This method integrates the indexedtrianglearray object method and the trianglestriparray object method.. Select the vertex to be displayed from the vertex array. Place the number of vertices to be displayed in indexcount, and place the subscript of the vertex to be displayed in the array index, the first three vertices in the Index Array generate a triangle surface. Starting from the fourth vertex, each vertex and the first two vertices adjacent to each other generate a new surface.

Indexedtrianglefanarray object

Its construction method is similar to the indexedtrianglestriparray object, but when each array generates a triangle surface,The first three vertices form a triangle surface. Starting from the fourth vertex, each other vertex forms a triangle surface with the first vertex next to each other and the first vertex in each group.

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.