glutDisk Rotation problem...

Hi, i’m beginner in OpenGL coding. I have one mini problem.
I create my own gluDisk.

But i need it set to ground = horizontally(now is vertically)

i trying

glRotatef(90, x1, y1, z1);

But it isn’t work… :frowning:

But it isn’t work…

That does not tell us how it is not working, making it difficult to decide what the problem could be.
What are the values of x1, y1, z1, in other words: around what axis are you rotating?
In general I’d say it is the right approach to have a function that generates geometry in a given way and then transform it into the needed position/orientation. However, since you are writing the function yourself, you should be able to create the vertices in the x/z plane (I’m guessing that is what you mean by ground) instead of the x/y plane.

x1, y1, z1 = Position of Mouse… is for terrain mapping…

Look screen in first post…and after:

Sorry for next posts…

In 90 degress…some bug…now it must be horizontally…but isn’t

Don’t rotate around the mouse position vector. You probably want to translate to the mouse position to put the disk shape in the right position, but to orient it you need to rotate around an axis that puts it in the same coordinate plane as the ground.
To find that you need two pieces of information: the coordinate plane your function draws the disc shape in (looks like it’s x/y, but can you confirm please?). The other is the plane you wan to rotate into, i.e. the plane that matches the ground at the mouse position.
If your ground is flat, it probably lies in a coordinate plane (x/z ?) itself and you just need to rotate around the x axis. If the ground is not flat you need the normal of the ground at the mouse position and then find a rotation that makes your disk shape’s normal match the ground normal. Your favourite search engine should be able to find you a suitable algorithm to compute such a rotation.

My code:

void renderDisk(float x1, float y1, float z1, float x2,float y2, float z2, float radius,int subdivisions,GLUquadricObj *quadric)
float vx = x2-x1;
float vy = y2-y1;
float vz = z2-z1;

//handle the degenerate case of z1 == z2 with an approximation
if( vz == 0.0f )
vz = .0001f;

float v = sqrt( vxvx + vyvy + vzvz );
float ax = 57.2957795f
acos( vz/v );
if ( vz < 0.0f )
ax = -ax;
float rx = -vyvz;
float ry = vx

//draw the quadric

glTranslatef(x1, y1, z1);
glRotatef(ax, rx, ry, 0.1);

gluQuadricOrientation(quadric, GLU_OUTSIDE);

gluDisk(quadric, radius - 0.25, radius + 5.0, subdivisions, 5);

void renderDisk_convenient(float x, float y, float z, float radius,int subdivisions)
//the same quadric can be re-used for drawing many objects
// Mouse opacity
glColor4f( 0.0f, 7.5f, 0.0f, 0.5f );
GLUquadricObj *quadric=gluNewQuadric();
gluQuadricDrawStyle(quadric, GLU_LINE);
gluQuadricNormals(quadric, GLU_SMOOTH);