Heightfield fluid demo questions

RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Heightfield fluid demo questions

Post by RJNelson68 »

Hi I am trying to implement btHfFluid in the Torque Game Engine Advanced version 1.81. I have been using you demo as an example on how to accomplish this but I need a bit of unit conversion information. The other demos had quite a few comments to explain what things were and the forum was pretty filled with details about them, this one was not that way.

In the following exerpt from your hieght field demo and I have a few questions about it:

Code: Select all

void Init_Floatyness (HfFluidDemo* fluidDemo)
{
	btHfFluid* fluid = NULL;

	fluid = new btHfFluid (btScalar(0.25), 100, 100);
	btTransform xform;
	xform.setIdentity ();
	xform.getOrigin() = btVector3(btScalar(-10.0), btScalar(-5.0), btScalar(-10.0));
	fluid->setWorldTransform (xform);
	fluid->setHorizontalVelocityScale (btScalar(0.0f));
	fluid->setVolumeDisplacementScale (btScalar(0.0f));
	fluidDemo->getHfFluidDynamicsWorld()->addHfFluid (fluid);

	for (int i = 0; i < fluid->getNumNodesLength()*fluid->getNumNodesWidth(); i++)
	{
		fluid->setFluidHeight(i, btScalar(5.0f));
	}
In fluid = new btHfFluid (btScalar(0.25), 100, 100); I know the values are gridCellWidth, numNodesWidth and numNodesLength.
Are numNodesWidth and numNodesLength the dimensions of water plane? If so, what is the value of their units in comparison to meters?

Also, in the demo gridCellWidth was only 0.25. What is the purpose of this variable and how does it compare to the dimensions of the water block?

Torque primarily uses a height and width system based upon scale and a grid element size variable as in the following

Code: Select all

   mWidth   = (U32)mFloor( mObjScale.x / mGridElementSize ) + 1;
   mHeight  = (U32)mFloor( mObjScale.y / mGridElementSize ) + 1;
I guess what I need to know is that in Torque each unit is about 1 meter in distance, is Bullet about the same? I am askin in regards this time to the code fluid->setFluidHeight(i, btScalar(5.0f));.

When you set the transform there were hard coded numbers in the example, how would that compare to a world transform in a game if you were trying to create this were an exisitng object is?

Finally, what do these do? They are set to zero in the demo.

Code: Select all

	fluid->setHorizontalVelocityScale (btScalar(0.0f));
	fluid->setVolumeDisplacementScale (btScalar(0.0f));
Thanks a ton for any help you can give me. I just want to understand this so I can use it.
User avatar
John McCutchan
Posts: 133
Joined: Wed Jul 27, 2005 1:05 pm
Location: Berkeley, CA

Re: Heightfield fluid demo questions

Post by John McCutchan »

Hi,

gridCellWidth is in meters and the width of the water surface is in gridCellWidth * numNodesWidth. The height is similar. The m_volumeDisplacementScale controls what percentage of displaced water is moved per frame. m_horizontalVelocityScale is unused.

John
RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Re: Heightfield fluid demo questions

Post by RJNelson68 »

Thank you that was extremely helpful.