Arraying 'Particles' around a sphere
GLvoid DrawParticle()
{
for(ploop=0;ploop<MAXPARTICLES;ploop++) // MAXPARTICLES = 10
{
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, bmptexture[11]); // Bind Texture 11
if (particle[ploop].active) // If the particle is active
{
glRotatef(rot, 0.0f, 0.0f, 1.0f); // Rot is Global Variable
glTranslatef(4.0f, 0.0f, 0.0f); // of type float declarded at 0.0f.
glColor4f(particle[ploop].r, particle[ploop].g, particle[ploop].b, particle[ploop].life);
glBegin(GL_TRIANGLE_STRIP); // DRaws a Triange Strip Quad
glTexCoord2d(1,1); glVertex3f( 0.5f, 0.5f, 0.0f); // Top Right
glTexCoord2d(0,1); glVertex3f(-0.5f, 0.5f, 0.0f); // Top Left
glTexCoord2d(1,0); glVertex3f( 0.5f,-0.5f, 0.0f); // Bottom Right
glTexCoord2d(0,0); glVertex3f(-0.5f,-0.5f, 0.0f); // Bottom Left
glEnd(); // Finished Drawing Triangle Strip Quad
}
rot = rot + 0.0052f; // Add 0.0052f to ''rot'' variable
glPopMatrix();
}
}
Basically, I''ve got a sphere, and I''m trying to array these particles around it, to generate a short of halo effect. Problem is, when I do this, it just maps every ''particle'' over the other, so I end up with a nasty white cube rotating around the sphere. I''ve incremented rot - as you can see, but it just dosen''t work. I''ve written down the statements logicially and traced what I think to be the way they should draw the particles, but it dosen''t seem to be working :\
Any help (Code specifially) greatly appericated
Thanks
plates.
Hi!!
I am having trouble seeing that the above code will draw anything but a bunch of particles in the same place, but it might be me....
All you hva to do is figure out how to make a sphere, and then you recode your draw function so it draw s sphere...sortof....
Almost like drawing a sphere iwth just points instead of tris...
Damn that was stocky explained....
Hope you got something out of it....
- -- ---[XaOs]--- -- -
[ project fy ]
I am having trouble seeing that the above code will draw anything but a bunch of particles in the same place, but it might be me....
All you hva to do is figure out how to make a sphere, and then you recode your draw function so it draw s sphere...sortof....
Almost like drawing a sphere iwth just points instead of tris...
Damn that was stocky explained....
Hope you got something out of it....
- -- ---[XaOs]--- -- -
[ project fy ]
just a quick note: NEVER use translate/rotate per particle. Calculate position on CPU and then send this coordinats to openGL. This is MUCH faster.
and you can generate points on sphere like:
x = sin( alpha ) * cos( beta ) * radius
y = cos( alpha ) * cos( beta ) * radius;
z = sin( beta ) * radius;
There are more worlds than the one that you hold in your hand...
and you can generate points on sphere like:
x = sin( alpha ) * cos( beta ) * radius
y = cos( alpha ) * cos( beta ) * radius;
z = sin( beta ) * radius;
There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
January 06, 2002 07:25 AM
i dont understand.. if you calculate the position, you still have to translate per pixel!
and if you dont want the particles to always face the camera you still have to rotate them all...
I did this too.. i wanted to make a cool looking sun so..
and if you dont want the particles to always face the camera you still have to rotate them all...
I did this too.. i wanted to make a cool looking sun so..
for(ploop=0;ploop{
???
???
"There is a $500 fine for detonating explosives within the confines of a city"
unfortunatly what I pasted in seems to have been truncated, but rest assured, it should be a proper for loop
Xaos: Could you explain what you mean? How you arrived at the conculsion that it only draws particles in the same place (which it does) because I am obviously missing something fairly fundemental in whats actually going on
Thanks

Xaos: Could you explain what you mean? How you arrived at the conculsion that it only draws particles in the same place (which it does) because I am obviously missing something fairly fundemental in whats actually going on

You''re an idiot if you translate each particle when you know the corrdinates instead of just using glVertex3f with the position, or better yet, using vertex arrays.
Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
Your rotation value seems to be very small. Unless you''ve got a ton of particles, you''re not going very far around your circle. glRotate takes Degrees not Radians.
You really ought to calc the value yourself, tho. much faster.
You really ought to calc the value yourself, tho. much faster.
like ATronic said : Use glVertex3f with the position and you don''t need to translate per particle or use VA. About facing camera: you method is .. well.. lame. It only works if you''re facing Z (0,0,1)... try finding some info on billboarding.
You should never let your fears become the boundaries of your dreams.
Hi!
It wasn't really hard to see that the particles would show up in the same place....
I am pretty sure that I was not the only one noticing that...
It's basicly because of this line :
(Well....not just because of that one...but you don't do anything else in the code for placing them so in your code it's because of this line)
If you don't change the pos of anything, they will show up in the same place....
Take Care
- -- ---[XaOs]--- -- -
[ project fy ]
Edited by - XaOs on January 7, 2002 5:55:52 AM
It wasn't really hard to see that the particles would show up in the same place....
I am pretty sure that I was not the only one noticing that...

It's basicly because of this line :
glTranslatef(4.0f, 0.0f, 0.0f);
(Well....not just because of that one...but you don't do anything else in the code for placing them so in your code it's because of this line)
If you don't change the pos of anything, they will show up in the same place....

Take Care
- -- ---[XaOs]--- -- -
[ project fy ]
Edited by - XaOs on January 7, 2002 5:55:52 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement