// Spinning Cube!
inline void scene2(float scene_time)
{
  int i = scene_time / 25;

  tglClear(TGL_COLOR_BUFFER_BIT);

  float zoom = 0;
  if(scene_time > 5000)
    zoom = 0.5*sin((float)(i-20)/10.0);
    
  float rot_speed = 1.0;
  if(scene_time > 12000)
    rot_speed += (float)(scene_time - 12000) / 1500.0;

  tglMatrixMode(TGL_MODELVIEW);
  tglLoadIdentity();
  tglTranslatef(0, 0, -2.5+zoom);

  tglRotatef((float)(i % 360) * rot_speed, 0, 1, 0);
  tglRotatef((float)(i % 360) * rot_speed, 1, 1, 0);

  tglBegin(TGL_LINES);
  for(int p=0; p<8; ++p) {
    tglVertex3fv(cube[cubestrip1[p]]);
  }
  tglEnd();

  tglBegin(TGL_LINES);
  for(int p=0; p<8; ++p) {
    tglVertex3fv(cube[cubestrip2[p]]);
  }
  tglEnd();

  tglSwap();
}
// Zoom into the cube
inline void scene1(float scene_time)
{
  tglClear(TGL_COLOR_BUFFER_BIT);  

  float min_zoom = -10;
  float max_zoom = -2.5;
  float zoom = min_zoom + (max_zoom-min_zoom) * (float)scene_time/timeline[scene];

  tglMatrixMode(TGL_MODELVIEW);
  tglLoadIdentity();
  tglTranslatef(0, 0, zoom);

  tglBegin(TGL_LINES);
  for(int p=0; p<8; ++p) {
    tglVertex3fv(cube[cubestrip1[p]]);
  }
  tglEnd();

  tglBegin(TGL_LINES);
  for(int p=0; p<8; ++p) {
    tglVertex3fv(cube[cubestrip2[p]]);
  }
  tglEnd();

  tglSwap();
  
  delay(50);
}
Exemple #3
0
void GfxTinyGL::drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts) {
	tglNormal3fv(const_cast<float *>(face->_normal._coords));
	tglBegin(TGL_POLYGON);
	for (int i = 0; i < face->_numVertices; i++) {
		tglNormal3fv(vertNormals + 3 * face->_vertices[i]);

		if (face->_texVertices)
			tglTexCoord2fv(textureVerts + 2 * face->_texVertices[i]);

		tglVertex3fv(vertices + 3 * face->_vertices[i]);
	}
	tglEnd();
}