Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

ofMaterial and ofLight

$
0
0

Hi,
I'm trying to make a red box using ofLight, ofMaterial and ofBoxPrimitive. Here's my
ofApp::setup:

ofSetSmoothLighting(true);

ofEnableDepthTest() 


box.setResolution(300, 300, 300);

box.setPosition(ofVec3f(ofGetWidth()/2,ofGetHeight()/2,0));
box.set(500);

easyCam.setVFlip(false);
easyCam.setPosition(ofGetWidth()/2, ofGetHeight()/2,700);
easyCam.setTarget(box.getPosition());
easyCam.setDistance(1400);

light.setSpotlight();
light.setSpotlightCutOff(50);

light.setDiffuseColor(ofColor::white);

light.setPosition(ofGetWidth()/2, 0, 100);
light.lookAt(box.getPosition());

material.setDiffuseColor(ofColor::red);
material.setAmbientColor(ofColor::red);
material.setSpecularColor(ofColor::white);

material.setShininess(128);

and here is my ofApp::draw();

ofBackground(0);

easyCam.begin();

light.enable();

material.begin();

box.draw();

material.end();
light.disable();

easyCam.end();

from what I understand, I should have a red box with a strong white spot. But all I get is a white box. If I change the color of the light, the box becomes exactly the same color as the light, always.

What am I doing wrong?


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>