Hi guys, I’m having some troubles setting material colors.
so i have this box, with one side textured.
I want them to have some specular highlights, so i’m trying to use this material.
void BoxSlider::draw()
{
ofMaterial mat1;
for(int i=0; i<mBoxes.size(); i++)
{
//mBoxes[i].box.draw(mImg.getTextureReference(),mBoxes[i].rect,ofColor(255/(i+1)),ofColor(255/(i+1)),mBoxes[i].pos,ofVec3f(0));
mat1.setShininess(128);
mat1.setSpecularColor(255);
//draw with material
mBoxes[i].box.draw(mImg.getTextureReference(),mBoxes[i].rect,mat1,ofColor(255/(i+1)),ofColor(255/(i+1)),mBoxes[i].pos,ofVec3f(0));
}
}
so here I draw the boxes, the comented version is without the material.
The highlights seem there, but i have no color.
void FrontFacedBox::draw(ofTexture& tex,ofRectangle rect,ofMaterial mat, ofColor boxColor, ofColor tintColor, ofVec3f pos, ofVec3f rot)
{
//redo frontface coords for the rect
frontFace.clearTexCoords();
frontFace.addTexCoord(ofVec2f(rect.x,rect.y));
frontFace.addTexCoord(ofVec2f(rect.x+rect.width,rect.y));
frontFace.addTexCoord(ofVec2f(rect.x+rect.width,rect.y+rect.height));
frontFace.addTexCoord(ofVec2f(rect.x,rect.y+rect.height));
ofPushMatrix();
ofRotateX(rot.x);
ofRotateY(rot.y);
ofRotateZ(rot.z);
ofTranslate(pos);
mat.setDiffuseColor(boxColor);
mat.begin();
ofSetColor(255);
bodyBox.draw();
mat.end();
mat.setDiffuseColor(tintColor);
mat.begin();
tex.bind();
ofSetColor(255);
frontFace.draw();
tex.unbind();
mat.end();
ofPopMatrix();
}
here is the box draw code, I dont really know what’s happening, and i think i dont have any pus/popstyles lost in the way.
The front face does not seem to be highlighted correctly, but i think the normal vectors are ok.
here is the result:
http://imgur.com/zafLMVR
almost forgot my light is this:
light.setPosition(ofPoint(0,0, -1000));
light.lookAt( ofPoint(-1000,0,0));
light.enable();
ofEnableLighting();
ecam.begin();
ofPushMatrix();
ofTranslate(-ofGetWidth()/2, ofGetHeight()/2,-200);
bslider.draw();//the box container and manager
ofPopMatrix();
ofPopMatrix();
ecam.end();
ofDisableLighting();
any tips?on this and on materials in general? like some easy eyecandy?
I intend to change the alpha also, can i do it with ofSetColor(ofColor(255,x));?