Quantcast
Viewing all articles
Browse latest Browse all 40524

Problem with lighting and 3d shapes in openframeworks 9

Hi @lorenzo_p !

You can use ofSetGlobalAmbientColor. Mind it passes an ofFloatColor.

For more control, you can use an ofMaterial, like so (there are more parameters, it's just a quick example):

// Update
material.setEmissiveColor(ofFloatColor(sin(ofGetElapsedTimef()), 0, 0));
material.setDiffuseColor(ofFloatColor(0, 0, (float)mouseX / ofGetWidth()));
material.setSpecularColor(ofFloatColor(0, (float)mouseY / ofGetHeight(), 0));

// Draw
ofBackground(ofColor::gray);
ofEnableLighting();

material.begin();
mPointLight.enable();

ofDrawSphere(ofGetWidth()/2, ofGetHeight()/2, -50, 105);

material.end();
mPointLight.disable();

ofDisableLighting();

Never the less, ofSetColor() should work. Maybe @arturo knows best.


Viewing all articles
Browse latest Browse all 40524

Trending Articles