PDA

View Full Version : a question,need help



iux
01-30-2003, 10:10 AM
hi everyone,
i have made an 3d object and already convert to .cc also .h with PolyTrans. now how can i import the cords into my main function? should i use gldrawable to do it?
thx

[This message has been edited by iux (edited 01-30-2003).]

iux
01-30-2003, 05:30 PM
can anyone help me?

shinpaughp
01-30-2003, 05:57 PM
Not sure what you are asking. What is PolyTrans? I assume .cc is some sort of C or C++ implementation file. By your words... "made an 3D object", do you mean you created an object in a 3D modelling application and you exported it and you wish to import it into your application and render it with OpenGL? Did you manually create an array containing all of the vertex coordinates, colors, etc? Are you asking how to set up an application to actually use OpenGL to render your object?

If you are new to OpenGL, you should probably check out http://nehe.gamedev.net or http://www.bluedev.net or the oh so many more links which can be found throughout this discussion board as well as read OpenGL Programming Guide or OpenGL Bible and if nothing else read the Documentation and FAQs links on the home page of this site.

Of course, if you are asking something else, you might wish to give more detail.

iux
01-30-2003, 06:26 PM
thank u for ur information,
PolyTrans is a software ,which can convert many sort files to eachother, i have convert .3ds to .cc ,there r many void funktions with glbegin and glend,each function is a part of the object(example: loft1,box1),i wanna import the whole object(inclue color,light) in my game so that player and move it in th game ,how can i do?

[This message has been edited by iux (edited 01-30-2003).]

iux
01-30-2003, 06:31 PM
a part of the large cord in .cc


#include "pacman.h"


void OGL_Set_Current_Material_Parameters(float shininess, float r_diffuseColor, float g_diffuseColor, float b_diffuseColor, float r_specularColor, float g_specularColor, float b_specularColor)
{
GLfloat glfModelSpecular[4];


glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
glfModelSpecular[0] = r_specularColor;
glfModelSpecular[1] = g_specularColor;
glfModelSpecular[2] = b_specularColor;
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, glfModelSpecular);
glColor3f(r_diffuseColor, g_diffuseColor, b_diffuseColor);
}

void OGL_Set_Current_Texture_Map(char *texture_map_name, float u_scale, float v_scale, float u_offset, float v_offset)
{
}

