The creation of water

Xtreme3D

Lesson 16
The creation of water

Level: medium
Version of the Xtreme3D: 3.0.x
Author: Gecko

The realistic animated water is a kind of hallmark Xtreme3D. This is really beautiful, special allows you to achieve a high degree of realism of the scene. However, the use of water must be carefully, because the calculations associated with it, quite �����������.

The water in the Xtreme3D is a flat surface, divided into a certain number of squares, on which there are concentric wave disturbances - you get the effect of "rain". Also supported are linear waves, as in the ocean - they are parallel, calculated on the sinusoid and uniformly moving across the surface of the water. In and of itself the water - only the geometry and any properties of the fluid, in addition to the waves, do not possess. Therefore, all other effects, enhancing the impression of water (reflection, sprays, physics of floating objects, etc.) you have to write on their own.

The Code creation of water looks as follows:

Water = WaterCreate(global.scene);
WaterSetResolution(water, 128);
WaterSetRainTimeInterval(water, 1000);
WaterSetRainForce(water, 1000);
WaterSetViscosity(water, 0.95);
WaterSetElastic(water, 10);
ObjectSetPosition(water, 0, 2.5, 0);
ObjectSetScale(water, 1000, 1000, 1000);

The Object Water has several important properties:

Resolution (resolution)
The number of polygons on the side of the grid. The geometry of the water is constructed of squares on the grid, so the total number of polygons is R2, where R is the value of the Resolution. It is clear that the higher the value, the higher the quality of water, and, accordingly, the speed of its work. The default value is: 64.

Rain time interval (the time interval of rain)
The effect of "Rain", when the surface of the �����������, creating in random places mesh wave disturbances. This option specifies the length of the pause in milliseconds between two disturbances. The default value is 500. The maximum value: 1000000. The minimum value is 0 (no rain).

Rain Force (force of rain)
The intensity of the disturbances; less than this value, the faster the waves of "fade". The default value is 5000. The maximum value: 1000000. The minimum value: 0.

Viscosity (viscosity)
The amplitude of the perturbation theory; in fact, the maximum height of the waves: the less the value, The ������������ liquid. The default value is 0.99. The maximum value: 1. The minimum value: 0.

Elastic (elasticity)
Speed of the perturbations. In the real world this property depends on the density of the substance (for example, the density of the mercury is much higher than that of water, so waves spread faster). The default value is: 10.

Another point: for the creation of water requires a mask that defines the shape of the surface. The Mask in this case - material with a monochrome image, where the black dots indicate lack of water, white - the presence of. Thus, we can create, for example, round the pool.

MaterialCreate('mMask', 'watermask.bmp');
WaterSetMask(water, 'mMask');