openframeworks / openframeworks/openFrameworks
ofMesh::icosahedron doesn't draw correctly
Nobody has claimed this yet.
- 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.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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