public Push ( float fx, float fy, float depth, float height, float speed, bool absolute ) : void | ||
fx | float | |
fy | float | |
depth | float | |
height | float | |
speed | float | |
absolute | bool | |
return | void |
public void Push( float fx, float fy, float depth, float height, float speed, bool absolute )
{
// Ogre Wave Generation Logic - scale pressure according to time passed
for ( int addx = (int)fx; addx <= (int)fx + 1; addx++ )
{
for ( int addy = (int)fy; addy <= (int)fy + 1; addy++ )
{
float diffy = fy - (float)System.Math.Floor( (double)addy );
float diffx = fx - (float)System.Math.Floor( (double)addx );
float dist = (float)System.Math.Sqrt( diffy * diffy + diffx * diffx );
float power = ( 1 - dist ) * cmplxAdj * speed;
if ( power < 0 )
{
power = 0;
}
if ( absolute )
{
vBuf[ addy, addx ].y = depth * power;
}
else
{
vBuf[ addy, addx ].y -= depth * power;
}
}
}
}
} // WaterMesh class
public void AnimateHead(float timeSinceLastFrame) { //animState.AddTime(timeSinceLastFrame); for (int i = 0; i < 4; i++) { sines[i] += adds[i] * headSpeed * timeSinceLastFrame; } float tx = (float)((Math.Sin(sines[0]) + Math.Sin(sines[1])) / 4 + 0.5) * (float)(CMPLX - 2) + 1; float ty = (float)((Math.Sin(sines[2]) + Math.Sin(sines[3])) / 4 + 0.5) * (float)(CMPLX - 2) + 1; // Push water down beneath the Ogre Head waterMesh.Push(tx, ty, headDepth, 150f, headSpeed, false); float step = PLANE_SIZE / CMPLX; headNode.ResetToInitialState(); Vector3 newPos = new Vector3(step * tx, 80f - 40f * headDepth, step * ty); Vector3 diffPos = newPos - oldPos; Quaternion headRotation = Vector3.UnitZ.GetRotationTo(diffPos); oldPos = newPos; headNode.Scale(new Vector3(3.0f, 3.0f, 3.0f)); headNode.Translate(newPos); headNode.Rotate(headRotation); }