?
Solved

Texture Mapping OpenGl

Posted on 2003-03-02
5
Medium Priority
?
3,186 Views
Last Modified: 2012-06-27
Hi,
I need to do a texture mapping on a 3D object,
cube mapping,sphere mapping and cylinder mapping.
My program now,includes the ability to load
*.skl format,then *.obj/*.off and then *.wgt(weights
file).
I have hierarchy window which has a tree of all the
skeleton bone heirarchy,i have also sidebar with bitmaps
buttons,and a toolbar with three buttons(cube,sphere,cylinder).
for example:
When i choose cube from toolbar,then one of the bmp file
by pushing the specific bitmap button,and then push a bone from the hierarchy window, after that the chosen bone should be with the specific texture.
Any help with some algorithm,explane about the three
texture mapping technics (projection calculate),opengl code...

Thanks a lot.
0
Comment
Question by:dani333
  • 3
  • 2
5 Comments
 

Accepted Solution

by:
JackNCalvin earned 200 total points
ID: 8127767
Dani333:

I created an openGl 3d maze program that uses texture mapping.  I have an init function, where I initialize the settings for appropriate texture mapping:

  /* read in texture example */
  /* you can try some of the smaller image files (e.g., mandrill2.rgb,
     mandrill3.rgb) to see if they are faster */
  //read_image("brick.rgb");

  /* set up texture environment */
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

  /* The texture can either modulate or decal the floor */
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

  /* We repeat the textures rather than clamping them to tile the floor*/
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

  /* GL_NEAREST might be faster, but you get aliasing */
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

  /* GL_LINEAR should do a better job of interpolating textures */
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  /* set our fine texture */
  glTexImage2D(GL_TEXTURE_2D, 0, *components,  *width,*height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_texture);

----------------------------------------------

Then when you want to draw the texture object in another function you need to enable it.  Here I am texture mapping a floor:

  glColor4f(1.0, 1.0, 1.0, 0.0);
  glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);
      glTexCoord2f(world.xmax, world.zmax);
      glVertex3f(world.xmin, -0.01, world.zmin);

      glTexCoord2f(world.xmin, world.zmax);
      glVertex3f(world.xmax, -0.01, world.zmin);

      glTexCoord2f(world.xmin, world.zmin);
      glVertex3f(world.xmax, -0.01, world.zmax);

      glTexCoord2f(world.xmax, world.zmin);
      glVertex3f(world.xmin, -0.01, world.zmax);
    glEnd();
  glDisable(GL_TEXTURE_2D);

------------------------------------

If you still have questions, or my code is hard to read let me know and I can give you the URL to the full source code of the program.  

Hope this helps!!!

-Jack-
0
 

Author Comment

by:dani333
ID: 8130616
Hi,
Thanks for your help,please send me your
URL with the full source code of the program.

Thanks again:-)
0
 

Author Comment

by:dani333
ID: 8146100
Don't forget give me your URL.
Thanks...
0
 

Expert Comment

by:JackNCalvin
ID: 8151567
dani333:

Sorry about the delay.  I was away for the past couple days.  Here are the URLs:

http://www.cse.psu.edu/~jmeyer/maze/

The main file is maze2.cpp.  Have fun :)

-jack-
0
 

Author Comment

by:dani333
ID: 8152279
Thanks I have another problem...

Lets say I have 3d object like an human body ,
on this object i'm applying some diffrent texture, some of the texture will be blended with each other on the intersections parts,
now that all the textures are applied on the object i want
to save the texture in (one!) bitmap file and of course remap the u,v coordinates of the object to correspond
to the new merged texture.
how can i do it ?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question