Hi, i’m beginner in OpenGL coding. I have one mini problem.
I create my own gluDisk.
http://www.sdilej.eu/pics/274a90360f9c46e2eaf94e095e0b6223.png
But i need it set to ground = horizontally(now is vertically)
i trying
glRotatef(90, x1, y1, z1);
But it isn’t work…
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: http://www.sdilej.eu/pics/69721aa237608b423b635945d430e561.png
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.