PDA

View Full Version : Particle Engine



HamidRM
07-17-2009, 12:23 AM
Hi
I Make a Particle Engine.
But i have a tiny problem.

if i draw particles befor draw teapot , always paricles are seen back of the teapot.

SMOKE_INIT[1].Make_Smoke();
FIRE_INIT[1].Make_Fire();
FIRE_JET_INIT[1].Make_Jet();
WATER_JET_INIT[1].Make_Jet();
RAIN_INIT.Make_Rain();
glTranslatef(0,0.35,-0.5);
glColor4f(0.7,0.4,0.1,1);
glutSolidTeapot(0.5);
and if i draw teapot befor draw particles , always teapot are seen back of the paricles.

glTranslatef(0,0.35,-0.5);
glColor4f(0.7,0.4,0.1,1);
glutSolidTeapot(0.5);
SMOKE_INIT[1].Make_Smoke();
FIRE_INIT[1].Make_Fire();
FIRE_JET_INIT[1].Make_Jet();
WATER_JET_INIT[1].Make_Jet();
RAIN_INIT.Make_Rain();
i write this code befor draw each Particles :

glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND|GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
i know that this problem is result of disabling depth test...
plaese help me about this problem.
:confused:
draw_particles_befor_draw_teapot.zip (http://files.upload2world.com/get-7-2009-upload2world_com_25y0t7vy.zip)
draw_teapot_befor_draw_particles.zip (http://files.upload2world.com/get-7-2009-upload2world_com_svvwdvgx.zip)
draw_particles_with_depthtest.zip (http://files.upload2world.com/get-7-2009-upload2world_com_yuw3th8n.zip)

Brolingstanz
07-17-2009, 08:53 AM
Hold on a second. Let me get this straight...

The particles are in back of the teapot? Or the teapot is in back of the particles?

Not to nitpick but your blend enable looks like its got a bad case of Orlicula Pipitis. And your blend func may not work as you expect, especially without a destination alpha channel.

HamidRM
07-18-2009, 12:30 AM
I had said that if i draw particles befor teapot , always paricles are seen back of the teapot and if i draw teapot befor particles , always teapot is seen back of the paricles.
I know that this problem is result of disabling depth test but without disabling depth , the particles had seen very bad.
i test every blend func but don't right
i upload my files again in an other site.
please see my files, then answer me.
thank u.
draw_teapot_befor_draw_particles (http://www.4shared.com/file/118902920/8c3a3ae4/draw_teapot_befor_draw_particles.html)
draw_particles_befor_draw_teapot (http://www.4shared.com/file/118902925/fc50ce6b/draw_particles_befor_draw_teapot.html)
draw_particles_with_depthtest (http://www.4shared.com/file/118902923/15336b5e/draw_particles_with_depthtest.html)

ZbuffeR
07-18-2009, 03:52 AM
without disabling depth , the particles had seen very bad.
Enable depth correctly to draw the teapot. Then disable depth writes (keep depth test), and draw the particles.

HamidRM
07-18-2009, 07:49 AM
I had done this work...
I after draw each particle ,enable depth test.

pudman
07-18-2009, 08:14 AM
I after draw each particle ,enable depth test.

I don't think you understood exactly. Without seeing your code it's difficult to verify, but it seems you should be doing:



// Draw teapot
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_FALSE ); // Enable depth writes
glutSolidTeapot(0.5);

// Draw particles
glDepthMask( GL_FALSE ); // Disable depth writes
glEnable(GL_BLEND|GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
SMOKE_INIT[1].Make_Smoke();
FIRE_INIT[1].Make_Fire();
FIRE_JET_INIT[1].Make_Jet();
WATER_JET_INIT[1].Make_Jet();
RAIN_INIT.Make_Rain();

HamidRM
07-18-2009, 11:26 PM
very very very ... thanks,I write this:
glDepthMask( GL_FALSE );
// Draw particles
glDepthMask( GL_TRUE );
and working very well now... ;)