The mesh mesh in the axiom3d:ogre is decomposed into a point line polygon.

Source: Internet
Author: User

This demand may be more eccentric, general mesh we assembled the vertices, index data, directly into the index buffer rendering. But if there are special needs, such as the need to label mesh vertices, lines, polygons, and special display of this information.

At the beginning, I was thinking of analyzing the mesh vertexdata and indexdata, the analysis of the vertex find the source code found ogre itself has related classes, here Axiom3d and Ogre source some differences, but the general meaning of the same.

The main classes used: Edgelistbuilder,commonvertexlist,edgedata.

The process is simple, edgelistbuilder add mesh, analyze vertex and index buffers in mesh, call method build to generate Commonvertexlist and edgedata. Let's take a look at the specific process below.

First of all, we have to note that whether it is a mesh or something that can be rendered, it is not necessarily a vertexdata (vertex buffer) corresponding to a indexdata (index buffer), such as a mesh of several Submesh shared vertexdata. So Edgelistbuilder saved a vertexdatalist and indexdatalist, in the middle there is an association list, in Ogre is a geometry structure, packaging vertex index Indexdata, Vertex index list index indexset, vertex buffer list index Vertexset, vertex index rendering mode operationtype. In axiom, it is a corresponding shaping array indexdatavertexdatasetlist the same length as the vertex index indexdatalist, in fact, as with Ogre, The index in the indexdatalist is placed directly into the indexdatavertexdatasetlist to get vertexset. There is also a operationtypelist, similarly, the same length as the indexdatalist.

Again Commonvertex, this structure has only five fields, the Vector3 type of position (vertex position), index (in the corresponding Indexdata index), Vertexset (index in Vertexdatalist), Indexset (index in Indexdatalist), Originalindex (index in commonvertexlist). Let's not confuse a few indexes with index. Suppose I'm looking for a second index buffer where the sixth data corresponds to the value of the vertex index, then in this case, indexset=2,index=6. indexdatalist[2][6] This value. Set p= Indexdatalist[indexset][index], we want to the value of the corresponding vertex index, the following calculation Vertexdatalist[vertexset][p] is the value of this vertex. There is also an easier way to commonvertexlist the vertex position, while the Originalindex in Commonvertex is the index to commonvertexlist, so you can go directly from commonvertexlist[ Originalindex] Gets the vertex position, which would be a better choice if only the vertex position is not considered normal, texture coordinates, color, etc.

Edgedata mainly contains two lists, one is trianglelist (triangle list), one is the Edgegrouplist list, one edgegroup corresponds to a vertexdata, many edge.edge good understanding, is the edge we want, 2.1 Lines, the attributes are Triindex (index in trianglelist), can be shared by two triangles. Vertindex (corresponds to the position of Vertexdata in Edgegroup). Sharedvertindex ( Corresponds to the index in the commonvertexlist).

The build method of Edgelistbuilder is to fill the relationship between Commonvertexlist and Edgedata above.

After calling build, first generate Edgegroup with the vertexdata in Vertexdatalist, and then generate a triangular mesh based on the index buffer set (indexdatalist), which tells the GPU how to render, where That tells us how to generate triangles.

Here the triangle has a welding process, may merge vertices, merge vertices there are five strategies, one is to merge all, the other is merged in the same index buffer, the third is merged in the same vertex buffer, and four is merging the same vertex buffer with the index buffer, and five non-merging. Here, first you will select a merge all, Then two, three or four, five. When merging 1-4, the vertices are reduced, which can create a problem that is common to the Triangle 22, but after merging, it may cause more than two triangles to be shared, thus creating an illegal mesh. So it's almost like this, If the merged vertices do not cause the wrong network, use the first policy, or the second, until the last fifth strategy.

After the triangle is generated, the corresponding edge edge is generated according to the triangle.

From Ogre and Axiom3d to these references, mainly for the shadow calculation, I am also used for the partial door, used to show the model of the points, lines, polygons and other elements. But according to the function of Edgelistbuilder, we can combine some models of the same material into a single model (some limitations , the model vertex contains the information preferably only vertex position, normal), in Ogre and Axiom3d also did not see the relevant application, maybe this idea is not perfect, I will try this effect in the back.

One of the top, line, surface related decomposition is only a first draft, so the relevant code is temporarily not put, and so on comprehensive consideration of related functions to set the corresponding method attributes and then give how to break down the reorganization of the code.

The mesh mesh in the axiom3d:ogre is decomposed into a point line polygon.

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.