version francaise

ClothRay, how does it work ?

At script level, this new feature is implemented as a new declaration block:

simcloth {
  [ environment OBJECT ]
  [ friction FLOAT ]
  [ gravity VECTOR ]
  [ wind { PIGMENT } ]
  [ viscosity FLOAT ]
  [ neighbors 0|1 ]
  [ internal_collision on|off ]
  [ damping FLOAT ]
  [ intervals FLOAT ]
  [ iterations INTEGER ]
    input STRING   // only required parameter
  [ output STRING ]
  [ mesh_output STRING ]
  [ smooth_mesh on|off ]
  [ uv_mesh on|off ]


Declaration of an object that will be used as the environnement of the cloth. It's strongly recommanded to declare it before simcloth (for readability reasons). Although any object can be used, the ones who have a well-defined interior will interact much better with the cloth.


It's an energy loss coefficient, when the cloth touches the environment. A low value (>= 0) means that the cloth will be strongly slowed, and a high value (<= 1) will allow the cloth to slide on the objects (but not to bounce off...). The default value is 1.0.


Specifies the direction and strength of gravity. The default value is < 0, 0, 0 >.


A pigment is used to define the direction and strength of the wind in every space location. At a given point, the wind is defined by the red, green and blue componants of the pigment at this point. You can explicitely declare the pigment, or use an already declared identifier. Don't forget that the colour componants can take any value you want (negative ones, greater than one, ...)


Specifies the influence of the wind and air friction on the cloth. The defaut value is 0 (no influence).


Specifies the number of neighbors that are joined by springs to each point. neighbors 0 is for 8 neighbors (faster bur rougher calculation), and neighbors 1 (default value) is for 24 neighbors (slower calculation, but better results).


Activate or deactivate internal collision management (cloth against itself). This problem is handle by added springs between points that are too close together. System instability probability is increased, and you must, most often, decrease the intervals parameter (see below). Deactivated by default (warning: much longer parsing when activated).


General energy loss parameter, it limits the accumulation of the model approximations and errors. A value lower than .95 (default value) est strongly recommanded.


specifies le time interval between each iteration. Keep it low. Default value is 0.05.


It's the number of iterations to calculate.


Filename of the starting .cth file. The only required parameter (easy to understand why...). For a complete description of the .cth file format, see below.


Filename of the ending .cth file. If this parameter is specified, the result of the simulation is saved. Useful for animations, or a multi-stage calculation.


Allow the program to ouput a file (with specified name), containing tons of triangle, corresponding to the cloth points after the simulation. It allows you to save the result of a simulation, in a format usable by other POV-Ray versions (official, or unofficials).


Activate or deactivate the creation of smooth_triangle if mesh_ouput option is activated. Deactivated by default.


Activate or deactivate UV coordinates within the triangle (or smooth_triangle) if mesh_ouput option is activated. UV coordinates go from < 0, 0 > to < 1, 1 >. Deactivated by default.

.cth file format description

the file format is very simple: the fisrt line describes the cloth dimensions (number ofpoints n1 and n2, normalized length between 2 neighbors nlng), and the springs strength ks. The other lines describe the location in space and velocity of each point. All values (3 for location, 3 for speed) are separated by commas, and each line is terminated by a comma as well.

Then, there is the constraints definitions. Constraints are 3 coefficients (1 for each axis) that will ponderate the velocity vector of a given point of the cloth. It will be possible, for instance, to slow a corner of the cloth along one axis, to completley stop it along another axis, and let it free along the last one. A constraint is defined by an interger (index), and 3 floating point coefficients, representing the constraint (respectively on x, y, z axis), all this on the same line and separated by commas. The index is the rank of the point (beginning at 0) in order of declaration of the cloth points. Constraints can be declared in any order.

You can se the cloth as 2 arrays of vectors Points[n1][n2], and Velocity[n1][n2], and its constraints Indexn, coefn. The .cth file will look like this:

n1, n2, nlng, ks,
Points[0][0], Velocity[0][0],
Points[0][1], Velocity[0][1],
Points[0][n2-1], Velocity[0][n2-1],
Points[1][0], Velocity[1][0],
Points[1][1], Velocity[1][1],
Points[1][n2-1], Velocity[1][n2-1],
Points[2][0], Velocity[2][0],
Points[n1-1][n2-1], Velocity[n1-1][n2-1],
Index1, coef1[x], coef1[y], coef1[z],
Index2, coef2[x], coef2[y], coef2[z],
Index3, coef3[x], coef3[y], coef3[z],

Examples for reading these files are provided here.