ofMesh::icosahedron doesn't draw correctly

Hi, I just found out ofMesh::icosahedron doesn’t draw correctly.
Every other 3d mesh objects work correctly but not this one.
I think it has problems with its normals.

Here’s my code below.

in ofApp.h

ofLight light;
ofMaterial material;
ofMesh sphere;
ofMesh icosphere;
ofMesh icosahedron;
float degree;

in ofApp.cpp

//--------------------------------------------------------------
void ofApp::setup(){
 
    ofSetBackgroundColor(10, 10, 10);
    ofEnableDepthTest();
    
    //directional light
    light.setDirectional();
    light.setSpecularColor(ofColor(255));
    light.setDiffuseColor(ofColor(255));
    light.setAmbientColor(ofColor(100));
    light.setOrientation(ofVec3f(0,180,0));
    
    //material
    material.setShininess(120);
    material.setSpecularColor(ofColor(0));
    material.setDiffuseColor(ofColor(200));
    material.setAmbientColor(ofColor(0));
    
    //mesh
    sphere = ofMesh::sphere(100);
    icosphere = ofMesh::icosphere(100);
    icosahedron = ofMesh::icosahedron(100);
}

//--------------------------------------------------------------
void ofApp::update(){
 
    degree++;
}

//--------------------------------------------------------------
void ofApp::draw(){
    
    ofEnableLighting();
    light.enable();
    material.begin();
    
    //draw sphere
    ofPushMatrix();
    ofTranslate(ofGetWidth()*0.2, ofGetHeight()*0.5);
    ofDrawBitmapString("SPHERE", -35, -130);
    ofRotate(degree, 1, 1, 1);
    sphere.draw();
    ofPopMatrix();
    
    //draw icosphere
    ofPushMatrix();
    ofTranslate(ofGetWidth()*0.5, ofGetHeight()*0.5);
    ofDrawBitmapString("ICOSPHERE", -40, -130);
    ofRotate(degree, 1, 1, 1);
    icosphere.draw();
    ofPopMatrix();
    
    //draw icosahedron
    ofPushMatrix();
    ofTranslate(ofGetWidth()*0.8, ofGetHeight()*0.5);
    ofDrawBitmapString("ICOSAHEDRON", -40, -130);
    ofRotate(degree, 1, 1, 1);
    icosahedron.draw();
    ofPopMatrix();
    
    material.end();
    light.disable();
    ofDisableLighting()
}

that’s probably an issue with the normals not being correct, can you open an issue in github?

There’s a comment in the code that says

// NO texture coords or normals
// use ofGetIcoSphere(radius, 0) // 0 iterations will return Icosahedron //

If I remember right, by using ofGetIcoSphere(radius, 0) you get a smoothed icosahedron, which might not be what you want (the smoothness) with regular polyhedrons.

So, It doesn’t have texCoords and normals?
Do you know why only icosahedron doesn’t have them?

Okay, I will try that. Thanks!

By looking at https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/3d/ofMesh.inl#L1970 it seems like that code comes from another project (ogre-procedural) which maybe did not have that yet implemented.

The latest version of that library is at https://bitbucket.org/transporter/ogre-procedural/src/ca6eb3363a53c2b53c055db5ce68c1d35daab0d5/library/src/?at=default

1 Like

it seems this is just missing, it should have normals and uvs as other primitives if you could open an issue that would be useful. since a sphere has smooth normals it won’t really look as an icosahedron

1 Like

Thanks @arturo

I opened an issue :slight_smile:

https://github.com/openframeworks/openFrameworks/issues/5512