Jump to content

Particles are not affected from Physical Wind


photo

Recommended Posts

Hi, I have particles and I want them to affected from physical wind. My car is affected from wind ( can't reach maximum speed) but particles are not affected.

 

Here is my code:

pos_araba = target_car.getPosition();
			vec3 direc = target_car.getDirection();
			vec3 windvolumepos = pos_araba + rotateZ(180.0 * atan2(direc.y, direc.x) / PI) * vec3(5.0, -5.0, 1.0);
			//MUZAFFER: rüzgar
			wind = add_editor(new PhysicalWind(vec3(10,20,10)));
			wind.setLinearDamping(0.16f);
			wind.setAngularDamping(0.16f);
			wind.setVelocity(vec3(0.0f,0.0f,5.0f));
			wind.setWorldTransform(translate(windvolumepos));
			
			volume = add_editor(new ObjectVolumeBox(vec3(10,20,10)));
			volume.setMaterial("volume_fog_base","*");
			volume.setMaterialParameter("diffuse_color",vec4(1.0f,0.0f,0.0f,0.0f),0);
			volume.setWorldTransform(translate(windvolumepos));

To check out where is the wind box is I created a volume box.

 

Here is my code for particles:

particlesbaca = add_editor(new ObjectParticles());
			particlesbaca.setMaterial("particles_base","*");
			//particlesbaca.setMaterialParameter("diffuse_color",vec4(1.0f,0.0f,0.0f,0.0f),0);
			particlesbaca.setMaterialParameter("diffuse_color",vec4(0.3f,0.3f,0.3f,0.0f),0);
			particlesbaca.setWorldTransform(translate(Vec3(0.0f,2.0f,1.5f)));
			particlesbaca.setParticlesType(OBJECT_PARTICLES_TYPE_LENGTH);
			particlesbaca.setSpawnRate(300.0f); //saniyede kaç tane üretilecek
			particlesbaca.setLengthStretch(0.01f); //uzatma 
			particlesbaca.setLinearDamping(0.0f);
			particlesbaca.setEmitterType(OBJECT_PARTICLES_EMITTER_POINT);
			particlesbaca.setEmitterDirection(vec3(0.1f,0.0f,0.1f));//target_car.getBackPosition()); //yönü
			particlesbaca.setEmitterSpread(vec3(0.0f,0.0f,0.0f));  //particialların alanı
			particlesbaca.setEmitterSize(vec3(0.0f,0.0f,0.0f)); //boyut
			particlesbaca.setEmitterEnabled(1);
			particlesbaca.setGravity(vec3(0.0f,0.0f,-9.8f));
			particlesbaca.setLife(2.0f,0.0f);
			particlesbaca.setRadius(0.1f,0.5f);
			particlesbaca.setVelocity(10.0f,0.0f);
			particlesbaca.setCulling(1);
			particlesbaca.setCollision(0);
			particlesbaca.setIntersection(0);
			particlesbaca.setEnabled(1);
			particlesbaca.setParent(target_car.getObject());

Should I turn or off an attribute for particles?

Link to comment

yep, you're right. In this case maybe you have to specify particle mass via ObjectParticles.setPhysicalMass() ? Maybe it's initialized by default to a value of 0.0, effectively disabling physical interaction.

Link to comment

setPhysicalMASK() takes into argument and should be set to same bit mask value (e.g. 1) as the Wind object, so the particles get affected by the wind object.

 

In addition also use setPhysicalMASS() for assigning particle weight. I would use a smaller mass value e.g. 0.1 or 1.0 for testing.

Link to comment

Actually I did set mass to 100.0f. Sorry for mistake.

 

Now I have set values according to your answer:

 

particlesbaca.setPhysicalMask(wind.getPhysicalMask());
particlesbaca.setPhysicalMass(1.0f);
 
But still no effect.
Link to comment

Ok, that I have no more ideas left, sorry. I think it would be helpful if you could provide a minimalistic test scene illustrating the problem for evaluation by Unigine crew  

Link to comment

Hi Yiğit,

 

I've just created test scene with wind and particles with your parameters, add physical mass and it works:

        PhysicalWind wind = addToEditor(new PhysicalWind(vec3(1000.0f)));
	wind.setVelocity(vec3(-5.0f,0.0f,1.0f));
	wind.setLinearDamping(8.0f);
	wind.setAngularDamping(8.0f);
	
	ObjectParticles particles = addToEditor(new ObjectParticles());
	particles.setMaterial("particles_base","*");
	particles.setMaterialParameter("diffuse_color",vec4(0.3f,0.3f,0.3f,0.0f),0);
	particles.setWorldTransform(translate(Vec3(0.0f,2.0f,1.5f)));
	particles.setParticlesType(OBJECT_PARTICLES_TYPE_LENGTH);
	particles.setSpawnRate(300.0f); //saniyede ka? tane ?retilecek
	particles.setLengthStretch(0.01f); //uzatma 
	particles.setLinearDamping(0.0f);
	particles.setEmitterType(OBJECT_PARTICLES_EMITTER_POINT);
	particles.setEmitterDirection(vec3(0.1f,0.0f,0.1f));//target_car.getBackPosition()); //y?n?
	particles.setEmitterSpread(vec3(0.0f,0.0f,0.0f));  //particiallar?n alan?
	particles.setEmitterSize(vec3(0.0f,0.0f,0.0f)); //boyut
	particles.setEmitterEnabled(1);
	particles.setGravity(vec3(0.0f,0.0f,-9.8f));
	particles.setLife(2.0f,0.0f);
	particles.setRadius(0.1f,0.5f);
	particles.setVelocity(10.0f,0.0f);
	particles.setCulling(1);
	particles.setCollision(0);
	particles.setIntersection(0);
	particles.setEnabled(1);
	particles.setPhysicalMass(0.057f);

Changing wind velocity or enabling/disabling it, changes particles direction.

 

If this wont help, please send us your test scene.

  • Like 1
Link to comment
  • 4 weeks later...

Hi Yiğit,

 

I've just created test scene with wind and particles with your parameters, add physical mass and it works:

        PhysicalWind wind = addToEditor(new PhysicalWind(vec3(1000.0f)));
	wind.setVelocity(vec3(-5.0f,0.0f,1.0f));
	wind.setLinearDamping(8.0f);
	wind.setAngularDamping(8.0f);
	
	ObjectParticles particles = addToEditor(new ObjectParticles());
	particles.setMaterial("particles_base","*");
	particles.setMaterialParameter("diffuse_color",vec4(0.3f,0.3f,0.3f,0.0f),0);
	particles.setWorldTransform(translate(Vec3(0.0f,2.0f,1.5f)));
	particles.setParticlesType(OBJECT_PARTICLES_TYPE_LENGTH);
	particles.setSpawnRate(300.0f); //saniyede ka? tane ?retilecek
	particles.setLengthStretch(0.01f); //uzatma 
	particles.setLinearDamping(0.0f);
	particles.setEmitterType(OBJECT_PARTICLES_EMITTER_POINT);
	particles.setEmitterDirection(vec3(0.1f,0.0f,0.1f));//target_car.getBackPosition()); //y?n?
	particles.setEmitterSpread(vec3(0.0f,0.0f,0.0f));  //particiallar?n alan?
	particles.setEmitterSize(vec3(0.0f,0.0f,0.0f)); //boyut
	particles.setEmitterEnabled(1);
	particles.setGravity(vec3(0.0f,0.0f,-9.8f));
	particles.setLife(2.0f,0.0f);
	particles.setRadius(0.1f,0.5f);
	particles.setVelocity(10.0f,0.0f);
	particles.setCulling(1);
	particles.setCollision(0);
	particles.setIntersection(0);
	particles.setEnabled(1);
	particles.setPhysicalMass(0.057f);

Changing wind velocity or enabling/disabling it, changes particles direction.

 

If this wont help, please send us your test scene.

It works. Thanks.

Link to comment
×
×
  • Create New...