Difference between revisions of "User:Le Forgeron"

From POV-Wiki
Jump to navigation Jump to search
Line 55: Line 55:
 
}
 
}
 
</pre>
 
</pre>
=====tcb spline
+
=====tcb spline=====
 
<p>Also know as Kochanek-Bartels spline, tcb stand for tension, continuity and bias.</p>
 
<p>Also know as Kochanek-Bartels spline, tcb stand for tension, continuity and bias.</p>
 
<p>The first and last point of such spline are not reached.</p>
 
<p>The first and last point of such spline are not reached.</p>
Line 78: Line 78:
 
* <code>continuity</code> controls how rapid speed and direction change.
 
* <code>continuity</code> controls how rapid speed and direction change.
 
* <code>bias</code> controls the direction of the curve as it passes through the control point.
 
* <code>bias</code> controls the direction of the curve as it passes through the control point.
 +
 
=====x splines=====
 
=====x splines=====
 
<p>The first and last point of such spline are not reached.</p>
 
<p>The first and last point of such spline are not reached.</p>

Revision as of 13:06, 10 February 2011

I use this page to pre-document some experimental code (as experimental, not distributed in official release)



Splines

Imported from Megapov
Relicensing from ABX is needed before allowing distribution
(some bugs get fixed in the process)
Also check the megapov documentation for better explanation or clarification.

Accessing splines data

Not only the value of a spline can be evaluated with the traditional SPLINE_IDENTIFIER ( FLOAT [, SPLINE_TYPE] ), it is also possible to get back the actual pieces of information from a spline.

dimension_size( SPLINE_IDENTIFIER )

provides the number of entries in the spline.

For each entry, the spline can be accessed like an array, the first element is the float of the path list and the second element the associated vector.

  • SPLINE_IDENTIFIER[ INDEX ][0] is a float
  • SPLINE_IDENTIFIER[ INDEX ][1] is a vector
  • INDEX should evolve as an integer from 0 to dimension_size(SPLINE_IDENTIFIER)-1

Additional types of splines

Sor spline

the curve followed by a sor can be evaluted by a spline of sor_spline type with a bit of manipulation: the y value of the sor must be used as the float of the path, and the x value become one of the component of the vector.

spline{
   sor_spline
  -1.000000,0.000000*x
   0.000000,0.118143*x
   0.540084,0.620253*x
   0.827004,0.210970*x
   0.962025,0.194093*x
   1.000000,0.286920*x
   1.033755,0.468354*x
}

sor{
  7
  <0.000000, -1.000000>
  <0.118143,  0.000000>
  <0.620253,  0.540084>
  <0.210970,  0.827004>
  <0.194093,  0.962025>
  <0.286920,  1.000000>
  <0.468354,  1.033755>
}
akima spline

That spline will go through all its points, smoothly.

spline {
  akima_spline
  time_Val_1, <Vector_1> [,]
  time_Val_2, <Vector_2> [,]
    ...
  time_Val_n, <Vector_n>
}
tcb spline

Also know as Kochanek-Bartels spline, tcb stand for tension, continuity and bias.

The first and last point of such spline are not reached.

spline {
  tcb_spline [TCB_PARAMETERS]
  time_Val_1 [TCB_PARAMETERS], <Vector_1> [TCB_PARAMETERS][,]
  time_Val_2 [TCB_PARAMETERS], <Vector_2> [TCB_PARAMETERS][,]
    ...
  time_Val_n [TCB_PARAMETERS], <Vector_n> [TCB_PARAMETERS]
}

TCB_PARAMETERS:
  [tension FLOAT] [continuity FLOAT] [bias FLOAT]

The tension, continuity and bias are fully optional. Depending on the place where they appear, they control the spline in different ways:

  • Placed right after the tcb_spline keyword, they set the default values for all ends of the spline segments. This placement is ignored in case of copying spline without adding new controls because previous defaults were already propagated to each side of control points.
  • Placed between the time_value and the corresponding vector, the tcb parameters determine the properties of the spline segment ending in the vector that follows these parameters.
  • For tcb parameters following a vector, the properties of the spline segment beginning after this vector are set.

What is controlled by these parameters?

  • tension controls how sharply the curve bends.
  • continuity controls how rapid speed and direction change.
  • bias controls the direction of the curve as it passes through the control point.
x splines

The first and last point of such spline are not reached.

There is 3 variations of x splines:

  • basic
  • extended
  • general
basic x spline
spline {
  basic_x_spline [freedom_degree FLOAT]
  time_Val_1, <Vector_1> [,]
  time_Val_2, <Vector_2> [,]
  ...
  time_Val_n, <Vector_n>
}

Colour space interpolation

The colour interpolation is available for:

  • mesh
  • blob
  • polygon

It can be used with texture_map, pigment_map or colour_map.

The interpolation is performed between the resulting colours from the evaluation, not along the map.

Which colourspace ?

Interpolation for polygon

Access to camera information

These pieces of information are in read-only mode. You cannot use them to modify the actual value (no #declare or #local). The various vectors might have been updated by transform and look_at.

  • camera_type is a string containing the type of the camera (but not its subtype, so cylinder camera might be ambiguous).
  • camera_up is the actual up vector of the camera.
  • camera_right is the actual right vector of the camera.
  • camera_direction is the actual direction vector of the camera.

In case of scene with multiple cameras, each keyword can be followed by an usual array notation to access the relevant camera. (e.g. camera_up[3] for the fourth camera)

Tesselation & mesh play

Yoda: Yes, run! Yes, a Jedi's strength flows from the Renderer. But beware of the dark side. 
      Mesh, Heightfield, Bicubic Patch; the dark side of the Force are they. Easily they flow, 
      quick to join you in a fight. If once you start down the dark path, 
      forever will it dominate your destiny, consume you it will, as it did Isosurface's apprentice.
Luke: Parametric precompute... Is the dark side stronger?
Yoda: No, no, no. Quicker, easier, more seductive.
Luke: But how am I to know the good side from the bad?
Yoda: You will know... when you are calm, at peace, passive. 
      A Jedi uses the Renderer for knowledge and defense, NEVER for attack.
Luke: But tell my why I can't...
Yoda: No, no! There is no "why".


Mesh from and to file

Loading

A GTS file can be loaded with gts_load.

#include "colors.inc"
camera { location <3,5,-4>
	direction z
		up y
		right image_width/image_height*x
		look_at <-1/2,1/2,0>
		angle 35
}

light_source{ <-5, 20, -20>, 1}
light_source{ <0, 2, 0>, 1/2}

gts_load{ "bunny.gts"
	right
	rotate 180*y	
	scale 17
	translate -2*y
	texture { pigment { color Aquamarine}}
}

Aside from the filename of the file to load, the right keyword can be used to change the default left-handed coordinate system to a right-handed one.

gts_load can be used to create a mesh of its own or to incorporate the mesh of the file into a larger mesh, in which case a texture identifier can be applied over the loaded GTS mesh.

 mesh { ...
    gts_load { filename [right] [texture { Tid }] ... }
  ...
 }

OR

 gts_load { filename [right] ... }
Saving

A mesh can be saved with gts_save. Beware of I/O restrictions.

gts_save { filename, mesh_object }