Jump to content

  • Log In with Google      Sign In   
  • Create Account


Circles


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 digitalerr0r   GDNet+   -  Reputation: 122

Like
Likes
Like

Posted 18 October 2001 - 04:44 AM

Hey, I have a Question. How do I make a object to move around in cricles...let''s say the I have a Sun, and some planets...how can I then make the planets to move around the sun ? The =)

Sponsor:

#2 ncsu121978   Members   -  Reputation: 444

Like
Likes
Like

Posted 18 October 2001 - 04:50 AM

look into using sin and cos

"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T

#3 Sebbi   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 October 2001 - 08:26 AM

i think that it is the best thing to use the glRotate functions to rotate objects around a circle ...

the example of a solarsystem is good for explaining it ... may be you set the sun into the origin of the coordsystem ... then you declare a variable holding the angle of the planet and you increment it every frame ... you will give that variable as the angle parameter to the glRotate function ... but first you have to translate the object about the radius away from the origin with the glTranslate function after that you have to rotate ...

but you have to implement it the other way round ...

-> first rotate
-> than translate

...

hope it helps ... you can do it of course with the help of sin and cosine but therefore you have a lot of calculation that is not nessecary ...

cu




#4 digitalerr0r   GDNet+   -  Reputation: 122

Like
Likes
Like

Posted 18 October 2001 - 10:06 AM

Thx for the help, i''l try these things out =)

#5 Jankey   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 October 2001 - 10:29 PM

ämm ...
whats about sin & cos ?
somewhere in the DrawGLScene

void DrawGLScene()
{

blabla;

rot += 0.001f; // Global Defined!! -> GLfloat rot = 0.0;

obejct.x = sin( rot / speed ) * Radius;
obejct.y = 0.0;
obejct.x = cos( rot / speed ) * Radius;

glTranslatef(obejct.x , obejct.y , obejct.z );

// The works!

blabla;

}

#6 Vlion   Members   -  Reputation: 151

Like
Likes
Like

Posted 21 October 2001 - 05:52 PM

i used:

x = (a)sin(time)
y = (b)cos(time)
glTranslate(x,y,z);

Vary the a and b vars and you come up with a ellipse.

If its just basic shaded spheres you really dont need to worry about rotating.

I actually have some elementry solar system code laying around, if you care to look at it.
(pdn@rmci.net)



I came, I saw, I got programmers block.
~V''''lion

#7 digitalerr0r   GDNet+   -  Reputation: 122

Like
Likes
Like

Posted 22 October 2001 - 07:43 AM

got it to work now, hehe...sin and cos are damn cool(and helpfull) =))

cya, and thx for all the replays!!§

#8 ANSI2000   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 October 2001 - 08:57 AM

YEah helpfull but very slow... If you wish to do it the math way... Pre compute your angles in an array.

The Rotate and transalte method will be alot faster though.

1- Translate your sun to the "middle" of the scene.
2- For each planet push matrix stack glRotate and glTranslate pop matrix stack.

glTranslate // Transform Scene
glRotate // TrasnFor Scene
glScale // Transform Scene

glPushMatrix
glTranslate
draw sun

for each planet
{
glPushMatrix
glRotate
glTranslate
draw planet
glPopMatrix
}glPopMatrix



Edited by - ANSI2000 on October 22, 2001 4:01:51 PM

#9 Ranger_One   Members   -  Reputation: 300

Like
Likes
Like

Posted 22 October 2001 - 09:10 AM


Don''t know how complex your simulation will become- but here is 1 limitation I found myself:

Do the positioning of the objects yourself in OpenGL. This way you can do accurate depth testing of objects and force a proper draw order.

Here is my rant:

I have a OpenGL driven 3d engine and was developing an advanced blending effects demo. In this demo I had three objects, one blended textured quad in the center, one transparent quad in the back, and some texture text in the front. The entire scene was rotated using glRotate().
Everything would work fine until the object in the back was rotated in the front, then it would actually become solid and block the other objects. After struggling for a bit- I discovered the cause. I was using the GL standard DEPTH_TEST, and when the first object drawn is in the front, it cause the other objects to fail the DEPTH_TEST and not be rendered.
My FIX: Rotate/Transform the objects using matrix math (like OpenGL would)- then use fast sqrt functions to figure the depth and qsort the objects from back to front, so the draw order is always proper.

My two cents,
Ranger



#10 cMADsc   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 October 2001 - 10:50 AM

This post came at a good time. I am making a solar system demo right now, just the sun and 9 planets for now. I currently use glPop and glPush for each planet. Although, doesn''t all the pushing and popping add to the overall time?


-----------------------------
"There are ones that say they can and there are those who actually do."

"...u can not learn programming in a class, you have to learn it on your own."






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS