View Full Version : 1D Texture mapping
01-09-2006, 03:32 AM
Can someone please tell me, where can i find good tutorials for 1D TEXTURE MAPPING, with a few examples? I am in desperate need for this.
I'm sure you could find plenty of examples of 1D texture mapping on this site. But it's really quite simple. It's really no different than 2D, 3D, and CUBE mapping, in the sense that you need to define an appropriate texture, create some geometry, supply or generate texture coordinate, then draw.
Can you post the code you're having trouble with, or can you be more specific in your query?
The "RedBook" has examples of most the basic concepts. This chapter covers texture mapping:
01-09-2006, 07:39 PM
Hi Smiley, given below, is my code to create a Cone:
float bottomRadius = 0.75 , topRadius = 0.0, height = 1.5, sliceCount = 102;
float theta1, theta2, X1, Y1, X2, Y2, X3, Y3, X4, Y4;
for(count = 0; count < sliceCount; count++)
theta1 = (float)(((360*count/sliceCount))*3.141592/180);
theta2 = (float)(((360*(count+1)/sliceCount))*3.141592/180);
X1 = bottomRadius*(float)cos(theta1);
Y1 = bottomRadius*(float)sin((double)theta1);
X2 = topRadius*(float)cos((double)theta1);
Y2 = topRadius*(float)sin((double)theta1);
X3 = topRadius*(float)cos((double)theta2);
Y3 = topRadius*(float)sin((double)theta2);
X4 = bottomRadius*(float)cos((double)theta2);
Y4 = bottomRadius*(float)sin((double)theta2);
glVertex3f(X1, Y1, 0);
glVertex3f(X2, Y2, height);
glVertex3f(X3, Y3, height);
glVertex3f(X4, Y4, 0);
glPopMatrix();Cone in the image below is the desired appearance of my cone. Could you help me please?
Have you looked at planar projections? Pick an intermediate plane (probably axis aligned) to project to and generate coordinates with. This is how games can get textures to tile seamlessly across adjacent polygons that aren't coplanar for example.
You can use OpenGL's texgen functionality to do this or you can manually project, scale and translate your vertexes on a suitable plane for precalculated texcoords.
If I understand the outcome you want, you could project your cone onto the positive and negative z axes (view forward), scale the resulting coordinates to the range [-1/2,1/2], then translate to [0,1].
Mind that you will see some "stretch" in your texture off-axis, but this is to be expected with a projection like this. Polygons perpendicular to the projection plane will see infinite stretch.
Think of it as light stretched out on the cone in the late afternoon, through a rectangular yellow glass window. The window's plane is the intermediate plane for the projection.
Does any of this make sense? I understand it, but sometimes I can confuse even myself :D
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.