Clouds and physics

Hello,



I have a working meteo system using the marvelous physics engine implemented in jMonkey. But I don’t find the answer to this question…



My clouds uses basic forces : getLinearVelocity, applyCentralForce, and the like.



They also use a SphereCollisionShape and implement the PhysicsCollisionListener.

The problem is they collide and “bounce” while clouds should merge quietly :frowning:



Can I tell the collision event to stop everything the physic engine was doing for this collision ?



I tried all those parameters without success :



[java] control = new RigidBodyControl( collisionShape );

control.setKinematic( false );

control.setKinematicSpatial( false );

control.setRestitution( 0 );

control.setDamping( 0f, 0f );[/java]



I also tried GhostControl, but for some reason it doesn’t have forces implementation.



Thank you.

Perhaps we are missing information… why is that you have made your clouds rigid bodies if you do not want them to behave like rigid bodies?

I guess you only want the forces to simulate wind on clounds am I right?

The last time I tried something similar it was not reall good possible, cause bullet has no empty collision shape, might be that it has changed since then(1-2 years ago), maybe normen can help you further.

First of all I’d say if you basically disable everything about the physics and then some basic movement of the cloud is left its probably easier simulating that movement from the beginning instead of using physics at all. Second, you could use a PhysicsCollisionGroupListener to avoid collisions that are not supposed to happen.

I use rigid bodies because they implement forces. Ghost bodies don’t :frowning:



The main purpose is to simulate the wind, yes.



If I understand your advice, I should implement my own PhysicsControl object ?

A physics engine is typically about 50% collision detection and 50% collision resolution. The part that does the actual motion fits in the margin of error for my percentages. :slight_smile:



And yes, I think we’re suggesting that you implement the motion yourself… which I think for clouds that aren’t a true vapor/gas simulation is pretty straight-forward. If anything, it will make it easier to simulate motion that you’d have to do tricks to make a rigid body physics engine do… ie: you can cheat to make it look more natural if needed.

Okay I will try that, thanks a lot for your answers :slight_smile:

if you really don’t need true simulation, just the effect of having rolling clouds, you should try to take a look at 3D noise with turbulence, taking time as the third dimension. Create a texture out of it and apply that to a skybox. It can easily be implemented as a shader (will do myself in the near future :slight_smile: )

Thank you anthyon,



Actually the game I’m slowly building up will rely a lot on a true weather system.

I need clouds to be “physically present” in the world map, and players will be able to interact with them.



But seeing how nifty your water shader is, I’m confident you will create another Art piece sky system real soon ^.^

well… thanks, but water is not mine :smiley:

Oh right, the shame :smiley:



TerrainGrid of course. I use this and water, got them mixed up in my tiny mind :wink:

Hello again,



I’m trying to extend GhostControl to create my own CloudControl object.



But when I Override the update() method, I have a visibility problem :



[java] private Vector3f getSpatialTranslation() {}



private Quaternion getSpatialRotation() {}[/java]



Is there a good reason those methods are private, or can we safely make them protected ?

I think I misunderstand the whole concept of setApplyPhysicsLocal()



If set to true, objects will collide in the same PhysicSpace as long as their LocalTranslation is identical ?

Which means, objects can be far away from each others (two different node positions), and collide ?



What can this be used for, if you have an exemple. :slight_smile:

I got it to work using super.update( tpf ); without changing visibilities to the cost of a now useless if (!enabled) return; . I’m not sure if the JVM will optimise and remove it automatically (?).



Another question, what is cloneForSpatial() from the Control interface used for ?

I had to copy the whole code because the instanciation and data copy aren’t in separate methods.

[java] public Control cloneForSpatial( Spatial spatial )

{

CloudControl control = new CloudControl( collisionShape ); // The is mine

control.setCcdMotionThreshold( getCcdMotionThreshold() ); // — From GhostControl

control.setCcdSweptSphereRadius( getCcdSweptSphereRadius() );

control.setCollideWithGroups( getCollideWithGroups() );

control.setCollisionGroup( getCollisionGroup() );

control.setPhysicsLocation( getPhysicsLocation() );

control.setPhysicsRotation( getPhysicsRotationMatrix() );

control.setApplyPhysicsLocal( isApplyPhysicsLocal() ); //—

control.setLinearVelocity( getLinearVelocity() ); // This is mine

control.setSpatial( spatial );

return control;

}

[/java]

Do you think you can separate the clone and copy into individual methods, like this :

[java] public Control cloneForSpatial( Spatial spatial )

{

GhostControl control = new GhostControl( collisionShape );

control.copyFrom( this );

control.setSpatial( spatial );

return control;

}

public void copyFrom( Control original )

this.setCcdMotionThreshold( original.getCcdMotionThreshold() );

this.setCcdSweptSphereRadius( original.getCcdSweptSphereRadius() );

this.setCollideWithGroups( original.getCollideWithGroups() );

this.setCollisionGroup( original.getCollisionGroup() );

this.setPhysicsLocation( original.getPhysicsLocation() );

this.setPhysicsRotation( original.getPhysicsRotationMatrix() );

this.setApplyPhysicsLocal( original.isApplyPhysicsLocal() );

}

[/java]

Thank you for reading.

No answers ? :frowning: snif

Pwease.