void
Arc01()
{
// Material attributes for surface '8 - default'
OGL_Set_Current_Material_Parameters(15.0000f, 1.00000f, 0.800000f, 0.488889f, 0.250980f, 0.184314f, 0.113725f);

OGL_Set_Current_Texture_Map("", 1.0, 1.0, 0.0, 0.0); // Disable last texture map output

// Polygon # 0
glBegin(GL_TRIANGLES);
glNormal3f(-0.989520f, 0.00548155f, 0.144293f);
glVertex3f(3.38454f, -12.7305f, -52.6156f);
glNormal3f(-0.996322f, 0.0328452f, 0.0791452f);
glVertex3f(3.35994f, -13.1065f, -52.7693f);
glNormal3f(-0.961593f, -0.00273774f, 0.274465f);
glVertex3f(3.37894f, -13.1147f, -52.6390f);
// Polygon # 1
glNormal3f(-0.989520f, 0.00548155f, 0.144293f);
glVertex3f(3.38454f, -12.7305f, -52.6156f);
glNormal3f(-0.998411f, 0.0109805f, 0.0552716f);
glVertex3f(3.35865f, -13.0983f, -52.9029f);
glNormal3f(-0.996322f, 0.0328452f, 0.0791452f);
glVertex3f(3.35994f, -13.1065f, -52.7693f);
// Polygon # 2
glNormal3f(-0.996997f, -0.0135618f, 0.0762430f);
glVertex3f(3.36554f, -12.7223f, -52.7460f);
glNormal3f(-0.998411f, 0.0109805f, 0.0552716f);
glVertex3f(3.35865f, -13.0983f, -52.9029f);
glNormal3f(-0.989520f, 0.00548155f, 0.144293f);
glVertex3f(3.38454f, -12.7305f, -52.6156f);
// Polygon # 3
glNormal3f(-0.999848f, 0.0139392f, 0.0104722f);
glVertex3f(3.36425f, -12.7142f, -52.8795f);
glNormal3f(-0.998411f, 0.0109805f, 0.0552716f);
glVertex3f(3.35865f, -13.0983f, -52.9029f);
glNormal3f(-0.996997f, -0.0135618f, 0.0762430f);
glVertex3f(3.36554f, -12.7223f, -52.7460f);
// Polygon # 4
glNormal3f(-0.916895f, -0.0109718f, 0.398978f);
glVertex3f(3.47246f, -12.7467f, -52.3707f);
glNormal3f(-0.940680f, 0.0155120f, 0.338940f);
glVertex3f(3.41486f, -13.1228f, -52.5134f);
glNormal3f(-0.856337f, -0.0188981f, 0.516072f);
glVertex3f(3.46686f, -13.1309f, -52.3941f);
// Polygon # 5
glNormal3f(-0.941354f, -0.0292698f, 0.336148f);
glVertex3f(3.42046f, -12.7387f, -52.4900f);
glNormal3f(-0.961593f, -0.00273774f, 0.274465f);
glVertex3f(3.37894f, -13.1147f, -52.6390f);
glNormal3f(-0.916895f, -0.0109718f, 0.398978f);
glVertex3f(3.47246f, -12.7467f, -52.3707f);
// Polygon # 6
glNormal3f(-0.989520f, 0.00548155f, 0.144293f);
glVertex3f(3.38454f, -12.7305f, -52.6156f);
glNormal3f(-0.961593f, -0.00273774f, 0.274465f);
glVertex3f(3.37894f, -13.1147f, -52.6390f);
glNormal3f(-0.941354f, -0.0292698f, 0.336148f);
glVertex3f(3.42046f, -12.7387f, -52.4900f);
// Polygon # 7
glNormal3f(-0.780545f, -0.0266079f, 0.624533f);
glVertex3f(3.62152f, -12.7619f, -52.1574f);
glNormal3f(-0.819793f, -0.000399096f, 0.572660f);
glVertex3f(3.53416f, -13.1386f, -52.2827f);
glNormal3f(-0.690425f, -0.0337811f, 0.722614f);
glVertex3f(3.61592f, -13.1460f, -52.1808f);
// Polygon # 8
glNormal3f(-0.780545f, -0.0266079f, 0.624533f);
glVertex3f(3.62152f, -12.7619f, -52.1574f);
glNormal3f(-0.856337f, -0.0188981f, 0.516072f);
glVertex3f(3.46686f, -13.1309f, -52.3941f);
glNormal3f(-0.819793f, -0.000399096f, 0.572660f);
glVertex3f(3.53416f, -13.1386f, -52.2827f);
// Polygon # 9
glNormal3f(-0.916895f, -0.0109718f, 0.398978f);
glVertex3f(3.47246f, -12.7467f, -52.3707f);
glNormal3f(-0.856337f, -0.0188981f, 0.516072f);
glVertex3f(3.46686f, -13.1309f, -52.3941f);
glNormal3f(-0.820486f, -0.0451754f, 0.569880f);
glVertex3f(3.53976f, -12.7545f, -52.2593f);
// Polygon # 10
glNormal3f(-0.678785f, -0.0346139f, 0.733520f);
glVertex3f(3.82521f, -12.7752f, -51.9882f);
glNormal3f(-0.639812f, -0.0140103f, 0.768404f);
glVertex3f(3.71134f, -13.1529f, -52.0899f);
glNormal3f(-0.745474f, -0.0296809f, 0.665873f);
glVertex3f(3.81961f, -13.1593f, -52.0116f);
// Polygon # 11
glNormal3f(-0.678785f, -0.0346139f, 0.733520f);
glVertex3f(3.82521f, -12.7752f, -51.9882f);
glNormal3f(-0.690425f, -0.0337811f, 0.722614f);
glVertex3f(3.61592f, -13.1460f, -52.1808f);
glNormal3f(-0.639812f, -0.0140103f, 0.768404f);
glVertex3f(3.71134f, -13.1529f, -52.0899f);
// Polygon # 12
glNormal3f(-0.640549f, -0.0604195f, 0.765537f);
glVertex3f(3.71694f, -12.7688f, -52.0665f);
glNormal3f(-0.690425f, -0.0337811f, 0.722614f);
glVertex3f(3.61592f, -13.1460f, -52.1808f);
glNormal3f(-0.678785f, -0.0346139f, 0.733520f);
glVertex3f(3.82521f, -12.7752f, -51.9882f);
// Polygon # 13
glNormal3f(-0.745474f, -0.0296809f, 0.665873f);
glVertex3f(3.81961f, -13.1593f, -52.0116f);
glNormal3f(-0.715169f, -0.0320923f, 0.698215f);
glVertex3f(3.82522f, -12.7752f, -51.9882f);
glNormal3f(-0.678785f, -0.0346139f, 0.733520f);
glVertex3f(3.82521f, -12.7752f, -51.9882f);
// Polygon # 14
glNormal3f(-0.745474f, -0.0296809f, 0.665873f);
glVertex3f(3.81961f, -13.1593f, -52.0116f);
glNormal3f(-0.535909f, -0.0436919f, 0.843145f);
glVertex3f(3.81962f, -13.1593f, -52.0116f);
glNormal3f(-0.715169f, -0.0320923f, 0.698215f);
glVertex3f(3.82522f, -12.7752f, -51.9882f);
// Polygon # 15
glNormal3f(-0.349936f, -0.0520136f, 0.935328f);
glVertex3f(4.06674f, -12.7853f, -51.8792f);
glNormal3f(-0.411497f, -0.0263450f, 0.911030f);
glVertex3f(3.93750f, -13.1648f, -51.9486f);
glNormal3f(-0.222157f, -0.0560812f, 0.973397f);
glVertex3f(4.06114f, -13.1695f, -51.9026f);
// Polygon # 16
glNormal3f(-0.349936f, -0.0520136f, 0.935328f);
glVertex3f(4.06674f, -12.7853f, -51.8792f);
glNormal3f(-0.535909f, -0.0436919f, 0.843145f);
glVertex3f(3.81962f, -13.1593f, -52.0116f);
glNormal3f(-0.411497f, -0.0263450f, 0.911030f);
glVertex3f(3.93750f, -13.1648f, -51.9486f);
// Polygon # 17
glNormal3f(-0.715169f, -0.0320923f, 0.698215f);
glVertex3f(3.82522f, -12.7752f, -51.9882f);
glNormal3f(-0.535909f, -0.0436919f, 0.843145f);
glVertex3f(3.81962f, -13.1593f, -52.0116f);
glNormal3f(-0.412236f, -0.0727424f, 0.908168f);
glVertex3f(3.94310f, -12.7807f, -51.9252f);
// Polygon # 18
glNormal3f(-0.0912699f, -0.0592480f, 0.994062f);
glVertex3f(4.32416f, -12.7916f, -51.8386f);
glNormal3f(-0.156482f, -0.0353942f, 0.987046f);
glVertex3f(4.18874f, -13.1731f, -51.8738f);
glNormal3f(0.0407311f, -0.0612808f, 0.997289f);
glVertex3f(4.31856f, -13.1757f, -51.8620f);
// Polygon # 19
glNormal3f(-0.0912699f, -0.0592480f, 0.994062f);
glVertex3f(4.32416f, -12.7916f, -51.8386f);
glNormal3f(-0.222157f, -0.0560812f, 0.973397f);
glVertex3f(4.06114f, -13.1695f, -51.9026f);
glNormal3f(-0.156482f, -0.0353942f, 0.987046f);
glVertex3f(4.18874f, -13.1731f, -51.8738f);
// Polygon # 20
glNormal3f(-0.157201f, -0.0801683f, 0.984307f);
glVertex3f(4.19434f, -12.7889f, -51.8504f);
glNormal3f(-0.222157f, -0.0560812f, 0.973397f);
glVertex3f(4.06114f, -13.1695f, -51.9026f);
glNormal3f(-0.0912699f, -0.0592480f, 0.994062f);
glVertex3f(4.32416f, -12.7916f, -51.8386f);
// Polygon # 21
glNormal3f(0.172506f, -0.0623337f, 0.983034f);
glVertex3f(4.58332f, -12.7936f, -51.8666f);
glNormal3f(0.107008f, -0.0395370f, 0.993472f);
glVertex3f(4.44881f, -13.1772f, -51.8674f);
glNormal3f(0.302063f, -0.0621738f, 0.951258f);
glVertex3f(4.57772f, -13.1777f, -51.8900f);
// Polygon # 22
glNormal3f(0.172506f, -0.0623337f, 0.983034f);
glVertex3f(4.58332f, -12.7936f, -51.8666f);
glNormal3f(0.0407311f, -0.0612808f, 0.997289f);
glVertex3f(4.31856f, -13.1757f, -51.8620f);
glNormal3f(0.107008f, -0.0395370f, 0.993472f);
glVertex3f(4.44881f, -13.1772f, -51.8674f);
// Polygon # 23
glNormal3f(0.106290f, -0.0843163f, 0.990754f);
glVertex3f(4.45441f, -12.7931f, -51.8440f);
glNormal3f(0.0407311f, -0.0612808f, 0.997289f);
glVertex3f(4.31856f, -13.1757f, -51.8620f);
glNormal3f(0.172506f, -0.0623337f, 0.983034f);
glVertex3f(4.58332f, -12.7936f, -51.8666f);
// Polygon # 24
glNormal3f(-0.0912699f, -0.0592480f, 0.994062f);
glVertex3f(4.32416f, -12.7916f, -51.8386f);
glNormal3f(0.0407311f, -0.0612808f, 0.997289f);
glVertex3f(4.31856f, -13.1757f, -51.8620f);
glNormal3f(0.106290f, -0.0843163f, 0.990754f);
glVertex3f(4.45441f, -12.7931f, -51.8440f);
// Polygon # 25
glNormal3f(0.293764f, -0.0622090f, 0.953851f);
glVertex3f(4.83007f, -12.7913f, -51.9637f);
glNormal3f(0.302063f, -0.0621738f, 0.951258f);
glVertex3f(4.57772f, -13.1777f, -51.8900f);
glNormal3f(0.365597f, -0.0385090f, 0.929976f);
glVertex3f(4.70353f, -13.1772f, -51.9299f);
// Polygon # 26
glNormal3f(0.364856f, -0.0849190f, 0.927183f);
glVertex3f(4.70913f, -12.7930f, -51.9065f);
glNormal3f(0.302063f, -0.0621738f, 0.951258f);
glVertex3f(4.57772f, -13.1777f, -51.8900f);
glNormal3f(0.293764f, -0.0622090f, 0.953851f);
glVertex3f(4.83007f, -12.7913f, -51.9637f);
// Polygon # 27
glNormal3f(0.172506f, -0.0623337f, 0.983034f);
glVertex3f(4.58332f, -12.7936f, -51.8666f);
glNormal3f(0.302063f, -0.0621738f, 0.951258f);
glVertex3f(4.57772f, -13.1777f, -51.8900f);
glNormal3f(0.364856f, -0.0849190f, 0.927183f);
glVertex3f(4.70913f, -12.7930f, -51.9065f);
// Polygon # 28
glNormal3f(0.145543f, -0.0622502f, 0.987392f);
glVertex3f(4.82447f, -13.1754f, -51.9871f);
glNormal3f(0.188716f, -0.0624322f, 0.980045f);
glVertex3f(4.83007f, -12.7913f, -51.9637f);
glNormal3f(0.293764f, -0.0622090f, 0.953851f);
glVertex3f(4.83007f, -12.7913f, -51.9637f);
// Polygon # 29
glNormal3f(0.652922f, -0.0556757f, 0.755376f);
glVertex3f(5.04210f, -12.7847f, -52.1227f);
glNormal3f(0.600861f, -0.0342497f, 0.798620f);
glVertex3f(4.93658f, -13.1726f, -52.0600f);
glNormal3f(0.747903f, -0.0512503f, 0.661827f);
glVertex3f(5.03650f, -13.1688f, -52.1461f);
// Polygon # 30
glNormal3f(0.652922f, -0.0556757f, 0.755376f);
glVertex3f(5.04210f, -12.7847f, -52.1227f);
glNormal3f(0.452772f, -0.0609333f, 0.889542f);
glVertex3f(4.82447f, -13.1754f, -51.9871f);
glNormal3f(0.600861f, -0.0342497f, 0.798620f);
glVertex3f(4.93658f, -13.1726f, -52.0600f);
// Polygon # 31
glNormal3f(0.600122f, -0.0806693f, 0.795831f);
glVertex3f(4.94218f, -12.7885f, -52.0366f);
glNormal3f(0.452772f, -0.0609333f, 0.889542f);
glVertex3f(4.82447f, -13.1754f, -51.9871f);
glNormal3f(0.652922f, -0.0556757f, 0.755376f);
glVertex3f(5.04210f, -12.7847f, -52.1227f);
// Polygon # 32
glNormal3f(0.188716f, -0.0624322f, 0.980045f);
glVertex3f(4.83007f, -12.7913f, -51.9637f);
glNormal3f(0.452772f, -0.0609333f, 0.889542f);
glVertex3f(4.82447f, -13.1754f, -51.9871f);
glNormal3f(0.600122f, -0.0806693f, 0.795831f);
glVertex3f(4.94218f, -12.7885f, -52.0366f);
// Polygon # 33
glNormal3f(0.829101f, -0.0460625f, 0.557198f);
glVertex3f(5.20179f, -12.7745f, -52.3285f);
glNormal3f(0.747903f, -0.0512503f, 0.661827f);
glVertex3f(5.03650f, -13.1688f, -52.1461f);
glNormal3f(0.790496f, -0.0263495f, 0.611900f);
glVertex3f(5.12333f, -13.1642f, -52.2440f);
// Polygon # 34
glNormal3f(0.789801f, -0.0711390f, 0.609224f);
glVertex3f(5.12893f, -12.7800f, -52.2206f);
glNormal3f(0.747903f, -0.0512503f, 0.661827f);
glVertex3f(5.03650f, -13.1688f, -52.1461f);
glNormal3f(0.829101f, -0.0460625f, 0.557198f);
glVertex3f(5.20179f, -12.7745f, -52.3285f);
// Polygon # 35
glNormal3f(0.652922f, -0.0556757f, 0.755376f);
glVertex3f(5.04210f, -12.7847f, -52.1227f);
glNormal3f(0.747903f, -0.0512503f, 0.661827f);
glVertex3f(5.03650f, -13.1688f, -52.1461f);
glNormal3f(0.789801f, -0.0711390f, 0.609224f);
glVertex3f(5.12893f, -12.7800f, -52.2206f);
// Polygon # 36
glNormal3f(0.946480f, -0.0333041f, 0.321041f);
glVertex3f(5.30202f, -12.7613f, -52.5688f);
glNormal3f(0.923066f, -0.0143378f, 0.384374f);
glVertex3f(5.25418f, -13.1524f, -52.4685f);
glNormal3f(0.980976f, -0.0258601f, 0.192399f);
glVertex3f(5.29642f, -13.1455f, -52.5922f);
// Polygon # 37
glNormal3f(0.922390f, -0.0591291f, 0.381708f);
glVertex3f(5.25978f, -12.7683f, -52.4451f);
glNormal3f(0.895520f, -0.0400014f, 0.443220f);
glVertex3f(5.19619f, -13.1586f, -52.3519f);
glNormal3f(0.946480f, -0.0333041f, 0.321041f);
glVertex3f(5.30202f, -12.7613f, -52.5688f);
// Polygon # 38
glNormal3f(0.829101f, -0.0460625f, 0.557198f);
glVertex3f(5.20179f, -12.7745f, -52.3285f);
glNormal3f(0.895520f, -0.0400014f, 0.443220f);
glVertex3f(5.19619f, -13.1586f, -52.3519f);
glNormal3f(0.922390f, -0.0591291f, 0.381708f);
glVertex3f(5.25978f, -12.7683f, -52.4451f);
// Polygon # 39
glNormal3f(0.994371f, -0.0206159f, 0.103930f);
glVertex3f(5.33567f, -12.7458f, -52.8314f);
glNormal3f(0.991824f, 0.00122371f, 0.127608f);
glVertex3f(5.32201f, -13.1380f, -52.7215f);
glNormal3f(0.998079f, -0.0181576f, 0.0592337f);
glVertex3f(5.33007f, -13.1300f, -52.8548f);
// Polygon # 40
glNormal3f(0.994371f, -0.0206159f, 0.103930f);
glVertex3f(5.33567f, -12.7458f, -52.8314f);
glNormal3f(0.980976f, -0.0258601f, 0.192399f);
glVertex3f(5.29642f, -13.1455f, -52.5922f);
glNormal3f(0.991824f, 0.00122371f, 0.127608f);
glVertex3f(5.32201f, -13.1380f, -52.7215f);
// Polygon # 41
glNormal3f(0.946480f, -0.0333041f, 0.321041f);
glVertex3f(5.30202f, -12.7613f, -52.5688f);
glNormal3f(0.980976f, -0.0258601f, 0.192399f);
glVertex3f(5.29642f, -13.1455f, -52.5922f);
glNormal3f(0.991145f, -0.0451921f, 0.124855f);
glVertex3f(5.32761f, -12.7538f, -52.6981f);
glEnd();
}


