ARToolKit | Mailing List Archive |
![]() |
From: | "BSS" <BegoSS@t ..........> | Received: | May 19, 2004 |
To | <artoolkit@h ..................> | ||
Subject: | I need to aply a texture to my 3D object | ||
hello again, I'm loading a 3d object from a .3ds file. I'm doing it successfully so I can see over the marker my object. The problem is that I'm also loading the texture (a .bmp file) for that object and when drawing the object I go thru this two lines (more or less )for rendering the texture : glEnable(GL_TEXTURE_2D) and glBindTexture( GL_TEXTURE_2D, ID), where ID is the identification of the texture.....but....... this is not working!!! I've been surfing on the web and I could find some examples for mapping textures using OpenGl and actually I could get an example to work==> this just create a regular window, load the 3d object, apply lights and render....sooo, this is making me think that there must be some option when drawing the video frame or even when creating the window that disable the texture for the object.....did anyone try it before?? I don't know too much about OpenGl so....I don't know where in the whole code I have to look for, please help!!!! |
From: | Robert Hinn <exodus@o ........> | Received: | May 19, 2004 |
To | |||
Subject: | Re: I need to aply a texture to my 3D object | ||
BSS schrieb: > hello again, Hi, > I'm loading a 3d object from a .3ds file. I'm doing it successfully so I > can see over the marker my object. The problem is that I'm also loading the > texture (a .bmp file) for that object and when drawing the object I go thru > this two lines (more or less )for rendering the texture : > glEnable(GL_TEXTURE_2D) and glBindTexture( GL_TEXTURE_2D, ID), where ID is > the identification of the texture.....but....... this is not working!!! > I've been surfing on the web and I could find some examples for mapping > textures using OpenGl and actually I could get an example to work==> this > just create a regular window, load the 3d object, apply lights and > render....sooo, this is making me think that there must be some option when > drawing the video frame or even when creating the window that disable the > texture for the object.....did anyone try it before?? I don't know too much > about OpenGl so....I don't know where in the whole code I have to look for, > please help!!!! Hm, is your texture size (height and width, not filesize) a power of 2? (128x128, 256x256, 512x512, etc.) If not, then that might be your problem. OpenGL usually requires textures to have a width and height which is a power of 2... By the way, you can find several good OpenGL tutorials at: http://nehe.gamedev.net (that site has nothing to do with augmented reality, but you can find examples for many OpenGL related topics there...) Hope I could help, Robert |
From: | "BSS" <BegoSS@t ..........> | Received: | May 19, 2004 |
To | "Robert Hinn" <exodus@o ........> | ||
Subject: | RE: I need to aply a texture to my 3D object | ||
thanks robert, but when I load the same object and the same texture in the example I can get to work, I can see it, so.... It must be any other stuff. By the way, right now I'm loading a simple sphere with a regular picture as texture..so I don't know what is wrong when I try to do it in my application. any other clues? Begona.- -----Mensaje original----- De: owner-artoolkit@h .................. [mailto:owner-artoolkit@h ..................]En nombre de Robert Hinn Enviado el: miercoles, 19 de mayo de 2004 23:35 CC: artoolkit@h .................. Asunto: Re: I need to aply a texture to my 3D object BSS schrieb: > hello again, Hi, > I'm loading a 3d object from a .3ds file. I'm doing it successfully so I > can see over the marker my object. The problem is that I'm also loading the > texture (a .bmp file) for that object and when drawing the object I go thru > this two lines (more or less )for rendering the texture : > glEnable(GL_TEXTURE_2D) and glBindTexture( GL_TEXTURE_2D, ID), where ID is > the identification of the texture.....but....... this is not working!!! > I've been surfing on the web and I could find some examples for mapping > textures using OpenGl and actually I could get an example to work==> this > just create a regular window, load the 3d object, apply lights and > render....sooo, this is making me think that there must be some option when > drawing the video frame or even when creating the window that disable the > texture for the object.....did anyone try it before?? I don't know too much > about OpenGl so....I don't know where in the whole code I have to look for, > please help!!!! Hm, is your texture size (height and width, not filesize) a power of 2? (128x128, 256x256, 512x512, etc.) If not, then that might be your problem. OpenGL usually requires textures to have a width and height which is a power of 2... By the way, you can find several good OpenGL tutorials at: http://nehe.gamedev.net (that site has nothing to do with augmented reality, but you can find examples for many OpenGL related topics there...) Hope I could help, Robert |
From: | Robert Hinn <exodus@o ........> | Received: | May 20, 2004 |
To | artoolkit@h .................. | ||
Subject: | Re: I need to aply a texture to my 3D object | ||
BSS schrieb: > thanks robert, but when I load the same object and the same texture in the > example I can get to work, I can see it, so.... It must be any other stuff. > By the way, right now I'm loading a simple sphere with a regular picture as > texture..so I don't know what is wrong when I try to do it in my > application. > any other clues? Well, I just tried some simple texture mapping in the simpleTest example that comes with ARToolKit and it seems to work. Maybe you can just check if your texture works with a simple polygon before trying to apply it to your .3ds object, e.g.: (instead of "glutSolidCube(50.0);" in the "draw()" function in "simple.c") glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, texture[0] ); glTexImage2D( GL_TEXTURE_2D, 0, 3, textureWidth, textureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, textureData ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glBegin( GL_POLYGON ); glVertex3f( -25.0f, -25.0f, 0.0f ); glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 25.0f, -25.0f, 0.0f ); glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 25.0f, 25.0f, 0.0f ); glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -25.0f, 25.0f, 0.0f ); glTexCoord2f( 0.0f, 1.0f ); glEnd(); That way you can make sure that your texture works. There could be several reasons why your texture isn't working, e.g.: - your texture width and height are not a power of 2 and your example program uses a workaround (e.g. internally using a larger texture (like 1024x1024), copying your image into it and then using texture coordinates to only select the part of the large texture with your image in it... this is a popular trick for using textures that have an invalid size) - your .3ds object doesn't set texture coordinates (the glTexCoord2f() calls in the above code tell OpenGL which point of the texture image corresponds to which object vertex) I haven't worked with .3ds objects, yet (at least not directly with OpenGL)... Cheers, Robert > Begona.- > > -----Mensaje original----- > De: owner-artoolkit@h .................. > [mailto:owner-artoolkit@h ..................]En nombre de Robert Hinn > Enviado el: miercoles, 19 de mayo de 2004 23:35 > CC: artoolkit@h .................. > Asunto: Re: I need to aply a texture to my 3D object > > > BSS schrieb: > >>hello again, > > > Hi, > > >> I'm loading a 3d object from a .3ds file. I'm doing it successfully so I >>can see over the marker my object. The problem is that I'm also loading > > the > >>texture (a .bmp file) for that object and when drawing the object I go > > thru > >>this two lines (more or less )for rendering the texture : >>glEnable(GL_TEXTURE_2D) and glBindTexture( GL_TEXTURE_2D, ID), where ID is >>the identification of the texture.....but....... this is not working!!! >>I've been surfing on the web and I could find some examples for mapping >>textures using OpenGl and actually I could get an example to work==> this >>just create a regular window, load the 3d object, apply lights and >>render....sooo, this is making me think that there must be some option > > when > >>drawing the video frame or even when creating the window that disable the >>texture for the object.....did anyone try it before?? I don't know too > > much > >>about OpenGl so....I don't know where in the whole code I have to look > > for, > >>please help!!!! > > > Hm, is your texture size (height and width, not filesize) a power of 2? > (128x128, 256x256, 512x512, etc.) > If not, then that might be your problem. OpenGL usually requires > textures to have a width and height which is a power of 2... > By the way, you can find several good OpenGL tutorials at: > http://nehe.gamedev.net > (that site has nothing to do with augmented reality, but you can find > examples for many OpenGL related topics there...) > > Hope I could help, > Robert > > |
From: | "BSS" <BegoSS@t ..........> | Received: | May 20, 2004 |
To | "Robert Hinn" <exodus@o ........>, <artoolkit@h ..................> | ||
Subject: | RE: I need to aply a texture to my 3D object | ||
guys!!!!! don't know why but this thing suddenly worked !!!! well, I just discover I was loading the texture before creating the window, a fact I didn't think was so important...uppsss now, I'm able to see the texture in the simple sphere...so my challenge will be mapping different textures in a virtual laboratory I have made using 3ds max. wish me luck!!! otherwise I'll be around here and other forums bothering people. Thanks a lot to all you guys!!! sincerely Begona.- the happiest one, right now!! hehe -----Mensaje original----- De: owner-artoolkit@h .................. [mailto:owner-artoolkit@h ..................]En nombre de Robert Hinn Enviado el: jueves, 20 de mayo de 2004 17:26 Para: artoolkit@h .................. Asunto: Re: I need to aply a texture to my 3D object BSS schrieb: > thanks robert, but when I load the same object and the same texture in the > example I can get to work, I can see it, so.... It must be any other stuff. > By the way, right now I'm loading a simple sphere with a regular picture as > texture..so I don't know what is wrong when I try to do it in my > application. > any other clues? Well, I just tried some simple texture mapping in the simpleTest example that comes with ARToolKit and it seems to work. Maybe you can just check if your texture works with a simple polygon before trying to apply it to your .3ds object, e.g.: (instead of "glutSolidCube(50.0);" in the "draw()" function in "simple.c") glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, texture[0] ); glTexImage2D( GL_TEXTURE_2D, 0, 3, textureWidth, textureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, textureData ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glBegin( GL_POLYGON ); glVertex3f( -25.0f, -25.0f, 0.0f ); glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 25.0f, -25.0f, 0.0f ); glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 25.0f, 25.0f, 0.0f ); glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -25.0f, 25.0f, 0.0f ); glTexCoord2f( 0.0f, 1.0f ); glEnd(); That way you can make sure that your texture works. There could be several reasons why your texture isn't working, e.g.: - your texture width and height are not a power of 2 and your example program uses a workaround (e.g. internally using a larger texture (like 1024x1024), copying your image into it and then using texture coordinates to only select the part of the large texture with your image in it... this is a popular trick for using textures that have an invalid size) - your .3ds object doesn't set texture coordinates (the glTexCoord2f() calls in the above code tell OpenGL which point of the texture image corresponds to which object vertex) I haven't worked with .3ds objects, yet (at least not directly with OpenGL)... Cheers, Robert > Begona.- > > -----Mensaje original----- > De: owner-artoolkit@h .................. > [mailto:owner-artoolkit@h ..................]En nombre de Robert Hinn > Enviado el: miercoles, 19 de mayo de 2004 23:35 > CC: artoolkit@h .................. > Asunto: Re: I need to aply a texture to my 3D object > > > BSS schrieb: > >>hello again, > > > Hi, > > >> I'm loading a 3d object from a .3ds file. I'm doing it successfully so I >>can see over the marker my object. The problem is that I'm also loading > > the > >>texture (a .bmp file) for that object and when drawing the object I go > > thru > >>this two lines (more or less )for rendering the texture : >>glEnable(GL_TEXTURE_2D) and glBindTexture( GL_TEXTURE_2D, ID), where ID is >>the identification of the texture.....but....... this is not working!!! >>I've been surfing on the web and I could find some examples for mapping >>textures using OpenGl and actually I could get an example to work==> this >>just create a regular window, load the 3d object, apply lights and >>render....sooo, this is making me think that there must be some option > > when > >>drawing the video frame or even when creating the window that disable the >>texture for the object.....did anyone try it before?? I don't know too > > much > >>about OpenGl so....I don't know where in the whole code I have to look > > for, > >>please help!!!! > > > Hm, is your texture size (height and width, not filesize) a power of 2? > (128x128, 256x256, 512x512, etc.) > If not, then that might be your problem. OpenGL usually requires > textures to have a width and height which is a power of 2... > By the way, you can find several good OpenGL tutorials at: > http://nehe.gamedev.net > (that site has nothing to do with augmented reality, but you can find > examples for many OpenGL related topics there...) > > Hope I could help, > Robert > > |