Solving the normal problem of OpenGL compute vertices

Source: Internet
Author: User

Because of the required papers, recently began to learn OpenGL. Because beginners have just started to have so often encountered a lot of problems.

These days, the difficulty of OpenGL is clear.

Some confusion:

    1. On-line Baidu. Found very much the introduction of plane method vector and program. I know that the vertex method vector is what I want later.
    2. For three points in a space. How to determine the method of plane normal vector? This can be inferred by attempting to combine the result graph clockwise and counterclockwise. Below is an introduction to how to proceed if.

How to infer the direction of a planar normal vector by means of a method (this refers to a triangular patch):

First of all, the data, of course, is that each patch in the original data is made up of three vertices. Today, for example, there is a triangular plane in space composed of three vertex a,b,c.

Then. There are two things that can happen, such as the following:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzmlzagvyd2fu/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">

So we just have to try it out in the program and we'll get our results.

Below I give some of my code already (Stanford University's famous Bunny model):

Of these, A and B are two vectors behind which the cross is to be multiplied, and the point1,point2,point3 is the three vertices of the triangular patch.


Scenario 1:

A[X] = point2[x]-point1[x]; A[y] = Point2[y]-point1[y]; A[Z] = point2[z]-point1[z]; B[X] = point1[x]-point3[x]; B[y] = Point1[y]-point3[y]; B[Z] = point1[z]-point3[z];

Scenario 2:

<span style= "color: #000000;" >A[X] = point3[x]-point1[x]; A[y] = Point3[y]-point1[y]; A[Z] = point3[z]-point1[z]; B[X] = point1[x]-point2[x]; B[y] = Point1[y]-point2[y]; B[Z] = point1[z]-point2[z];</span>


It can be seen from both of the above. They are indeed the opposite.

You can try it again when you are actually working on it.


To calculate the process record of a vertex normal vector:

First, we need to understand a few concepts, planar normals (two on the plane are not parallel. Non-collinear vector fork multiplication), vertex normal vector (the sum of the normal vectors of all triangles with this point as the vertex).

Then we are able to get two vectors through three vertices, and two vector forks multiply to obtain the plane normal vector. (Normalization of planar normal vectors)

Then, the sum of all planar normal vectors of each vertex is counted. (vertex normal vector is normalized)


Bunny Data File Download link

Bunny data includes vertex data and vertex vector data links

The first connection is bunny some data model, the second is a bunny vertex data model and calculated vertex normal vector data.

To calculate, we can use vertex data vertex normals to compare the normals of vertices, then, and file, write your own calculations, verify that vertex normal program is correct or not.

Solving the normal problem of OpenGL compute vertices

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.