PDA

View Full Version : Divide the code



Aquileo
12-04-2003, 04:00 AM
I'd a function with lights and color material, and I've divided the function in 2, one function with lights and other with color material but now don't work. Why?

Thank you very much!

starman
12-04-2003, 04:02 AM
There's a problem with something. Fix it and it will work.

If you want a more meaningful answer, you'll have to post some code and give a better description of the problem.

Aquileo
12-04-2003, 06:13 AM
The code is:

void TMDIChild::SetupColorMaterial()
{
static const int x=0, y=1, z=2, alfa=3;
float colAmbiente[4];
float colDifusa[4];
float colEspecular[4];

float materiales[][13] = {{0.329412,0.223529,0.027451,1.0,0.780392,0.568627 ,0.113725,1.0,0.992157,0.941176,0.807843,1.0,27.89 74},...}};

// Y los cuerpos cojan color
if (bColorMateriales)
{
glEnable(GL_COLOR_MATERIAL);

THorma *Horma = Model->GetHorma();
int material = Horma->propiedadesHorma->iNumeroMaterial;
// Introducimos el gl_ambient
for (int veces=0; veces<4; veces++) {
colAmbiente[veces] = materiales[material][veces];
}

// Ahora el gl_diffuse
for (int veces=4; veces<8; veces++) {
colDifusa[veces-4] = materiales[material][veces];
}

// Ahora de gl_specular
for (int veces = 8; veces<12; veces++) {
colEspecular[veces-8] = materiales[material][veces];
}

// y el gl_shinness
float *brillo = &(materiales[material][12]);

glMaterialfv(GL_FRONT, GL_AMBIENT, colAmbiente);
glMaterialfv(GL_FRONT, GL_DIFFUSE, colDifusa);
glMaterialfv(GL_FRONT, GL_SPECULAR, colEspecular);
glMaterialfv(GL_FRONT, GL_SHININESS, brillo);
}
else
glDisable(GL_COLOR_MATERIAL);

}

and the code of light is:

void TMDIChild::SetupLighting()
{
GLfloat posCentro[3] = {-posicion_luz[0],-posicion_luz[1],-posicion_luz[2]};
GLfloat col_luz[] = {1.0, 1.0, 1.0, 1.0};

// Hagase la luz
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, posicion_luz);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, posCentro);
glLightfv(GL_LIGHT0, GL_AMBIENT_AND_DIFFUSE, col_luz);
}

And other problem is the light change coordinates for 'x' and 'z'

Thank you very much.
Aquileo