Material Color - changing the difuse color

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? :smiley:

I intend to change the alpha also, can i do it with ofSetColor(ofColor(255,x));?

For the untextured side (right side i think): you assign white specular color and you see white highlights. Did you try another color?

For the textured side (left side i think): you didn’t put a light against this side and it is unlighted. Anyway it still looks like having a diffuse color.

Everything looks ok. I think your exact problem (what you can not obtain) is not clear.

BTW, just a side note, these 2 lines look suspicious to me:

light.setPosition(ofPoint(0,0, -1000));
light.lookAt( ofPoint(-1000,0,0));

Is your topview something like that?

Textured side is the front face od the box, all of the other faces are textureless.

What you see there is not the front view, its the right side view (easycam).

What i want is to give thefaces color.
Front face, a tint color for the texture, i think ill be able to do that with setcolor.
Other faces, a difuse color, and eventualy difuse with alpha.

Thanks

I am not sure about that because I can not test now, but probably ofSetColor(255); makes everything white including diffuse color. You can try mat.setAmbientColor(255); instead of ofSetColor(255);

And if it works, then you can try mat.setDiffuseColor(ofColor(r, g, b, a)); for diffuse color with alpha.

fixed it removing the diffuse color, and doing ofsetcolor(tint/boxcolor, 255*alpha).

thanks