Tuesday, May 08, 2007



Manejando las luces....

//toroide.
#include
#include
#include "./glut.h"

#define PI 3.1415927f
#define tol 0.0001f

GLuint base, sphereList, sphereFacetedList, sphereLinesList;
float angleX = 0.0f;
float angleY = 0.0f;
float angleZ = 0.0f;
float transZ = -10.0f;

GLuint modelIndex;

GLfloat mat_specular[] = {1.0,1.0,1.0,1.0};
GLfloat mat_diffuse[] = {0.5,0.5,0.5,1.0};
GLfloat light_pos[] = {1.0,1.0,1.0,0.0};


void checkIntegrity(float res[3], float thresh)
{
if( fabs(res[0]) < norm =" (float)sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);" norm =" 1.0f;" norm =" getNorm(res);" i =" 0;" norm =" 1.0f;" norm =" getNorm(res);" offset="radius+2;" theta =" 2.0f*PI*(float)(span+0)/(float)slices;//i="span" phi =" 2.0f*PI*(float)(slice+0)/(float)spans;//j="slice" span =" 0," slice =" 0;" glindex =" ++base;" span =" 0;" slice =" 0;" span =" 0;" slice =" -slices">>1; slice <>>1; slice++ )
{
spherePoint(v1, radius, slice , slices, span , spans);
spherePoint(v2, radius, slice+1, slices, span , spans);
spherePoint(v3, radius, slice+1, slices, span+1, spans);
spherePoint(v4, radius, slice , slices, span+1, spans);

normal[0] = v1[0];
normal[1] = v1[1];
normal[2] = v1[2];
normalize(normal);
glNormal3fv(normal);
glVertex3fv(v1);

normal[0] = v2[0]; normal[1] = v2[1]; normal[2] = v2[2];
normalize(normal);
glNormal3fv(normal);
glVertex3fv(v2);

normal[0] = v3[0]; normal[1] = v3[1]; normal[2] = v3[2];
normalize(normal);
glNormal3fv(normal);
glVertex3fv(v3);

normal[0] = v4[0]; normal[1] = v4[1]; normal[2] = v4[2];
normalize(normal);
glNormal3fv(normal);
glVertex3fv(v4);





}
}
glEnd();
}
break;
case 2:/// Wireframe
{

glBegin(GL_LINES);
for( span = -spans/2; span < slice =" -slices/2;" base =" 0;" spherelist =" initSphere(1.0," spherefacetedlist =" initSphere(1.0," spherelineslist =" initSphere(1.0,32," modelindex =" sphereList;" modelindex =" sphereList;" modelindex =" sphereFacetedList;" modelindex =" sphereLinesList;">

No comments: