🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

3d exploration and textures

Started by
13 comments, last by Castor3d 24 years ago
Does anyone have any information to the usage of 3D exploration, when used to generate texture data as well as object data? It feels like im getting dumber and dumber for each day that passes. Btw i might as well ask you guys how you do it when you have to map complex objects? Edited by - Castor3d on 5/30/00 8:17:34 AM
Advertisement
Hi,

The textures are exported along with the model files. At least that is what happens for me when importing *.cob files and exporting to OGL application code. I did have a problem initially with receiving an error when trying to use textures, but that was solved by downloading a later version of the app (Version 1.3.00).

Hope that helps.

Karl

KarlFisher
KarlFisher
Do you mean, ''How can i get the right textures to be used, when i use the 3d exploration to generate my drawing code?''

If so then what you need to do is load up the textures in the same order that they are in used in 3d exploration.

You then need to modify the generated code. In the code there should be two lines you need to uncomment which look like this:

//int ti=face_indicies[j+6];

//glTexCoord2f(textures[ti][0],textures[ti][1]);

and then in the function SelectMaterial(int i)

you need to add:

glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, id(i) );

where id( i ) is the texture id for the ith texture used by the model.


3d exploration should save the textures out as bmps in the correct order with a similar name to the file that contains the code eg you have a ball model with two textures and you save the model as glBall.cpp, 3d explorer will also save the two textures as glBall_0.bmp and glBall_1.bmp. When the code calls SelectMaterial( 1 ) you need to make glBall_1.bmp the active texture.


hope that makes sense

cheers dan



Game production:
Good, quick, cheap: Choose two.
Game production:Good, quick, cheap: Choose two.
Thank you for explaining everything to me, but i guess im stupid or something

I didn''t quite understand when you explained
glBindTexture( GL_TEXTURE_2D, id(i) );

some code from landskap.cpp

#include
#include
#include

#include

struct sample_MATERIAL{
GLfloat ambient[3];
GLfloat diffuse[3];
GLfloat specular[3];
GLfloat emission[3];
GLfloat alpha;
int texture;
};
struct sample_TEXTURE{
char * name;
GLint id;
};

static sample_MATERIAL materials [1] = {
{{0.117647f,0.117647f,0.117647f}, {0.784314f,0.784314f,0.784314f}, {0.752941f,0.752941f,0.752941f}, {0.0f,0.0f,0.0f}, 0.0f,0}
};

static sample_TEXTURE texture_maps [1] = {
{"landskap_0.bmp",0}
};

// 441 Verticies
// 445 Texture Coordinates
// 584 Normals
// 800 Triangles

static short face_indicies[800][9] = {
// Object: #1

/*
''snip snip'' lots of numbers cut away :-)
*/

/*{material index,face count}*/
static int material_ref [1][2] = {
{0,800}
};
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.
//

GLfloat alpha=materials.alpha;
MyMaterial (GL_AMBIENT, materials.ambient,alpha);<br> MyMaterial (GL_DIFFUSE, materials.diffuse,alpha);<br> MyMaterial (GL_SPECULAR, materials.specular,alpha);<br> MyMaterial (GL_EMISSION, materials.emission,alpha);<br><br> glEnable( GL_TEXTURE_2D );<br> glBindTexture( GL_TEXTURE_2D, id(i) );<br><br><br>};<br><br>GLint Gen3DObjectList()<br>{<br> int i;<br> int j;<br> GLint lid=glGenLists(1);<br> glNewList(lid, GL_COMPILE);<br><br> int mindex=0;<br> int mcount=0;<br><br> glBegin (GL_TRIANGLES);<br> for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)<br> {<br> if(!mcount)<br> {<br> SelectMaterial(material_ref[mindex][0]);<br> mcount=material_ref[mindex][1];<br> mindex++;<br> }<br> mcount–;<br> for(j=0;j<3;j++)<br> {<br> int vi=face_indicies[j];<br> int ni=face_indicies[j+3];<br> int ti=face_indicies[j+6];<br> glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);<br> glTexCoord2f(textures[ti][0],textures[ti][1]);<br> glVertex3f (verticies[vi][0],verticies[vi][1],verticies[vi][2]);<br> }<br> }<br> glEnd ();<br><br> glEndList();<br> return lid;<br>}<br><br>What should i have instead of id(i) ?<br><br>Sorry for this homugous paste but im really a graphics artis trying to understand the world of programmers. <br> </i>
sup, castor3d,
i''m also using 3d exploration, and have run into the same problem. I haven''t tried out what Danack means, but i get the idea. instead of id, use texture_maps, but of course, these are just the texture names. ( i was thinking of using the integer variables that are generated for the texture object when loading in the texture, but i''m not sure yet. if your still confused, don''t worry, cuz i haven''t tried it out either, but i''ll repost once i figure it out, if you don''t first)<br><br>a2k </i>
------------------General Equation, this is Private Function reporting for duty, sir!a2k
instead of id, try texture_maps.id; </i>
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Hi all, sorry i havent said how things went, iwe been out of town the last few days.

I just tried to do what you suggested, and added

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture_maps.id);

to the SelectMaterial(int i)
and now there are no more errors, but the texture does not make an appearance now either :-)

The object sits pretty on the screen though.

I was wondering, does any code have to be added to the main code(except glCallList(Gen3DObjectList()) and the include)?

have you loaded the texture into memory? first, you have to read the bitmap in, and then set it as a texture. when you do this, it assigns the integer value indicated in texture. but loading the texture is the vital step. i know i may be asking a stupid question, but just wondering if you had done this.

wow. funny how i''m giving you all this theoretical stuff, when i should be trying it out myself. =)

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
I am trying to use the skeleton from nehes tutorials, but i must be missing out on something seriously basic.

(Cough)You dont happen to have some simple source with something mapped that you could (Cough) mail me (Smile)?

i think im doing wrong when im loadning the textures to memory, It works when i make a polygon within the main program, but not with the code from 3d exploration
Hi everybody,

Something strange happen when i use texture coordinates from the code generated by 3DExploration : the textures are "flickering" like the texture coordinates are wrong (sorry for my awful english) I use 3DSMAX and the file format is 3DS.
Castor3d : for loading texture in memory , follow nehe''s tutorial about textures (n°6 i think) it is as good as simple!

lunasol

This topic is closed to new replies.

Advertisement