?
Solved

Texture Mapping OpenGl

Posted on 2003-03-02
5
Medium Priority
?
3,134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 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