View Full Version : Texture on a disk

Zelig63

01-25-2013, 07:23 AM

I have defined a disk with a triangle fan and I want to put a texture on it. Unfortunately, I can't figure out how to define the texture coordinates.

Can anyone help me?

Thanks in advance for the time you will spend trying to help me.

tonyo_au

01-26-2013, 10:13 PM

It depends on how you want to texture. Do you want to drap a square raster over the circle?

Zelig63

01-27-2013, 01:28 AM

It depends on how you want to texture. Do you want to drap a square raster over the circle?

My texture image represents a circular picture and I want this circular area to be drawn on the surface of my disk. Let's say I want to put the texture on both faces of a coin.

tonyo_au

01-27-2013, 05:03 PM

Then the center of your disk has UV if 0.5,0.5 and the other vertices lie on a circle where the vertex (radius,0,0) maps to UV (1,0.)

Zelig63

01-30-2013, 09:47 AM

Then the center of your disk has UV if 0.5,0.5 and the other vertices lie on a circle where the vertex (radius,0,0) maps to UV (1,0.)

Sorry but I don't understand your answer. :o

My disk is made of n triangles, and triangle i has the center of the disk as the first vertex, (radius*cos((i-1)*a),radius*sin((i-1)a)) as second vertex and (radius*cos(i*a),radius*sin(i*a)) for third vertex. Can you please explicitely tell me what the texture coordinates should be to have the disk drawn in my texture image to be pasted over my 3D disk?

tonyo_au

01-30-2013, 03:18 PM

If my maths is right, the each vertex the uv will be( (cos((i-1)*a)+1)/2, (sin((i-1)a)+1)/2)

Zelig63

01-31-2013, 09:19 AM

Then your math is wrong...

tonyo_au

01-31-2013, 09:40 PM

I don't think so

double a = DEGREES2RADIANS(45);

float ox = 200;

float oy = 200;

float r = 100;

glBegin(GL_TRIANGLE_FAN);

glColor3f(0.5,.5f,0.0f);

glVertex3f(ox,oy,0);

for (int i = 0; i < 7; i++)

{

float u = (float(cos((i-1)*a))+1.0)/2.0;

float v = (float(sin((i-1)*a))+1.0)/2.0;

float cx = float(cos((i-1)*a)) * r;

float cy = float(sin((i-1)*a))* r;

glColor3f(u,v,0);

glVertex3f(cx+ox,cy+oy,0);

}

glEnd();

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.