Hi, here's opengl shape code, hope it helps:
cone:
Code: Select all
/*
This file was produced by Deep Exploration Plugin: CPP Export filter.
Deep Exploration
Copyright (c) 1999-2003 Right Hemisphere, Inc
WWW http://www.righthemisphere.com/dexp.htm
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>
struct sample_MATERIAL{
GLfloat ambient[3];
GLfloat diffuse[3];
GLfloat specular[3];
GLfloat emission[3];
GLfloat alpha;
GLfloat phExp;
int texture;
};
static sample_MATERIAL materials [1] = {
{{0.3f,0.3f,0.3f}, {0.7f,0.7f,0.7f}, {0.752941f,0.752941f,0.752941f}, {0.0f,0.0f,0.0f}, 1.0f,8.0f,-1} //DefaultLib.Scene_Material
};
// 26 Verticies
// 20 Texture Coordinates
// 10 Normals
// 48 Triangles
static BYTE face_indicies[48][9] = {
// Object #-1
{5,2,0 ,0,0,0 ,0,1,2 }, {2,6,3 ,0,0,0 ,1,0,1 }, {2,5,6 ,0,0,0 ,1,0,0 },
{3,7,4 ,1,2,1 ,1,3,4 }, {3,6,7 ,1,2,2 ,1,0,3 }, {4,7,1 ,1,2,3 ,4,3,5 },
{8,5,0 ,0,0,0 ,6,0,2 }, {5,9,6 ,0,0,0 ,0,6,0 }, {5,8,9 ,0,0,0 ,0,6,6 },
{6,10,7 ,2,4,2 ,0,7,3 }, {6,9,10 ,2,4,4 ,0,6,7 }, {7,10,1 ,2,4,3 ,3,7,5 },
{11,8,0 ,0,0,0 ,8,6,9 }, {8,12,9 ,0,0,0 ,6,8,6 }, {8,11,12 ,0,0,0 ,6,8,8 },
{9,13,10 ,4,5,4 ,6,10,7 }, {9,12,13 ,4,5,5 ,6,8,10 }, {10,13,1 ,4,5,3 ,7,10,11 },
{14,11,0 ,0,0,0 ,12,8,9 }, {11,15,12 ,0,0,0 ,8,12,8 }, {11,14,15 ,0,0,0 ,8,12,12 },
{12,16,13 ,5,6,5 ,8,13,10 }, {12,15,16 ,5,6,6 ,8,12,13 }, {13,16,1 ,5,6,3 ,10,13,11 },
{17,14,0 ,0,0,0 ,14,12,9 }, {14,18,15 ,0,0,0 ,12,14,12 }, {14,17,18 ,0,0,0 ,12,14,14 },
{15,19,16 ,6,7,6 ,12,15,13 }, {15,18,19 ,6,7,7 ,12,14,15 }, {16,19,1 ,6,7,3 ,13,15,11 },
{20,17,0 ,0,0,0 ,9,14,9 }, {17,21,18 ,0,0,0 ,14,9,14 }, {17,20,21 ,0,0,0 ,14,9,9 },
{18,22,19 ,7,8,7 ,14,16,15 }, {18,21,22 ,7,8,8 ,14,9,16 }, {19,22,1 ,7,8,3 ,15,16,11 },
{23,20,0 ,0,0,0 ,17,2,2 }, {20,24,21 ,0,0,0 ,2,17,2 }, {20,23,24 ,0,0,0 ,2,17,17 },
{21,25,22 ,8,9,8 ,2,18,19 }, {21,24,25 ,8,9,9 ,2,17,18 }, {22,25,1 ,8,9,3 ,19,18,5 },
{2,23,0 ,0,0,0 ,1,17,2 }, {23,3,24 ,0,0,0 ,17,1,17 }, {23,2,3 ,0,0,0 ,17,1,1 },
{24,4,25 ,9,1,9 ,17,4,18 }, {24,3,4 ,9,1,1 ,17,1,4 }, {25,4,1 ,9,1,3 ,18,4,5 }
};
static GLfloat vertices [26][3] = {
{0.0f,-0.5f,0.0f},{0.0f,0.5f,0.0f},{-0.125f,-0.5f,0.0f},
{-0.25f,-0.5f,0.0f},{-0.125f,0.0f,0.0f},{-0.0883882f,-0.5f,0.0883882f},
{-0.176777f,-0.5f,0.176777f},{-0.0883882f,0.0f,0.0883882f},{0.0f,-0.5f,0.125f},
{0.0f,-0.5f,0.25f},{0.0f,0.0f,0.125f},{0.0883882f,-0.5f,0.0883882f},
{0.176777f,-0.5f,0.176777f},{0.0883882f,0.0f,0.0883882f},{0.125f,-0.5f,0.0f},
{0.25f,-0.5f,0.0f},{0.125f,0.0f,0.0f},{0.0883882f,-0.5f,-0.0883882f},
{0.176777f,-0.5f,-0.176777f},{0.0883882f,0.0f,-0.0883882f},{0.0f,-0.5f,-0.125f},
{0.0f,-0.5f,-0.25f},{0.0f,0.0f,-0.125f},{-0.0883882f,-0.5f,-0.0883882f},
{-0.176777f,-0.5f,-0.176777f},{-0.0883882f,0.0f,-0.0883882f}
};
static GLfloat normals [10][3] = {
{0.0f,-1.0f,0.0f},{-0.970142f,0.242536f,0.0f},{-0.685994f,0.242536f,0.685994f},
{0.0f,1.0f,0.0f},{0.0f,0.242536f,0.970142f},{0.685994f,0.242536f,0.685994f},
{0.970142f,0.242536f,0.0f},{0.685994f,0.242536f,-0.685994f},{0.0f,0.242536f,-0.970142f},
{-0.685994f,0.242536f,-0.685994f}
};
static GLfloat textures [20][2] = {
{0.375f,0.0f},{0.25f,0.0f},{0.0f,0.0f},
{0.375f,0.5f},{0.25f,0.5f},{0.0f,1.0f},
{0.5f,0.0f},{0.5f,0.5f},{0.625f,0.0f},
{1.0f,0.0f},{0.625f,0.5f},{1.0f,1.0f},
{0.75f,0.0f},{0.75f,0.5f},{0.875f,0.0f},
{0.875f,0.5f},{1.0f,0.5f},{0.125f,0.0f},
{0.125f,0.5f},{0.0f,0.5f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,48}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
GLfloat d[4];
d[0]=f[0];
d[1]=f[1];
d[2]=f[2];
d[3]=alpha;
glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
* SelectMaterial uses OpenGL commands to define facet colors.
*
* Returns:
* Nothing
*/
void SelectMaterial(int i)
{
//
// Define the reflective properties of the 3D Object faces.
//
glEnd();
GLfloat alpha=materials[i].alpha;
MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
MyMaterial (GL_EMISSION, materials[i].emission,alpha);
glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
glBegin(GL_TRIANGLES);
};
GLint Gen3DObjectList()
{
int i;
int j;
GLint lid=glGenLists(1);
int mcount=0;
int mindex=0;
glNewList(lid, GL_COMPILE);
glBegin (GL_TRIANGLES);
for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
{
if(!mcount)
{
SelectMaterial(material_ref[mindex][0]);
mcount=material_ref[mindex][1];
mindex++;
}
mcount--;
for(j=0;j<3;j++)
{
int vi=face_indicies[i][j];
int ni=face_indicies[i][j+3];//Normal index
int ti=face_indicies[i][j+6];//Texture index
glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
glTexCoord2f(textures[ti][0],textures[ti][1]);
glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
}
}
glEnd ();
glEndList();
return lid;
};
cube
Code: Select all
/*
This file was produced by Deep Exploration Plugin: CPP Export filter.
Deep Exploration
Copyright (c) 1999-2003 Right Hemisphere, Inc
WWW http://www.righthemisphere.com/dexp.htm
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>
struct sample_MATERIAL{
GLfloat ambient[3];
GLfloat diffuse[3];
GLfloat specular[3];
GLfloat emission[3];
GLfloat alpha;
GLfloat phExp;
int texture;
};
static sample_MATERIAL materials [1] = {
{{0.3f,0.3f,0.3f}, {0.7f,0.7f,0.7f}, {0.752941f,0.752941f,0.752941f}, {0.0f,0.0f,0.0f}, 1.0f,8.0f,-1} //DefaultLib.Scene_Material
};
// 8 Verticies
// 4 Texture Coordinates
// 6 Normals
// 12 Triangles
static BYTE face_indicies[12][9] = {
// Object #-1
{0,3,1 ,0,0,0 ,0,1,2 }, {0,2,3 ,0,0,0 ,0,3,1 }, {0,5,4 ,1,1,1 ,2,3,1 },
{0,1,5 ,1,1,1 ,2,0,3 }, {0,6,2 ,2,2,2 ,2,3,1 }, {0,4,6 ,2,2,2 ,2,0,3 },
{1,7,5 ,3,3,3 ,0,1,2 }, {1,3,7 ,3,3,3 ,0,3,1 }, {2,7,3 ,4,4,4 ,1,0,3 },
{2,6,7 ,4,4,4 ,1,2,0 }, {4,7,6 ,5,5,5 ,2,3,1 }, {4,5,7 ,5,5,5 ,2,0,3 }
};
static GLfloat vertices [8][3] = {
{-0.5f,-0.5f,-0.5f},{0.5f,-0.5f,-0.5f},{-0.5f,0.5f,-0.5f},
{0.5f,0.5f,-0.5f},{-0.5f,-0.5f,0.5f},{0.5f,-0.5f,0.5f},
{-0.5f,0.5f,0.5f},{0.5f,0.5f,0.5f}
};
static GLfloat normals [6][3] = {
{0.0f,0.0f,-1.0f},{0.0f,-1.0f,0.0f},{-1.0f,0.0f,0.0f},
{1.0f,0.0f,0.0f},{0.0f,1.0f,0.0f},{0.0f,0.0f,1.0f}
};
static GLfloat textures [4][2] = {
{1.0f,0.0f},{0.0f,1.0f},{0.0f,0.0f},
{1.0f,1.0f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,12}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
GLfloat d[4];
d[0]=f[0];
d[1]=f[1];
d[2]=f[2];
d[3]=alpha;
glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
* SelectMaterial uses OpenGL commands to define facet colors.
*
* Returns:
* Nothing
*/
void SelectMaterial(int i)
{
//
// Define the reflective properties of the 3D Object faces.
//
glEnd();
GLfloat alpha=materials[i].alpha;
MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
MyMaterial (GL_EMISSION, materials[i].emission,alpha);
glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
glBegin(GL_TRIANGLES);
};
GLint Gen3DObjectList()
{
int i;
int j;
GLint lid=glGenLists(1);
int mcount=0;
int mindex=0;
glNewList(lid, GL_COMPILE);
glBegin (GL_TRIANGLES);
for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
{
if(!mcount)
{
SelectMaterial(material_ref[mindex][0]);
mcount=material_ref[mindex][1];
mindex++;
}
mcount--;
for(j=0;j<3;j++)
{
int vi=face_indicies[i][j];
int ni=face_indicies[i][j+3];//Normal index
int ti=face_indicies[i][j+6];//Texture index
glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
glTexCoord2f(textures[ti][0],textures[ti][1]);
glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
}
}
glEnd ();
glEndList();
return lid;
};
cylinder
Code: Select all
/*
This file was produced by Deep Exploration Plugin: CPP Export filter.
Deep Exploration
Copyright (c) 1999-2003 Right Hemisphere, Inc
WWW http://www.righthemisphere.com/dexp.htm
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>
struct sample_MATERIAL{
GLfloat ambient[3];
GLfloat diffuse[3];
GLfloat specular[3];
GLfloat emission[3];
GLfloat alpha;
GLfloat phExp;
int texture;
};
static sample_MATERIAL materials [1] = {
{{0.3f,0.3f,0.3f}, {0.7f,0.7f,0.7f}, {0.752941f,0.752941f,0.752941f}, {0.0f,0.0f,0.0f}, 1.0f,8.0f,-1} //DefaultLib.Scene_Material
};
// 42 Verticies
// 27 Texture Coordinates
// 10 Normals
// 80 Triangles
static BYTE face_indicies[80][9] = {
// Object #-1
{7,2,0 ,0,0,0 ,0,1,2 }, {2,8,3 ,0,0,0 ,1,0,1 }, {2,7,8 ,0,0,0 ,1,0,0 },
{3,9,4 ,1,2,1 ,1,3,4 }, {3,8,9 ,1,2,2 ,1,0,3 }, {4,10,5 ,1,2,1 ,4,5,6 },
{4,9,10 ,1,2,2 ,4,3,5 }, {5,11,6 ,3,3,3 ,6,5,6 }, {5,10,11 ,3,3,3 ,6,5,5 },
{6,11,1 ,3,3,3 ,6,5,7 }, {12,7,0 ,0,0,0 ,8,0,2 }, {7,13,8 ,0,0,0 ,0,8,0 },
{7,12,13 ,0,0,0 ,0,8,8 }, {8,14,9 ,2,4,2 ,0,9,3 }, {8,13,14 ,2,4,4 ,0,8,9 },
{9,15,10 ,2,4,2 ,3,10,5 }, {9,14,15 ,2,4,4 ,3,9,10 }, {10,16,11 ,3,3,3 ,5,10,5 },
{10,15,16 ,3,3,3 ,5,10,10 }, {11,16,1 ,3,3,3 ,5,10,7 }, {17,12,0 ,0,0,0 ,11,8,12 },
{12,18,13 ,0,0,0 ,8,11,8 }, {12,17,18 ,0,0,0 ,8,11,11 }, {13,19,14 ,4,5,4 ,8,13,9 },
{13,18,19 ,4,5,5 ,8,11,13 }, {14,20,15 ,4,5,4 ,9,14,10 }, {14,19,20 ,4,5,5 ,9,13,14 },
{15,21,16 ,3,3,3 ,10,14,10 }, {15,20,21 ,3,3,3 ,10,14,14 }, {16,21,1 ,3,3,3 ,10,14,15 },
{22,17,0 ,0,0,0 ,16,11,12 }, {17,23,18 ,0,0,0 ,11,16,11 }, {17,22,23 ,0,0,0 ,11,16,16 },
{18,24,19 ,5,6,5 ,11,17,13 }, {18,23,24 ,5,6,6 ,11,16,17 }, {19,25,20 ,5,6,5 ,13,18,14 },
{19,24,25 ,5,6,6 ,13,17,18 }, {20,26,21 ,3,3,3 ,14,18,14 }, {20,25,26 ,3,3,3 ,14,18,18 },
{21,26,1 ,3,3,3 ,14,18,15 }, {27,22,0 ,0,0,0 ,19,16,12 }, {22,28,23 ,0,0,0 ,16,19,16 },
{22,27,28 ,0,0,0 ,16,19,19 }, {23,29,24 ,6,7,6 ,16,20,17 }, {23,28,29 ,6,7,7 ,16,19,20 },
{24,30,25 ,6,7,6 ,17,21,18 }, {24,29,30 ,6,7,7 ,17,20,21 }, {25,31,26 ,3,3,3 ,18,21,18 },
{25,30,31 ,3,3,3 ,18,21,21 }, {26,31,1 ,3,3,3 ,18,21,15 }, {32,27,0 ,0,0,0 ,12,19,12 },
{27,33,28 ,0,0,0 ,19,12,19 }, {27,32,33 ,0,0,0 ,19,12,12 }, {28,34,29 ,7,8,7 ,19,22,20 },
{28,33,34 ,7,8,8 ,19,12,22 }, {29,35,30 ,7,8,7 ,20,15,21 }, {29,34,35 ,7,8,8 ,20,22,15 },
{30,36,31 ,3,3,3 ,21,15,21 }, {30,35,36 ,3,3,3 ,21,15,15 }, {31,36,1 ,3,3,3 ,21,15,15 },
{37,32,0 ,0,0,0 ,23,2,2 }, {32,38,33 ,0,0,0 ,2,23,2 }, {32,37,38 ,0,0,0 ,2,23,23 },
{33,39,34 ,8,9,8 ,2,24,25 }, {33,38,39 ,8,9,9 ,2,23,24 }, {34,40,35 ,8,9,8 ,25,26,7 },
{34,39,40 ,8,9,9 ,25,24,26 }, {35,41,36 ,3,3,3 ,7,26,7 }, {35,40,41 ,3,3,3 ,7,26,26 },
{36,41,1 ,3,3,3 ,7,26,7 }, {2,37,0 ,0,0,0 ,1,23,2 }, {37,3,38 ,0,0,0 ,23,1,23 },
{37,2,3 ,0,0,0 ,23,1,1 }, {38,4,39 ,9,1,9 ,23,4,24 }, {38,3,4 ,9,1,1 ,23,1,4 },
{39,5,40 ,9,1,9 ,24,6,26 }, {39,4,5 ,9,1,1 ,24,4,6 }, {40,6,41 ,3,3,3 ,26,6,26 },
{40,5,6 ,3,3,3 ,26,6,6 }, {41,6,1 ,3,3,3 ,26,6,7 }
};
static GLfloat vertices [42][3] = {
{0.0f,-0.5f,0.0f},{0.0f,0.5f,0.0f},{-0.125f,-0.5f,0.0f},
{-0.25f,-0.5f,0.0f},{-0.25f,0.0f,0.0f},{-0.25f,0.5f,0.0f},
{-0.125f,0.5f,0.0f},{-0.0883882f,-0.5f,0.0883882f},{-0.176777f,-0.5f,0.176777f},
{-0.176777f,0.0f,0.176777f},{-0.176777f,0.5f,0.176777f},{-0.0883882f,0.5f,0.0883882f},
{0.0f,-0.5f,0.125f},{0.0f,-0.5f,0.25f},{0.0f,0.0f,0.25f},
{0.0f,0.5f,0.25f},{0.0f,0.5f,0.125f},{0.0883882f,-0.5f,0.0883882f},
{0.176777f,-0.5f,0.176777f},{0.176777f,0.0f,0.176777f},{0.176777f,0.5f,0.176777f},
{0.0883882f,0.5f,0.0883882f},{0.125f,-0.5f,0.0f},{0.25f,-0.5f,0.0f},
{0.25f,0.0f,0.0f},{0.25f,0.5f,0.0f},{0.125f,0.5f,0.0f},
{0.0883882f,-0.5f,-0.0883882f},{0.176777f,-0.5f,-0.176777f},{0.176777f,0.0f,-0.176777f},
{0.176777f,0.5f,-0.176777f},{0.0883882f,0.5f,-0.0883882f},{0.0f,-0.5f,-0.125f},
{0.0f,-0.5f,-0.25f},{0.0f,0.0f,-0.25f},{0.0f,0.5f,-0.25f},
{0.0f,0.5f,-0.125f},{-0.0883882f,-0.5f,-0.0883882f},{-0.176777f,-0.5f,-0.176777f},
{-0.176777f,0.0f,-0.176777f},{-0.176777f,0.5f,-0.176777f},{-0.0883882f,0.5f,-0.0883882f}
};
static GLfloat normals [10][3] = {
{0.0f,-1.0f,0.0f},{-1.0f,0.0f,0.0f},{-0.707107f,0.0f,0.707107f},
{0.0f,1.0f,0.0f},{0.0f,0.0f,1.0f},{0.707107f,0.0f,0.707107f},
{1.0f,0.0f,0.0f},{0.707107f,0.0f,-0.707107f},{0.0f,0.0f,-1.0f},
{-0.707107f,0.0f,-0.707107f}
};
static GLfloat textures [27][2] = {
{0.375f,0.0f},{0.25f,0.0f},{0.0f,0.0f},
{0.375f,0.5f},{0.25f,0.5f},{0.375f,1.0f},
{0.25f,1.0f},{0.0f,1.0f},{0.5f,0.0f},
{0.5f,0.5f},{0.5f,1.0f},{0.625f,0.0f},
{1.0f,0.0f},{0.625f,0.5f},{0.625f,1.0f},
{1.0f,1.0f},{0.75f,0.0f},{0.75f,0.5f},
{0.75f,1.0f},{0.875f,0.0f},{0.875f,0.5f},
{0.875f,1.0f},{1.0f,0.5f},{0.125f,0.0f},
{0.125f,0.5f},{0.0f,0.5f},{0.125f,1.0f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,80}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
GLfloat d[4];
d[0]=f[0];
d[1]=f[1];
d[2]=f[2];
d[3]=alpha;
glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
* SelectMaterial uses OpenGL commands to define facet colors.
*
* Returns:
* Nothing
*/
void SelectMaterial(int i)
{
//
// Define the reflective properties of the 3D Object faces.
//
glEnd();
GLfloat alpha=materials[i].alpha;
MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
MyMaterial (GL_EMISSION, materials[i].emission,alpha);
glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
glBegin(GL_TRIANGLES);
};
GLint Gen3DObjectList()
{
int i;
int j;
GLint lid=glGenLists(1);
int mcount=0;
int mindex=0;
glNewList(lid, GL_COMPILE);
glBegin (GL_TRIANGLES);
for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
{
if(!mcount)
{
SelectMaterial(material_ref[mindex][0]);
mcount=material_ref[mindex][1];
mindex++;
}
mcount--;
for(j=0;j<3;j++)
{
int vi=face_indicies[i][j];
int ni=face_indicies[i][j+3];//Normal index
int ti=face_indicies[i][j+6];//Texture index
glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
glTexCoord2f(textures[ti][0],textures[ti][1]);
glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
}
}
glEnd ();
glEndList();
return lid;
};
sphere
Code: Select all
/*
This file was produced by Deep Exploration Plugin: CPP Export filter.
Deep Exploration
Copyright (c) 1999-2003 Right Hemisphere, Inc
WWW http://www.righthemisphere.com/dexp.htm
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>
struct sample_MATERIAL{
GLfloat ambient[3];
GLfloat diffuse[3];
GLfloat specular[3];
GLfloat emission[3];
GLfloat alpha;
GLfloat phExp;
int texture;
};
static sample_MATERIAL materials [1] = {
{{0.3f,0.3f,0.3f}, {0.7f,0.7f,0.7f}, {0.752941f,0.752941f,0.752941f}, {0.0f,0.0f,0.0f}, 1.0f,8.0f,-1} //DefaultLib.Scene_Material
};
// 58 Verticies
// 67 Texture Coordinates
// 58 Normals
// 112 Triangles
static BYTE face_indicies[112][9] = {
// Object #-1
{9,2,0 ,0,1,2 ,0,1,2 }, {2,10,3 ,1,3,4 ,1,3,4 }, {2,9,10 ,1,0,3 ,1,0,3 },
{3,11,4 ,4,5,6 ,4,5,6 }, {3,10,11 ,4,3,5 ,4,3,5 }, {4,12,5 ,6,7,8 ,6,7,8 },
{4,11,12 ,6,5,7 ,6,5,7 }, {5,13,6 ,8,9,10 ,8,9,10 }, {5,12,13 ,8,7,9 ,8,7,9 },
{6,14,7 ,10,11,12 ,10,11,12 }, {6,13,14 ,10,9,11 ,10,9,11 },
{7,15,8 ,12,13,14 ,12,13,14 }, {7,14,15 ,12,11,13 ,12,11,13 },
{8,15,1 ,14,13,15 ,14,13,15 }, {16,9,0 ,16,0,2 ,16,0,2 }, {9,17,10 ,0,17,3 ,0,17,3 },
{9,16,17 ,0,16,17 ,0,16,17 }, {10,18,11 ,3,18,5 ,3,18,5 }, {10,17,18 ,3,17,18 ,3,17,18 },
{11,19,12 ,5,19,7 ,5,19,7 }, {11,18,19 ,5,18,19 ,5,18,19 }, {12,20,13 ,7,20,9 ,7,20,9 },
{12,19,20 ,7,19,20 ,7,19,20 }, {13,21,14 ,9,21,11 ,9,21,11 },
{13,20,21 ,9,20,21 ,9,20,21 }, {14,22,15 ,11,22,13 ,11,22,13 },
{14,21,22 ,11,21,22 ,11,21,22 }, {15,22,1 ,13,22,15 ,13,22,15 },
{23,16,0 ,23,16,2 ,23,16,24 }, {16,24,17 ,16,24,17 ,16,25,17 },
{16,23,24 ,16,23,24 ,16,23,25 }, {17,25,18 ,17,25,18 ,17,26,18 },
{17,24,25 ,17,24,25 ,17,25,26 }, {18,26,19 ,18,26,19 ,18,27,19 },
{18,25,26 ,18,25,26 ,18,26,27 }, {19,27,20 ,19,27,20 ,19,28,20 },
{19,26,27 ,19,26,27 ,19,27,28 }, {20,28,21 ,20,28,21 ,20,29,21 },
{20,27,28 ,20,27,28 ,20,28,29 }, {21,29,22 ,21,29,22 ,21,30,22 },
{21,28,29 ,21,28,29 ,21,29,30 }, {22,29,1 ,22,29,15 ,22,30,31 },
{30,23,0 ,30,23,2 ,32,23,24 }, {23,31,24 ,23,31,24 ,23,33,25 },
{23,30,31 ,23,30,31 ,23,32,33 }, {24,32,25 ,24,32,25 ,25,34,26 },
{24,31,32 ,24,31,32 ,25,33,34 }, {25,33,26 ,25,33,26 ,26,35,27 },
{25,32,33 ,25,32,33 ,26,34,35 }, {26,34,27 ,26,34,27 ,27,36,28 },
{26,33,34 ,26,33,34 ,27,35,36 }, {27,35,28 ,27,35,28 ,28,37,29 },
{27,34,35 ,27,34,35 ,28,36,37 }, {28,36,29 ,28,36,29 ,29,38,30 },
{28,35,36 ,28,35,36 ,29,37,38 }, {29,36,1 ,29,36,15 ,30,38,31 },
{37,30,0 ,37,30,2 ,39,32,24 }, {30,38,31 ,30,38,31 ,32,40,33 },
{30,37,38 ,30,37,38 ,32,39,40 }, {31,39,32 ,31,39,32 ,33,41,34 },
{31,38,39 ,31,38,39 ,33,40,41 }, {32,40,33 ,32,40,33 ,34,42,35 },
{32,39,40 ,32,39,40 ,34,41,42 }, {33,41,34 ,33,41,34 ,35,43,36 },
{33,40,41 ,33,40,41 ,35,42,43 }, {34,42,35 ,34,42,35 ,36,44,37 },
{34,41,42 ,34,41,42 ,36,43,44 }, {35,43,36 ,35,43,36 ,37,45,38 },
{35,42,43 ,35,42,43 ,37,44,45 }, {36,43,1 ,36,43,15 ,38,45,31 },
{44,37,0 ,44,37,2 ,46,39,24 }, {37,45,38 ,37,45,38 ,39,47,40 },
{37,44,45 ,37,44,45 ,39,46,47 }, {38,46,39 ,38,46,39 ,40,48,41 },
{38,45,46 ,38,45,46 ,40,47,48 }, {39,47,40 ,39,47,40 ,41,49,42 },
{39,46,47 ,39,46,47 ,41,48,49 }, {40,48,41 ,40,48,41 ,42,50,43 },
{40,47,48 ,40,47,48 ,42,49,50 }, {41,49,42 ,41,49,42 ,43,51,44 },
{41,48,49 ,41,48,49 ,43,50,51 }, {42,50,43 ,42,50,43 ,44,52,45 },
{42,49,50 ,42,49,50 ,44,51,52 }, {43,50,1 ,43,50,15 ,45,52,31 },
{51,44,0 ,51,44,2 ,53,54,2 }, {44,52,45 ,44,52,45 ,54,55,56 },
{44,51,52 ,44,51,52 ,54,53,55 }, {45,53,46 ,45,53,46 ,56,57,58 },
{45,52,53 ,45,52,53 ,56,55,57 }, {46,54,47 ,46,54,47 ,58,59,60 },
{46,53,54 ,46,53,54 ,58,57,59 }, {47,55,48 ,47,55,48 ,60,61,62 },
{47,54,55 ,47,54,55 ,60,59,61 }, {48,56,49 ,48,56,49 ,62,63,64 },
{48,55,56 ,48,55,56 ,62,61,63 }, {49,57,50 ,49,57,50 ,64,65,66 },
{49,56,57 ,49,56,57 ,64,63,65 }, {50,57,1 ,50,57,15 ,66,65,15 },
{2,51,0 ,1,51,2 ,1,53,2 }, {51,3,52 ,51,4,52 ,53,4,55 }, {51,2,3 ,51,1,4 ,53,1,4 },
{52,4,53 ,52,6,53 ,55,6,57 }, {52,3,4 ,52,4,6 ,55,4,6 }, {53,5,54 ,53,8,54 ,57,8,59 },
{53,4,5 ,53,6,8 ,57,6,8 }, {54,6,55 ,54,10,55 ,59,10,61 }, {54,5,6 ,54,8,10 ,59,8,10 },
{55,7,56 ,55,12,56 ,61,12,63 }, {55,6,7 ,55,10,12 ,61,10,12 },
{56,8,57 ,56,14,57 ,63,14,65 }, {56,7,8 ,56,12,14 ,63,12,14 },
{57,8,1 ,57,14,15 ,65,14,15 }
};
static GLfloat vertices [58][3] = {
{0.0f,-0.5f,0.0f},{0.0f,0.5f,0.0f},{-0.191342f,-0.46194f,0.0f},
{-0.353553f,-0.353553f,0.0f},{-0.46194f,-0.191342f,0.0f},{-0.5f,0.0f,0.0f},
{-0.46194f,0.191342f,0.0f},{-0.353553f,0.353553f,0.0f},{-0.191342f,0.46194f,0.0f},
{-0.135299f,-0.46194f,0.135299f},{-0.25f,-0.353553f,0.25f},{-0.326641f,-0.191342f,0.326641f},
{-0.353553f,0.0f,0.353553f},{-0.326641f,0.191342f,0.326641f},{-0.25f,0.353553f,0.25f},
{-0.135299f,0.46194f,0.135299f},{0.0f,-0.46194f,0.191342f},{0.0f,-0.353553f,0.353553f},
{0.0f,-0.191342f,0.46194f},{0.0f,0.0f,0.5f},{0.0f,0.191342f,0.46194f},
{0.0f,0.353553f,0.353553f},{0.0f,0.46194f,0.191342f},{0.135299f,-0.46194f,0.135299f},
{0.25f,-0.353553f,0.25f},{0.326641f,-0.191342f,0.326641f},{0.353553f,0.0f,0.353553f},
{0.326641f,0.191342f,0.326641f},{0.25f,0.353553f,0.25f},{0.135299f,0.46194f,0.135299f},
{0.191342f,-0.46194f,0.0f},{0.353553f,-0.353553f,0.0f},{0.46194f,-0.191342f,0.0f},
{0.5f,0.0f,0.0f},{0.46194f,0.191342f,0.0f},{0.353553f,0.353553f,0.0f},
{0.191342f,0.46194f,0.0f},{0.135299f,-0.46194f,-0.135299f},{0.25f,-0.353553f,-0.25f},
{0.326641f,-0.191342f,-0.326641f},{0.353553f,0.0f,-0.353553f},{0.326641f,0.191342f,-0.326641f},
{0.25f,0.353553f,-0.25f},{0.135299f,0.46194f,-0.135299f},{0.0f,-0.46194f,-0.191342f},
{0.0f,-0.353553f,-0.353553f},{0.0f,-0.191342f,-0.46194f},{0.0f,0.0f,-0.5f},
{0.0f,0.191342f,-0.46194f},{0.0f,0.353553f,-0.353553f},{0.0f,0.46194f,-0.191342f},
{-0.135299f,-0.46194f,-0.135299f},{-0.25f,-0.353553f,-0.25f},{-0.326641f,-0.191342f,-0.326641f},
{-0.353553f,0.0f,-0.353553f},{-0.326641f,0.191342f,-0.326641f},{-0.25f,0.353553f,-0.25f},
{-0.135299f,0.46194f,-0.135299f}
};
static GLfloat normals [58][3] = {
{-0.269132f,-0.924736f,0.269132f},{-0.380611f,-0.924735f,0.0f},{0.0f,-1.0f,0.0f},
{-0.498494f,-0.70923f,0.498494f},{-0.704977f,-0.70923f,0.0f},{-0.652733f,-0.384551f,0.652733f},
{-0.923104f,-0.384551f,0.0f},{-0.707107f,0.0f,0.707107f},{-1.0f,0.0f,0.0f},
{-0.652733f,0.384551f,0.652733f},{-0.923104f,0.384551f,0.0f},{-0.498494f,0.70923f,0.498494f},
{-0.704977f,0.70923f,0.0f},{-0.269132f,0.924736f,0.269132f},{-0.380611f,0.924735f,0.0f},
{0.0f,1.0f,0.0f},{0.0f,-0.924735f,0.380611f},{0.0f,-0.70923f,0.704977f},
{0.0f,-0.384551f,0.923104f},{0.0f,0.0f,1.0f},{0.0f,0.384551f,0.923104f},
{0.0f,0.70923f,0.704977f},{0.0f,0.924735f,0.380611f},{0.269132f,-0.924736f,0.269132f},
{0.498494f,-0.70923f,0.498494f},{0.652733f,-0.384551f,0.652733f},{0.707107f,0.0f,0.707107f},
{0.652733f,0.384551f,0.652733f},{0.498494f,0.70923f,0.498494f},{0.269132f,0.924736f,0.269132f},
{0.380611f,-0.924735f,0.0f},{0.704977f,-0.70923f,0.0f},{0.923104f,-0.384551f,0.0f},
{1.0f,0.0f,0.0f},{0.923104f,0.384551f,0.0f},{0.704977f,0.70923f,0.0f},
{0.380611f,0.924735f,0.0f},{0.269132f,-0.924736f,-0.269132f},{0.498494f,-0.70923f,-0.498494f},
{0.652733f,-0.384551f,-0.652733f},{0.707107f,0.0f,-0.707107f},{0.652733f,0.384551f,-0.652733f},
{0.498494f,0.70923f,-0.498494f},{0.269132f,0.924736f,-0.269132f},{0.0f,-0.924735f,-0.380611f},
{0.0f,-0.70923f,-0.704977f},{0.0f,-0.384551f,-0.923104f},{0.0f,0.0f,-1.0f},
{0.0f,0.384551f,-0.923104f},{0.0f,0.70923f,-0.704977f},{0.0f,0.924735f,-0.380611f},
{-0.269132f,-0.924736f,-0.269132f},{-0.498494f,-0.70923f,-0.498494f},{-0.652733f,-0.384551f,-0.652733f},
{-0.707107f,0.0f,-0.707107f},{-0.652733f,0.384551f,-0.652733f},{-0.498494f,0.70923f,-0.498494f},
{-0.269132f,0.924736f,-0.269132f}
};
static GLfloat textures [67][2] = {
{0.375f,0.125f},{0.25f,0.125f},{0.0f,0.0f},
{0.375f,0.25f},{0.25f,0.25f},{0.375f,0.375f},
{0.25f,0.375f},{0.375f,0.5f},{0.25f,0.5f},
{0.375f,0.625f},{0.25f,0.625f},{0.375f,0.75f},
{0.25f,0.75f},{0.375f,0.875f},{0.25f,0.875f},
{0.0f,1.0f},{0.5f,0.125f},{0.5f,0.25f},
{0.5f,0.375f},{0.5f,0.5f},{0.5f,0.625f},
{0.5f,0.75f},{0.5f,0.875f},{0.625f,0.125f},
{1.0f,0.0f},{0.625f,0.25f},{0.625f,0.375f},
{0.625f,0.5f},{0.625f,0.625f},{0.625f,0.75f},
{0.625f,0.875f},{1.0f,1.0f},{0.75f,0.125f},
{0.75f,0.25f},{0.75f,0.375f},{0.75f,0.5f},
{0.75f,0.625f},{0.75f,0.75f},{0.75f,0.875f},
{0.875f,0.125f},{0.875f,0.25f},{0.875f,0.375f},
{0.875f,0.5f},{0.875f,0.625f},{0.875f,0.75f},
{0.875f,0.875f},{1.0f,0.125f},{1.0f,0.25f},
{1.0f,0.375f},{1.0f,0.5f},{1.0f,0.625f},
{1.0f,0.75f},{1.0f,0.875f},{0.125f,0.125f},
{0.0f,0.125f},{0.125f,0.25f},{0.0f,0.25f},
{0.125f,0.375f},{0.0f,0.375f},{0.125f,0.5f},
{0.0f,0.5f},{0.125f,0.625f},{0.0f,0.625f},
{0.125f,0.75f},{0.0f,0.75f},{0.125f,0.875f},
{0.0f,0.875f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,112}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
GLfloat d[4];
d[0]=f[0];
d[1]=f[1];
d[2]=f[2];
d[3]=alpha;
glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
* SelectMaterial uses OpenGL commands to define facet colors.
*
* Returns:
* Nothing
*/
void SelectMaterial(int i)
{
//
// Define the reflective properties of the 3D Object faces.
//
glEnd();
GLfloat alpha=materials[i].alpha;
MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
MyMaterial (GL_EMISSION, materials[i].emission,alpha);
glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
glBegin(GL_TRIANGLES);
};
GLint Gen3DObjectList()
{
int i;
int j;
GLint lid=glGenLists(1);
int mcount=0;
int mindex=0;
glNewList(lid, GL_COMPILE);
glBegin (GL_TRIANGLES);
for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
{
if(!mcount)
{
SelectMaterial(material_ref[mindex][0]);
mcount=material_ref[mindex][1];
mindex++;
}
mcount--;
for(j=0;j<3;j++)
{
int vi=face_indicies[i][j];
int ni=face_indicies[i][j+3];//Normal index
int ti=face_indicies[i][j+6];//Texture index
glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
glTexCoord2f(textures[ti][0],textures[ti][1]);
glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
}
}
glEnd ();
glEndList();
return lid;
};