What is MeshBuilder is doing in PlayN

67 Views Asked by At

I happened to see the the following code develped by PlayN framework. I am not getting what the following piece of code doing.

meshBuilder.begin(MeshBuilder.Mode.TRIANGLE_FAN, MeshBuilder.OPTION_COLOR);
    meshBuilder.color3f(color[0] * 0.2f, color[1] * 0.2f, color[2] * 0.2f);
    int i;
    for (i = 0; i < 3; i++) {
      DynamicLight.v[i] = origin[i] - GlState.vpn[i] * rad;
    }

    meshBuilder.vertex3f(DynamicLight.v[0], DynamicLight.v[1], DynamicLight.v[2]);
    meshBuilder.color3f(0, 0, 0);

What type of mesh it is building in the above code. I referred the API, but did not get much. MeshBuilder.java in PlayN

I just compared the MeshBulder in libgdx where it can be used to create meshes (cirlce, arrow,etc).

Any idea?

Thanks

1

There are 1 best solutions below

0
Daniel Gerson On

So Stephan Haustein used PlayN to port over Quake 2! Rather than rebuild the game it is simply easier to map OpenGL 1.1 commands to OpenGL 2.0. This is what the linked code is used for. It allows you to point code that is using glBegin and glEnd in a largely java codebase to be able to ultimately run in the browser or maybe on android. If you're more familiar with OpenGL2.0 ES, then you can take a history lesson and see how it used to be done here.

http://en.wikibooks.org/wiki/OpenGL_Programming/GLStart/Tut3

This doesn't answer your question directly, but it gives you the tools to answer it yourself.

Edit:

Since you haven't marked my answer as correct yet, the actual shape it draws is only the first vertex of what perhaps is a triangle, but could be a greater shape. See http://en.wikipedia.org/wiki/Triangle_fan. As it is it draws nothing. The colour it prepares to draw is very dark with only 20% luminosity, can't tell what as color is a variable.