0

I am trying to draw a loaded .obj file with VB .NET, but without any success.

Here is my test.obj file, it's a simple cube:

    # test.obj
#

g cube

v  0.0  0.0  0.0
v  0.0  0.0  1.0
v  0.0  1.0  0.0
v  0.0  1.0  1.0
v  1.0  0.0  0.0
v  1.0  0.0  1.0
v  1.0  1.0  0.0
v  1.0  1.0  1.0

vn  0.0  0.0  1.0
vn  0.0  0.0 -1.0
vn  0.0  1.0  0.0
vn  0.0 -1.0  0.0
vn  1.0  0.0  0.0
vn -1.0  0.0  0.0

f  1//2  7//2  5//2
f  1//2  3//2  7//2 
f  1//6  4//6  3//6 
f  1//6  2//6  4//6 
f  3//3  8//3  7//3 
f  3//3  4//3  8//3 
f  5//5  7//5  8//5 
f  5//5  8//5  6//5 
f  1//4  5//4  6//4 
f  1//4  6//4  2//4 
f  2//1  6//1  8//1 
f  2//1  8//1  4//1 

I use the following VB .NET code to load the file with the help of Meshomatic:

    Dim m As New Meshomatic.ObjLoader
    Dim md As Meshomatic.MeshData
    md = m.LoadFile("test.obj")

But then I don't know how to draw the cube.

Usually I use the following code to draw a triangle ( without any problem ):

    GL.Begin(BeginMode.Triangles)

        GL.Color3(Color.Yellow)

        GL.Vertex3(0, 10, 0)

        GL.Vertex3(-10, -10, 0)

        GL.Vertex3(10, -10, 0)

    GL.End()

As there is no specific manual to use OpenTk and Meshomatic with VB .Net, I am quite lost.

user3666197
  • 1
  • 6
  • 50
  • 92
Erwan
  • 1,055
  • 1
  • 12
  • 26

1 Answers1

0

First, OpenTK mirrors the OpenGL API 1:1, you can google for openGL tutorials and just adapt the c / c++ code to c#

Second, have a look at http://www.opentk.com/doc/graphics

This tutorial doesn't use glBegin / glEnd, as i would recommend it, those functions are legacy profile and cause significantly more overhead and synchronization.

Vengarioth
  • 684
  • 5
  • 13