openframeworks / openframeworks/openFrameworks

ofMesh::icosahedron doesn't draw correctly

Open
#5,512 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core section-3D
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

Every other 3d mesh objects work well but icosahedron doesn't draw correctly.
I think it has to do with incorrect normals.

4f773e6de10807eb27aa2664f2c4a8a01f2bff44

Here's a link to the forum post
https://forum.openframeworks.cc/t/ofmesh-icosahedron-doesnt-draw-correctly/26301

And Here's my test code

in ofApp.h

#pragma once

#include "ofMain.h"

class ofApp : public ofBaseApp{
public:
    void setup();
    void update();
    void draw();

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

in ofApp.cpp

#include "ofApp.h"

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);
    ofRotateDeg(degree, 1, 1, 1);
    sphere.draw();
    ofPopMatrix();

    //draw icosphere
    ofPushMatrix();
    ofTranslate(ofGetWidth()*0.5, ofGetHeight()*0.5);
    ofDrawBitmapString("ICOSPHERE", -40, -130);
    ofRotateDeg(degree, 1, 1, 1);
    icosphere.draw();
    ofPopMatrix();

    //draw icosahedron
    ofPushMatrix();
    ofTranslate(ofGetWidth()*0.8, ofGetHeight()*0.5);
    ofDrawBitmapString("ICOSAHEDRON", -40, -130);
    ofRotateDeg(degree, 1, 1, 1);
    icosahedron.draw();
    ofPopMatrix();
    
    material.end();
    light.disable();
    ofDisableLighting();
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the reproduction in the provided ofApp.h and ofApp.cpp, comparing the sphere, icosphere, and icosahedron under the same lighting. Trace the icosahedron mesh generation and its normals in the openFrameworks source; done means the icosahedron draws correctly with lighting, like the other meshes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.