title: Positioning an array of objects in OpenGL
body: <p>Edit: </p>
  
  <p>I'm still not getting the correct position, all the balls are being drawn at the origin, I think I may be putting things in the wrong places... </p>
  
  <p>Ball.cpp</p>
  
  <pre><code>#include "Ball.h"
  #include "Vector2f.h"
  #include "Vector3f.h"
  #include "Glut/glut.h"
  #include "GL/gl.h"
  #include "GL/glu.h"
  
  
  Ball::Ball(void)
  {
      Vector3f Temp_position;
      position = Temp_position;
      Vector3f Temp_velocity;
      velocity = Temp_velocity;
  }
  
  
  Ball::~Ball(void)
  {
  }
  
  void Ball::SetPos(Vector3f New_position)
  {
      position = New_position;
  }
  
  
  void Ball::Draw()
  {
      glPushMatrix();
      glTranslatef(position.X(), position.Y(), position.Z());
      glColor3d(1, 0, 0);
      glutSolidSphere(0.3, 50, 50);
      glPopMatrix();
  }
  
  void Ball::ArrayPosition()
  {
  
  Ball *Yellowball = new Ball[8];
  Yellowball[0].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  Yellowball[1].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  Yellowball[2].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  Yellowball[3].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  Yellowball[4].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  Yellowball[5].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  Yellowball[6].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  Yellowball[7].SetPos(Vector3f (position.X(), position.Y(), position.Z()));
  
  }
  
  void Ball::DrawYellow()
  {
  
  glPushMatrix();
  glColor3f(2,1,0);
  glutSolidSphere(0.3, 50, 50);
  glPopMatrix();
  }
  
  void Ball::SetVel(Vector3f New_velocity)
  {
      velocity = New_velocity;
  }
  
  
  
  Vector3f Ball::GetPos()
  {
      Vector3f temp;
      temp = position;
      return temp;
  }
  
  Vector3f Ball::GetVel()
  {
      Vector3f temp;
      temp = velocity;
      return temp;
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>Ball Redball;
  float BALL_RED_START = 0;
  float RADIUS_OF_BALL = 0.3;
  float BALL_RED_END = 8;
  
  Ball Yellowball; 
  float BALL_YELLOW_START = 0;
  
  float BALL_YELLOW_END = 8;
  
  init()
  
  Ball *Yellowball = new Ball[8];
  
  for(int i = BALL_YELLOW_START; i &lt; BALL_YELLOW_START; i++)
  {
  
  Yellowball[0].SetPos(Vector3f (1,0,0));
  Yellowball[1].SetPos(Vector3f (0,0,0));
  Yellowball[2].SetPos(Vector3f (0,0,0));
  Yellowball[3].SetPos(Vector3f (0,0,0));
  Yellowball[4].SetPos(Vector3f (0,0,0));
  Yellowball[5].SetPos(Vector3f (0,0,0));
  Yellowball[6].SetPos(Vector3f (0,0,0));
  Yellowball[7].SetPos(Vector3f (0,0,0));
  }
  
  Draw method:
  
  Ball Yellowball[8];
  
  for (int i = BALL_YELLOW_START; i&lt;BALL_YELLOW_END;i++)
  {
  glColor3f(2,1,0);
  
  Yellowball[i].DrawYellow();
  
  }
  glPopMatrix();
  </code></pre>
  
  <p>The result is that is drawing the array at the origin all the balls are in the same place!</p>