User:Le Forgeron/nurbs

From POV-Wiki
Jump to navigation Jump to search


Nurbs

nurbs is like spline : an invisible object

NURBS means Non Uniform Rational B-Spline.

syntax is

nurbs {
  Uorder, Vorder, 
  Usize, Vsize 
  UKNOTS
  VKNOTS
  ULINE (repeated Vsize time)
  [OBJECTS_MODIFIERS...] 
 }

ULINE := WEIGHTED_POINT (repeated Usize time)
WEIGHTED_POINT := < X, Y, Z, W >
UKNOTS := KNOT, (repeated Uorder+Usize time)
VKNOTS := KNOT, (repeated Vorder+Vsize time)
KNOT := float value
  • The order must be at least 2 and at most `size` for each U & V coordinates.
  • Along a sequence of knots, the values must not be decreasing.
  • nurbs is one of the UVMeshable objects

Drawing a nurbs

#version 3.7;
global_settings{ assumed_gamma 1.0 }

#declare UVMeshableObject = nurbs { 3,3,7,7
// u knots
0, 0, 0, 1/5, 2/5, 3/5, 4/5, 1, 1, 1
// v knots
0, 0, 0, 1/5, 2/5, 3/5, 4/5, 1, 1, 1
// first line of (x,y,z,w)
 <-4.1894,-5.4790,0.0000,1.0000> <-4.1894,-4.3181,2.0249,1.0000>
<-4.1894,-2.8825,0.0000,1.0000> <-4.1894,-1.5000,0.0000,1.0000>
<-4.1894,-0.5000,0.0000,1.0000> <-4.1894,0.5000,0.0000,1.0000>
<-4.1894,1.5000,0.0000,1.0000>

// second line of (x,y,z,w)
<-2.6808,-4.8585,0.6794,1.0000>
 <-2.6808,-4.3181,2.0249,1.0000> <-2.6808,-2.8825,0.0000,1.0000>
<-2.6808,-1.5000,3.2519,1.0000> <-2.6808,-0.5000,0.0000,1.0000>
<-2.6808,0.5000,0.0000,1.0000> <-2.6808,1.5000,3.2103,1.0000>

// third line of (x,y,z,w)
<-1.5000,-5.4790,0.0000,1.0000>
 <-1.5000,-4.3181,2.0249,1.0000> <-1.5000,-2.8825,0.0000,1.0000>
<-1.5000,-1.5000,0.0000,1.0000> <-1.5000,-0.5000,1.2319,1.0000>
<-1.5000,0.5000,0.0000,1.0000> <-1.5000,1.5000,0.0000,1.0000>

// fourth line of (x,y,z,w)
<-0.5000,-5.4790,0.0000,1.0000>
 <-0.5000,-4.3181,0.0000,1.0000> <-0.5000,-2.8825,1.7624,1.0000>
<-0.5000,-1.5000,0.0000,1.0000> <-0.5000,-0.5000,1.0000,1.0000>
<-0.5000,0.5000,1.0000,1.0000> <-0.5000,1.5000,0.0000,1.0000>

// fifth line of (x,y,z,w)
<0.5000,-5.4790,0.0000,1.0000>
 <0.5000,-4.3181,0.0000,1.0000> <0.5000,-2.8825,0.0000,1.0000>
<0.5000,-1.5000,1.1552,1.0000> <0.5000,-0.5000,1.0000,1.0000>
<0.5000,0.5000,1.0000,1.0000> <0.5000,1.5000,0.0000,1.0000>

// sixth line of (x,y,z,w)
<1.5000,-5.4790,1.9780,1.0000>
 <1.5000,-4.3181,0.0000,1.0000> <1.5000,-2.8825,1.7335,1.0000>
<1.5000,-1.5000,0.0000,1.0000> <1.5000,-0.5000,0.0000,1.0000>
<1.5000,0.5000,0.0000,1.0000> <1.5000,1.5000,1.5217,1.0000>

// seventh line of (x,y,z,w)
<2.9668,-5.4790,-0.2469,1.0000>
 <2.9668,-4.3181,0.0000,1.0000> <2.9668,-2.8825,0.0000,1.0000>
<2.9668,-1.5000,0.0000,1.0000> <2.9668,-0.5000,-2.9599,1.0000>
<2.9668,0.5000,0.0000,1.0000> <2.9668,1.5000,0.0000,1.0000>
};

#declare Texture = texture { checker texture { pigment { color blue 1 } } texture { pigment { color rgb <1,1,0> } } }

#include "NurbsMesh.inc"
#declare UResolution = 92;
#declare VResolution = 92;
mesh {
     UVMeshable( UVMeshableObject, UResolution, VResolution )
     texture { uv_mapping Texture scale <1/24, 1/24, 1> }
     }

light_source {+40*z+90*x, 1 }
camera { location uv_vertex( UVMeshableObject, 0.5, 0.5 ) +<0,0,40>
direction z
up y
right image_width/image_height*x
look_at uv_vertex( UVMeshableObject, 0.5, 0.5 )
angle 16
}

Nurbs