Home Game Development opengl es – Convert Wavefront (OBJ) faces into triangles for drawing with OpenGLES

opengl es – Convert Wavefront (OBJ) faces into triangles for drawing with OpenGLES

0
opengl es – Convert Wavefront (OBJ) faces into triangles for drawing with OpenGLES

[ad_1]

I wrote a easy Wavefront parser in C++ that masses v, vn, vt and f into std::vectors.

Essentially the most f traces in my .obj file comprise 4 triples like this:

    f 601/10518/265 10522/10517/265 10521/10516/265 602/10515/265

clearly, if I’ve 4 triples I create two triangles.

However I don’t perceive properly sufficient what to do with the final f line in my .obj file that accommodates about 700 triples:

    f 3229/3228/1 3456/3227/1 3455/3280/1 3508/3279/1 3507/3332/1 3560/3331/1 3559/3384/1 3612/3383/1 3611/3436/1 3664/3435/1 3663/3488/1 3716/3487/1 3715/3540/1 3768/3539/1 3767/3592/1 3820/3591/1 3819/3644/1 3872/3643/1 3871/3696/1 3924/3695/1 ....

From wikipedia: OBJ recordsdata additionally help free-form geometry which use curves and surfaces to outline objects, akin to NURBS surfaces.

Is that this line a some type of this NURBS surfaces? If sure what lib can I exploit for them?

How you can convert it to triangles? (For drawing with OpenGLES).

Can I exploit GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN?

Beneath I offered a trivial airplane instance that I load efficiently:

    # Blender 3.6.5
    # www.blender.org
    mtllib airplane.mtl
    o Aircraft
    v -1.000000 0.000000 1.000000
    v 1.000000 0.000000 1.000000
    v -1.000000 0.000000 -1.000000
    v 1.000000 0.000000 -1.000000
    vn -0.0000 1.0000 -0.0000
    vt 0.000000 0.000000
    vt 1.000000 0.000000
    vt 1.000000 1.000000
    vt 0.000000 1.000000
    s 0
    f 1/1/1 2/2/1 4/3/1 3/4/1

however my real-life mesh is just too lengthy so as to add there, I exported it in Blender from this:

enter image description here

[ad_2]