@cuinjune wrote:
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() }
Posts: 7
Participants: 3
