How to change the color of model
this is a triangular model....
default color:(light color + material Color) when tool doesn’t touch the surface...
color of only cutting part should change when tool touch
the surface of model...
and when tool move deeper and deeper
i want to change the color of
cutting part only...i tried but no success...
i need to apply color of those vertices that pushed due to
the tool sphere....but i want not any effect to whole other model
How can i do this......
here is the link of image.....for more detail....please open this URL...thanks
http://aycu01.webshots.com/image/40800/2001879489635176397_rs.jpg
I would use a static VBO that stores vertex, texture coord, normals
and another VBO that stores color (RGBA).
You update the color array when necessary.
If you aren't using shaders, call this
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
so that it uses the per vertex color instead of glMaterial
and another VBO that stores color (RGBA).
You update the color array when necessary.
If you aren't using shaders, call this
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
so that it uses the per vertex color instead of glMaterial
what do you mean i dont need to apply the material.....only need to apply a color array......but i am not using the VBO,.. currently i am using glVertex3d.....what you suggest like this
glColor3f(R, G, B);
glNormal3dv((double *)&VertNormals[v1]);
glVertex3dv((double *)&p_VERTICES[v1]);
glColor3f(R, G, B);
glNormal3dv((double *)&VertNormals[v2]);
glVertex3dv((double *)&p_VERTICES[v2]);
glColor3f(R, G, B);
glNormal3dv((double *)&VertNormals[v3]);
glVertex3dv((double *)&p_VERTICES[v3]);
but when i initialize the openGL function....what i need to do...means...do i apply light and as well as material of color...or not.......
please suggest me....
glColor3f(R, G, B);
glNormal3dv((double *)&VertNormals[v1]);
glVertex3dv((double *)&p_VERTICES[v1]);
glColor3f(R, G, B);
glNormal3dv((double *)&VertNormals[v2]);
glVertex3dv((double *)&p_VERTICES[v2]);
glColor3f(R, G, B);
glNormal3dv((double *)&VertNormals[v3]);
glVertex3dv((double *)&p_VERTICES[v3]);
but when i initialize the openGL function....what i need to do...means...do i apply light and as well as material of color...or not.......
please suggest me....
If you want to use glMaterial, then you can. Just replace the calls to glColor with glMaterial. It is legal to call glMaterial inside glBegin and glEnd.
do you mean like following code.....
then what kind of initializing.......is there any need to initialize with material......or only initialize with apply light...
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambiMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specMat);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glNormal3dv((double *)&VertNormals[v1]);
glVertex3dv((double *)&p_VERTICES[v1]);
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambiMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specMat);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glNormal3dv((double *)&VertNormals[v2]);
glVertex3dv((double *)&p_VERTICES[v2]);
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambiMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specMat);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glNormal3dv((double *)&VertNormals[v3]);
glVertex3dv((double *)&p_VERTICES[v3]);
then what kind of initializing.......is there any need to initialize with material......or only initialize with apply light...
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambiMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specMat);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glNormal3dv((double *)&VertNormals[v1]);
glVertex3dv((double *)&p_VERTICES[v1]);
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambiMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specMat);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glNormal3dv((double *)&VertNormals[v2]);
glVertex3dv((double *)&p_VERTICES[v2]);
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambiMat);
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specMat);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shine);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glNormal3dv((double *)&VertNormals[v3]);
glVertex3dv((double *)&p_VERTICES[v3]);
If you call glEnable(GL_COLOR_MATERIAL);
then that means you want GL to use glColor as your material.
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
is used to tell it that glColor is for changing the material diffuse.
The alternative is not to do the above and instead use glMaterial.
PS : it's better to use float instead of double. GPUs don't support double yet.
then that means you want GL to use glColor as your material.
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
is used to tell it that glColor is for changing the material diffuse.
The alternative is not to do the above and instead use glMaterial.
PS : it's better to use float instead of double. GPUs don't support double yet.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement