help pls - rotating a 3d object
jfhtgui Wrote:I have a few other questions, though:You need to study up on projections. I have them set up so half the screen is on the left and half on the right, and same for bottom top. That way when you draw an object it is automatically in the center. That's default behavior for perspective, but you can do it for ortho too, which I left in there if you want to uncomment it.
- how does this origin end up being somewhere in the center of the screen? I can understand how that might be the case if i use a glTranslatef (xOffset, yOffset, 0), and then draw around the origin, but for this one? the glTranslatef has 0 x, and 0 y translation... Shouldnt the object be drawn around the lower left corner of the screen then (this is [0,0]???) This is number 1.
jfhtgui Wrote:- number 2 is this, which was what I was trying to ask about rotation to be done at the center of the triangle fan: when I move my mouse along x right now, I'm expecting to see the center of the fan stay. But in fact, it doesnt. Why is this so? and what's causing it?I have it rotating the pie slice based on the x movement of the mouse. You can turn that off easy. You'll have to work out the other transforms yourself though if you want it to be somewhere else on the screen. It'll be easier if you move back to glOrtho and change the projection to be so that the lower left is 0, 0.
Sorry, it's a lot of stuff to try to understand all at once, but like I mentioned earlier, you're at the steep part of the OpenGL learning curve. I will say that learning transforms is probably best learned from a book and not so much through example code. Plus, I'd like to mention that the example code that you're working from has some rather strange ways of calculating mouse positions/radiuses and other stuff. Not that you shouldn't use it, but don't be afraid to do things differently.
[adding] Honestly, if I were you I'd back off and use some other code base to learn how to transform a simple cube first. The stuff you're working with right now can make things rather confusing for you and will likely discourage you.
Possibly Related Threads...
|Rotating a clipped Texture||tfifriday||1||1,655||
Feb 3, 2009 06:00 AM
Last Post: godexsoft