Cannot load model

I’ve a problem loading an external model to OF. I’ve tried first loading the mesh using a .ply file:

//in the header
ofVboMesh mesh;
//in the setup call
mesh.load('example.ply');

//in the draw call
mesh.draw();

And as error I’ve:

[ error ] ofMesh: load(): 2367:face not a triangle
[ error ] ofMesh: load(): "4 0 1 2 3"

I’ve then making another attempt exporting the file as 3ds and loading it with ofxAssimpLoader:

// in the header
#include "ofxAssimpModelLoader.h"
ofxAssimpModelLoader trunk;


void ofApp::setup(){
  trunk.loadModel("trunk.3ds", 20);
}

void ofApp::draw(){
  trunk.drawFaces();
}

And this is the error:

[ error ] ofShader: setupShaderFromSource(): GL_VERTEX_SHADER shader failed to compile
[ error ] ofShader: GL_VERTEX_SHADER shader reports:
ERROR: 0:14: '' : syntax error: incorrect preprocessor directive
ERROR: 0:14: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline
ERROR: 0:40: '' : syntax error: incorrect preprocessor directive
ERROR: 0:40: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline

[ error ] ofShader: GL_VERTEX_SHADER, offending line 14 :
	   12	OUT vec3 v_eyePosition;
	   13	OUT vec3 v_worldPosition;
	   14	#if HAS_COLOR
	   15	OUT vec4 v_color;
	   16	#endif

Im on OSX El Capitan, and I’m using the programmable pipeline, this is mt main call:

int main( ){
    ofGLWindowSettings settings;
    settings.setGLVersion(3, 2);  // Programmable pipeline
    settings.width = 1024;
    settings.height = 1024;
    ofCreateWindow(settings);
    if(!ofGLCheckExtension("GL_ARB_geometry_shader4") && !ofGLCheckExtension("GL_EXT_geometry_shader4") && !ofIsGLProgrammableRenderer()){
        ofLogFatalError() << "geometry shaders not supported on this graphics card";
        return 1;
    }
}

When using OF 0.9.8 and the ofxAssimpModelLoader, the app crash in the method load model of the file addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp

Seems that you are defining faces as a pentagon, you should make sure the faces are only composed by triangles (method known as triangulate in Blender)

Many thanks @Hennio it worked (or, at least I can load a mesh, I’m still not able to get the ofxAssimpLoader working, but loading the mesh is enough for me)
If someone is having the same problem, when exporting curves designed with the bezier tool from blender

  1. press alt + c and export from curve to mesh. Otherwise you will not see the modfiers tab
  2. go to the modifiers tab and choose triangulate https://www.blender.org/manual/modeling/modifiers/introduction.html)

Also, I’ve another problem, using of 0.9.8 I’ve to convert some method that were using the glm syntax to the old ofVec3f, do you know from which version the glm syntax is the standard one? I’m getting a bit confused, I’ve used only nigthly releases recently (where the glm syntax was the default) but I’ve to go back to the stable 0.9.8 because of a bug.

the first error you posted is just a shader compiler error, has nothing to do with assimp, you need to review your shader since it seems you have some syntax error there.

not sure what’s going on with the seg fault in assimp on 0.9.8 can you open an issue with the exact line where it’s crashing and perhaps the smallest possible code that reproduces the error?

and glm, hasn’t been officially released yet it’s only present in the nightly builds and github whic will become 0.10 at some point

Hey Arturo, sorry, too many things in my previous post.

The compile shader error hapens when using ofMaterial, not with a custom shader. it is the same as the issue opened here: https://github.com/openframeworks/openFrameworks/issues/5383 and it happens ONLY with nightly builds (the last one).

Regarding the error on Assimp, i will open the issue this evening.

Regarding glm, I see, i was not aware of this.

ah ok, there’s been some changes in ofMaterial in the nightly builds. this is in osx right?

Yep, osx and El Capitan, if you want I can try also on Linux, but this evening

it should be ok in linux since i’ve used it there and windows after those changes but thanks!

@arturo I can not reproduce the ofxAssimpLoader bug anymore, neither in 0.9.8 nor in the nightly(20161107), both works. I think it is not a bug but some mess in the model that I was exporting.