🎉 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!

Problems With 3D Explorer Textures

Started by
14 comments, last by steve_bruce 23 years, 11 months ago
Has anyone had problems with 3D Explorer and textures. I created a model of a house in 3DSMax with a simple box for the main house and a prism for the roof. Both had there own textures. After I exported the house object complete with textures and converted it to GL code the textures don''t appear to be assigned to the right part of the house. In other words one texture is being used for the whole of the model (roof & box). I''m loading the textures seperately as TextureImage[0] and TextureImage[1]. I spent ages trying to work it out and am just about ready to give up so any help would be much appreciated.
Advertisement
hi
if you want to have several texture in your scene you have to transform a little bit the code generated by 3Dexploration (it''s not yet a perfect app!)
First you have to bind the texture before the glBegin() in the display list.
Second you have to find a method to tell which texture you want to bind. For example create a new static variable

static byte objet_indice[number of obj][3]={# of the object,#last triangle of the object,#texture you want to apply on the object}

glNewList(lid, GL_COMPILE);
for (k=objet_indice[num_obj][0];k glBindTexture( GL_TEXTURE_2D, texture_im[objet_indice[num_obj][2]]);
glBegin (GL_TRIANGLES);
for(i=num_triangle;i num_triangle++;
if(!mcount){

SelectMaterial(material_ref[mindex][0]);
mcount=material_ref[mindex][1];
mindex++;
}
mcount--;
for(j=0;j<3;j++){
int vi=face_indicies[j];
int ni=face_indicies[j+3];<br> int ti=face_indicies[j+6];<br> <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> num_obj++;<br> }<br> <br> glEndList(); <br><br><br>hope that help<br><br>lunasol </i>
Thanks for the post. I understand most of what is going on here.
I''ve got my two objects set up in this array:

static byte object_indice[2][3] = {
{0,12,0},{1,24,1}};

I think that''s right. Then I added these two variables to clear up some errors:

int k;
int num_obj=0;

I hope thats right. This is the line I''m having all the trouble with:

for(k=object_indice[num_obj][0]; k glBindTexture(GL_TEXTURE_2D, texture[object_indice[num_obj][2]]);

Could you please explain whats going on in this line of code. I know how For loops work but I thought they''re supposed to be 3 parts to a For loop. Also what are the numbers [0] and [2] all about.


When I compile the program it comes up with 5 errors. This is the first error to do with that line which has got me a bit stumped:

error C2146: syntax error : missing '';'' before identifier ''glBindTexture''


Help!!







I suggest you put your two textures in one single texture, because texture state changes are very expensive (calculation-wise) and should be avoided as much as possible..

----------
Mail me, Drago's OpenGL Website
osu!
hi
i think that my post have been truncated...
here what you should have red :

for (k=objet_indice[num_obj][0];k glBindTexture( GL_TEXTURE_2D, texture_im[objet_indice[num_obj][2]]);
....
}
hey Drago how do you manage two different textures in a single one? thanks for the replies...

lunasol
what''s that hell! it seems to me that my post have been truncated again!!!! ok i understand the "lower than" sign surely cause problem (damn HTML)

for (k=objet_indice[num_obj][0];k(lower than) MAX_OBJ;k++){
glBindTexture( GL_TEXTURE_2D, texture_im[objet_indice[num_obj][2]]);
....
}

lunasol
Hi lunasol

Here''s the code I''ve got for my Display List at the moment and it just doesn''t appear to be working. Do you know what I''m doing wrong. I''ve got two objects a prism and a box for a house object. I''ve also got 2 textures for the roof and walls. I must be doing something wrong here. If possible could you send me your Display List code so I can see where I''m going wrong. Thanks very much.

mailto:steve_bruce@lineone.net



GLvoid BuildLists()
{
int i;
int j;
static byte object_indice[2][3] = {
{0,12,0},{1,24,1}};


House=glGenLists(1);
glNewList(House, GL_COMPILE);

int mindex=0;
int mcount=0;
int k;
int num_obj=1;


for (k=object_indice[num_obj][0];k {
glBindTexture(GL_TEXTURE_2D, texture[object_indice [num_obj][3]]);
glBegin (GL_TRIANGLES);
for(i=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[j];
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> num_obj++;<br> }<br> glEndList();<br>} </i> <br><br>
hi
yep i see what you are doing wrong :
1)you initialize num_obj at 1
2)just after glBegin(), your loop restart from zero for each objects.

you ought to do :

1)
int num_obj=0; // =0 because the first element in an array is 0

2)
int num_triangle=0; //triangle you want to draw;

glBegin(GL_TRIANGLES);
for (i=num_triangle,i(lower than)objet_indice[num_obj][1];i++){//for example, objet_indice[0][1]=12
num_triangle++;
....


hope that help and happy coding

lunasol
Let''s say you have two textures. From texture A you only map a circle and from Texture B you only map a rectangular object. You merge them together with any graphics program (Paint, Photoshop, whatever) simply by copy pasting the two objects into one file.

If you use from Texture A the whole space and from Texture B also (doesn''t matter), then you could put them along side each other.

You could a)
leave a lot of space unused because you have to scale the texture to a valid size
or b)
mipmap the texture so that it will automatically be rescaled
c) don''t mipmap the texture but scale it manually.

You can download the Symbiotic Engine from my site, it
has a texture class that automatically resizes a texture if it has an invalid size, either by using gluBuild2DMipmaps (if you give the parameter) or gluScaleImage..

You will have to change the texture coordinates ofcourse, but that is acceptable, at least for me ;-)..


----------
Mail me, Drago's OpenGL Website
osu!
okay, i''m bringing this topic back up from the dead.

so, by lunasol''s method, you would be able to texture up to whatever triangle of the object you are on, not just the object? so, you can have multiple textures on one object, right?
and how would you specify what textures go to what faces? is the only way, by compiling and looking at the object?

should i just start another thread or continue this one? lunasol and pentode, i hope you guys are still out there, cuz i''m about to restart my 3d exploration coding.

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k

This topic is closed to new replies.

Advertisement