GLGraphics and objLoader
in
Contributed Library Questions
•
2 years ago
I try to load a model with saito .objLoader and want to push it into a GLModel for performance reasons. Sadly I don’t get the vertices connected in the right way. Any ideas what I can do? The model is exported from Photoshop. The screenshots show objloader on the left and glmodel on the right.
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import saito.objloader.*;
- OBJModel model;
- GLModel glmodel;
- void setup() {
- size(300, 200, GLConstants.GLGRAPHICS);
- model = new OBJModel(this, "Model.obj", "relative", POLYGON);
- model.enableDebug();
- glmodel = new GLModel(this, model.getVertexCount(), POLYGON, GLModel.STATIC);
- glmodel.beginUpdateVertices();
- for(int i = 0; i < model.getVertexCount(); i++){
- PVector v = model.getVertex(i);
- glmodel.updateVertex(i, v.x, v.y, v.z);
- }
- glmodel.endUpdateVertices();
- glmodel.initColors();
- glmodel.setColors(255, 100);
- noStroke();
- }
- void draw() {
- background(0);
- ambient(250, 250, 250);
- pointLight(255, 255, 255, 500, height/2, 400);
- // draw objloader model
- model.draw();
- translate(50, 0, 0);
- // draw glmodel
- rotateX((float) mouseX / 100);
- translate(30, 0, 0);
- GLGraphics renderer = (GLGraphics)g;
- renderer.beginGL();
- renderer.model(glmodel);
- renderer.endGL();
- }
1