Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 26 Jun 2012
Offline Last Active Jun 27 2012 09:11 AM

Posts I've Made

In Topic: Keyboard triggers animation

27 June 2012 - 09:09 AM

Yeah, I know, my doubt is more related to basic programming than anything else.

Now I did read the links you recommended properly, and I'm starting to understand a bit more about the problems related to floating comparisons (although it looks like I'm way too noob to get some of those stuff as of now). And a TimerFunc, in the case I need, looks a better option (than an IdleFunc).

Thanks for your reply, 'cause it opened my eyes to problems I didn't know existed. I'll just test and study more to get to the result I want.

In Topic: Keyboard triggers animation

27 June 2012 - 07:29 AM

Sorry, hadn't seen the code was still posted broken. I'll try it again:

[source lang="cpp"]void Timer(int value){ if (posInitialxObject == -1.5) { while (posInitialxObject != posFinalxObject) posInitialxObject += -0.1; } else { while (posFinalxObject != posInitialxObject) posInitialxObject -= -0.1; } glutPostRedisplay(); glutTimerFunc(33, Timer, 1);}[/source]

The -1.5 was the initial X position of the object on the screen. Until that position was different then -2.3, the X variable should decrease -0.1, making it translate. Now I've created two global variables w/ the initial and final position, so I'm comparing these two.

In Topic: Keyboard triggers animation

26 June 2012 - 02:33 PM

I'm sorry, my Timer function didn't appear correctly, so I'm posting it here:

[source lang="cpp"]void Timer(int value) { if (positionObject == -1.5) { while (positionObject <= -2.3) positionObject += -0.1; } else { while (positionObject != -1.5) positionObject -= -0.1; } glutPostRedisplay(); glutTimerFunc(33, Timer, 1);}[/source]

In Topic: Rotating specific .obj with keyboard key

26 June 2012 - 08:42 AM

Guys, thank you all for your answer. All your considerations were basically right, and now it is rotating perfectly. The main problem was that I wasn't applying glRotate when the object was first called and rendered.

You guys rock.. thanks once again!