Jump to content
  • Advertisement
Sign in to follow this  
SnowMoo

Position of Object

This topic is 3770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
In the case of glutSolidSphere, there is no object. The function uses lower level OpenGL calls to "send" the shape of a sphere to the graphics card. It does not record anywhere that you sent a sphere.

You could do something like this:



class sphere
{
private:
float radius;
float xpos,ypos,zpos;
public:
sphere(float R,X,Y,Z)
{
xpos = X; ypos = Y; zpos = Z;
radius = R;
}


draw()
{
glPushMatrix();
glTranslatef(x,y,z);
glutSolidSphere(radius);
glPopMatrix();
}
};




Then just create an array of spheres, and call the draw() method when you want to draw it, and add some member functions to get the position. On each update of the game you move your spheres and / or read their positions, and when you render you simply call the draw function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!