void
ChamferBox()
{
// Material attributes for surface '15 - default'
OGL_Set_Current_Material_Parameters(15.0000f, 1.00000f, 0.909677f, 0.477419f, 0.235294f, 0.203922f, 0.000000f);

OGL_Set_Current_Texture_Map("", 1.0, 1.0, 0.0, 0.0); // Disable last texture map output

// Polygon # 0
glBegin(GL_TRIANGLES);
glNormal3f(-0.197064f, -0.141247f, -0.970162f);
glVertex3f(2.38031f, -18.8389f, -64.8220f);
glNormal3f(-0.176051f, 0.293535f, -0.939597f);
glVertex3f(2.38031f, -16.4032f, -64.7075f);
glNormal3f(0...................................... .................................................. ..................................

jebus
01-31-2003, 06:10 AM
it looks like most of the work is done for you. you just need to ensure you set up OpenGL correctly (glEnable() and the others) and make sure you call your OGL_* functions in the right places.

jebus

nexusone
01-31-2003, 08:05 AM
Here is how to handle your object:


inside you display routine:

// Draw Pacman
// Push Matrix save matrix so that what we do next will not effect object drawn afterward
glPushMatrix();
// Translate Pacman to some point in our world
glTranslate
// Rotate Pacman
glRotate
// Scale Pacman to size needed for world.
glScale
// Call Pacman drawing code
Draw_Pacman();
// We have finished our object restore matrix to be for drawing object
glPopMatrix();

Then create a routine call Draw_Pacman

void Draw_Pacman( void )
{
//Start drawing code here

}

iux
01-31-2003, 09:23 AM
thanks a lot for your information,
your

"//Start drawing code here"

here means all the cords i have written above, right?

nexusone
01-31-2003, 03:38 PM
Yes the cords you have written.



Originally posted by iux:

thanks a lot for your information,
your

"//Start drawing code here"

here means all the cords i have written above, right?