c - How do I subdivide a triangle in three dimensions? -


I have a function which takes 3 digits and I will use these points to draw a triangle, like I The glVertex was using the function.

But since I want to make this triangle a texture while avoiding perspective distortion, I have to divide it and use it for computation of texture mapping and normals.

I can not understand how to do this for a managed rectangle, spherical, cylinder and taurus, but for me, how to understand the triangle, for my life.

I have found every example of triangle mapping only for 2D space and by using glVertex, with predefined digits.

In the form of a rectangle, the code I am using is:

  zero rectangle: draw float tex, float texts) {float x 1, X2, y1, y2; X1 = v.at (0); X2 = V.Att (2); Y1 = v.at (1); Y2 = v.at (3); // glRectf (x1, y1, x2, y2); Int _numDivisions = 100; Float _xDim = abs (x2 - x1); Float_yadim = ab (y2 - y1); Float textsmulti, taximultity; Tech Multitas = _xDim / texs; // / _xDim; Texmaltity = _yDim / texT; // / _yDim; GlPushMatrix (); GlTranslatef (x1, y1, 0); glRotatef (-90.0,1,0,0); GlScalef (_xDim * (1.0 / (Double) _numDivisions), 1, _yDim * (1.0 / (Double) _numDivisions)); GlNormal3f (0, -1.0); For (int bx = 0; bx & lt; _numdivisions; bx ++) {glBegin (GL_TRIANGLE_STRIP); GlTexCoord2f ((bx * 1.0 / _numDivisions) * taximultity, 0.0 * technocultics); GlVertex3f (bx + x1, 0, 0 + y1); (Int bez = 0; bg; ln; _numDivisions; bz ++) {glTexCoord2f (bx + 1) * 1.0 / _numDivisions) * Technistics, (bees * 1.0 / _num division) * Texmultity); GlVertex3f ((bx + 1) + x1, 0, bz + y1); GlTexCoord2f (((bx + 1) * 1.0 / _num division) * Technistics, ((bez + 1) * 1.0 / _num division) * Techniques Multititi); GlVertex3f (bx + x 1, 0, (bez + 1) + y1); } GlTexCoord2f ((bx + 1) * 1.0 / _num division) * Techniques, 1.0 * TechnicTTY); GlVertex3d ((bx + 1 + + x1, 0, _numDivisions + y1); glEnd (); } GlPopMatrix (); }   

And it's getting me It is very easy, because it is in 2D space. I was aiming for the same kind of argument, but for a 3D space triangle.

But I can not understand the required calculation for the digits in the triangle in the 3D space.

For example:

P1-> (0,0,1); P2-> (1,0,0); P3- & gt; (0,1,0);

My best idea so far is to draw it originally with P1 in 2D space, I can just make every point in the P1-> P2 line, concentrate on P3, and Then calculate the angle of rotating angle according to the X-axis and then calculate the angle for rotation in the y-axis, but is this the best way to actually go?

Edit:

Being benevolent, there can be a way to re-write the question: "How can I divide a normal triangle in three dimensions" ?

Since the objective is to obtain an algorithm that creates a triangle in the triangle segment (triangle strip or tractor bar) in 3D space, I can use the corner for texture mapping and general calculation. As suggested in the comments, you can slice the triangle equal to a triangle

With some fancy ASCII art:

  / | / | ---- / | / | / | / | ------- / | / | / | / | / | / | ---------- / | / | / | / | / | / | / | / | -------------   

In this triangle strips, moving down from the top down, we will have 4 strips. The triangles of strips for 4 strips are:

  1, 3, 5, 7   

or 2 * i + 1 For strip i , from i to 0 to n - 1 .

To calculate the required verticals for the subdivision, you can calculate the digits on the bottom edge of the linear interpolation between the two edges. The only thing for the edges of the edges of the edges in diagram is diagonally. Then with each bar, you again make a linear interpolation between these two points, in the strip i in i on the left side of the pieces, and in on the right Split i + 1 pieces.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -