Results 1 to 2 of 2

Thread: Simple animation issue--but I can't see it

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012

    Simple animation issue--but I can't see it

    Hello! I have been staring at this for hours and have played around with all of the logic and numbers and nothing seems to do what I want. I am trying to create an animation that shows how a shape or object is actually rotated in openGL... so I create an object at a particular point in space, I need to animate it moving to the origin, rotating, and then translating back. So I have been able to get the shape to move around, but once it hit the x = 0 point, instead of changing directions, it stays in a jittering mode, like the direction is continuously getting changed...but I can't seem to understand where my code is doing this. I have pretty much commented everything out so I know where the culprit is but I have no idea where I am going wrong Can anyone please help? I am doing this in baby steps, so as soon as I get the x-direction working I'll start adding in the y and z directions as well as the rotation at the origin...

    Thanks!! I have taken out all of the commented code that is not in use yet for legibility...I don't think any of it is relevant to my problem...

    Code :
    {void display(void)
    	//color buffer gets cleared everytime a new frame is drawn
    	setWindow(-9.0, 9.0, -1.0, 1.0);			// set the window
    	glTranslated(xPos, yPos, 0.0);	
    	glutWireCube(.25);  //***THIS WORKS***
    	if (xDirection==0){ //if moving left
    		xPos-=0.0005;	//move in a negative direction along the xaxis	
    	else if (xDirection==1){
    		xPos+=0.0005;	//otherwise move in the positive direction
    	if (xPos > 0.0) {	
    	else {
    int main(int argc, char** argv){
    	glutInit(&argc, argv);
    	//glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);  //double pixel buffer that holds RGB 
    	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    	glutInitWindowSize(800, 800);
    	return 0;

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2012
    Ha! It was the logic..I had to read it out case this helps anyone...
    Code :
    	if (xDirection==0 && xPos > 0.0) {
    	if (xDirection==0 && xPos < 0.0) {
    	if (xDirection==1 && xPos < 0.75) {
    	if (xDirection==1 && xPos > 0.75) {

Similar Threads

  1. Simple Animation
    By gottijay in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-24-2011, 03:38 PM
  2. Simple Box Animation Not working
    By Nano511 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-06-2011, 06:30 PM
  3. simple water animation
    By mogu in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-08-2005, 03:34 AM
  4. simple animation w/glut
    By pbrisk in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-08-2001, 03:23 AM
  5. simple animation
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-01-2001, 08:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean