Hi guys,
I just want to texture an object that is created by reading vertices from a data file. I read the file for vertices load the vertices to my glDraw function but when I try to apply a texture to my generated object , I don’t quite get what I want as an output.
The output is my object with my texture on it but in “slices”. It’s as if my object is generated from a lot of cones where the sum of each cone’s circumference represents the outer surface of my object. So my texture is applied to each cone and not to the whole object, uniformally.
I have tried using automatic texture generation as well but the output remains the same.
Right now I’m guessing that the vertices that i put into the glVertex function should be manipulated somehow (glVertex(sin(x),cos(y),sin(z)).
Another (general this time) question, how can I upload to the forum a picture from file (not from a URL) so that you all can see what I’m talking about.
Maybe I can do what I want with bezier curves?
Any ideas guys?
Cheers
Here is the latest source:
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);// Clear The Screen And The Depth Buffer
GL.glLoadIdentity(); // Reset The View
GL.glEnable(GL.GL_TEXTURE_2D);
GL.glBindTexture(GL.GL_TEXTURE_2D, textures[0]);
GL.glTranslatef(cx, cy, cz); // Translate The The Current Position To Start Drawing
GL.glRotatef(xrot, 1, 0, 0); // Rotate On The X Axis By xrot
GL.glRotatef(yrot, 0, 1, 0); // Rotate On The Y Axis By yrot
GL.glRotatef(zrot, 0, 0, 1); // Rotate On The Z Axis By zrot
xrot += xspeed;
yrot += yspeed;
zrot += zspeed; // Increase xrot, yrot & zrot by xspeed, yspeed & zspeed
float tx, ty, tz; // Temp X, Y & Z Variables
Vertex q; // Holds Returned Calculated Values For One Vertex
float[] t=new float[2];
float[] xyz=new float[3];
GL.glBegin(GL.GL_POLYGON);
for (int i=0; i < morph1.verts; i++)
{
if (morph)
q = calculate(i);
else
q.x = q.y = q.z = 0; // If morph Is True Calculate Movement Otherwise Movement=0
helper.points[i].x -= q.x; // Subtract q.x Units From helper.points[i].x (Move On X Axis)
helper.points[i].y -= q.y; // Subtract q.y Units From helper.points[i].y (Move On Y Axis)
helper.points[i].z -= q.z; // Subtract q.z Units From helper.points[i].z (Move On Z Axis)
tx = helper.points[i].x; // Make Temp X Variable Equal To Helper's X Variable
ty = helper.points[i].y; // Make Temp Y Variable Equal To Helper's Y Variable
tz = helper.points[i].z; // Make Temp Z Variable Equal To Helper's Z Variable
GL.glTexCoord2f(((float)Math.Sin(tx))*((float)Math.Cos(tx)),((float)Math.Sin(ty))*((float)Math.Cos(ty)));
GL.glVertex3f(tx,ty,tz);
}
GL.glEnd();
uint error = GL.glGetError();
if(error != GL.GL_NO_ERROR)
{
Console.WriteLine(error);
}
else {Console.WriteLine("No error occured");}
GL.glDisable(GL.GL_TEXTURE_2D);
GL.glFlush();
}