Skip to content
LeForgeron edited this page Oct 9, 2016 · 8 revisions

Hgpovray


Object

Access to data of mesh (including mesh2)

  • Returns the number of triangles in the mesh
get_triangle_count( MESH )
  • Returns the number of vertices in the mesh
get_vertex_count( MESH )
  • Returns the number of normal vectors in the mesh
get_normal_count( MESH )
  • Returns the number of uv vectors in the mesh
get_uv_count( MESH )
  • Returns the vertex vector that corresponds to the given index value (starting from 0)
get_vertex( MESH, INDEX )
  • As get_vertex, but returns a normal vector
get_normal( MESH, INDEX )
  • As get_vertex, but returns an uv vector (2D)
get_uv( MESH, INDEX )
  • Returns a vector containing index values to vertices for the triangle number INDEX (starting from 0). This can be used to read the three vertices of the triangle calling get_vertex() with each vector component
get_vertex_indices( MESH, INDEX )
  • The same as get_vertex_indices(), but returns indices to the normal vectors of the triangle number INDEX
get_normal_indices( MESH, INDEX )
  • The same as get_vertex_indices(), but returns indices to the uv vectors of the triangle number INDEX
get_uv_indices( MESH, INDEX )
  • Tells whether the triangle number INDEX is smooth or not.
is_smooth_triangle( MESH, INDEX )

Access to part of compound object

Compound objects can be made of:

  • Constructive Solid Geometry (CSG : difference, union, merge, intersection)
  • Generalised Symetric Difference (GSD: interunion, intermerge)

Data access

The children function take an object as parameter, and return the number of first level sub-objects in it.

  • if parameter is not compound compatible, it returns -1

Getting a copy of an object inside a compound object

A small SDL extension, to retrieve the object inside an existing compound object (CSG or GSD).

child { CSG_Object_ID }( Index )

The index start at 0 for the first child of the CSG. Only the first level of the CSG is explored (recursion in CSG structure must be handled the same way: with recursion).

It is recommended to use children( CSG_Object_ID ) to check the object first, as child generates an error whenever:

  • the object is not compound
  • the index is out of bound in regard to the number of first level subobject in the compound object

Galley

Similar to text, with formatting as traditional printing galley.

Syntax is

 galley {
 ttf FONT_NAME "string of text" <thickness, interparagraph factor, justification>, < width, interline height, left adjustment> 
 [OBJECT_MODIFIERS]
 }

 galley {
 internal FONT_NUMBER "string of text" <thickness, interparagraph factor, justification>, < width, interline height, left adjustment> 
 [OBJECT_MODIFIERS]
 }
  • ttf FONT_NAME, internal FONT_NUMBER and thickness are identical to the ones for text{}.
  • width is the desired width of the text on which to fold the text
  • interline height is the leading of the text, on the y direction. Traditional value should be -1.
  • left adjustment is the adjustement on the left margin when folding the text past the first line of a paragraph.
  • interparagraph factor is a multiplier of the interline height when a "\n" is encountered.
  • justification is 0 or less for word wrapping (do not cut words, ragged right side, width can be overruled), any positive value for letter folding (cut words, enforce the width)
  • the string of text can use \n to start a new paragraph.

For the following picture, thickness : 0.01, interparagraph factor : 1.5, width : 30, interline height : -1, and

Left adjustement Justification : 1, cut Word Justification : 0, wrap Word
+2
0
-2

Illustration with 6 galley

GSD : Generalised Symetric Difference

RANGE: (NUMBER|VECTOR)[,RANGE]
VECTOR: <NUMBER, NUMBER>
NUMBER: number of intersection, negative number are added to total number of object+1

GSD

The minimal number of objects is three.

Interunion

syntax is

interunion { 
  OBJECTS...
  [range{ RANGE } ]*
  [OBJECT_MODIFIERS...] 
 }

Interunion

#version 3.7;
global_settings { assumed_gamma 1.0 }

camera { location -560*z
         direction z
         up y
         right image_width*x/image_height
         angle 5
       }

#include "colors.inc"

interunion{
#for(i,0,359.99,60)
#local pos= vrotate(6*x,i*z);
            cylinder { pos-z,pos+31*z,10 texture { pigment { color CH2RGB(i) filter 0.45 } } }
#end
            range { <2,4> }
            clipped_by {cylinder { 30*z,0, 20  } }
          }

box { 30*z-20*x-20*y, 30*z+20*x+20*y texture { pigment { color White }}}

light_source { 10*<0,0,-20>, 0.9 }
light_source { 10*<-5,10,-50>, 0.9 }
light_source { 10*<-10,10,-50>, 0.9 }
light_source { 10*<5,10,-50>, 0.9 }
light_source { 10*<10,10,-50>, 0.9 }

Intermerge

syntax is

intermerge { 
  OBJECTS...
  [range{ RANGE } ]*
  [OBJECT_MODIFIERS...] 
 }

Intermerge

#version 3.7;
global_settings { assumed_gamma 1.0 }

camera { location -560*z
         direction z
         up y
         right image_width*x/image_height
         angle 5
       }

#include "colors.inc"

intermerge{
#for(i,0,359.99,60)
#local pos= vrotate(6*x,i*z);
            cylinder { pos-z,pos+31*z,10 texture { pigment { color CH2RGB(i) filter 0.45 } } }
#end
            range { <2,4> }
            clipped_by {cylinder { 30*z,0, 20  } }
          }

box { 30*z-20*x-20*y, 30*z+20*x+20*y texture { pigment { color White }}}

light_source { 10*<0,0,-20>, 0.9 }
light_source { 10*<-5,10,-50>, 0.9 }
light_source { 10*<-10,10,-50>, 0.9 }
light_source { 10*<5,10,-50>, 0.9 }
light_source { 10*<10,10,-50>, 0.9 }

Lemon

syntax is

lemon { 
  <Base_Point>, Base_Radius, <Cap_Point>, Cap_Radius, Inner_Radius [open]
  [OBJECTS_MODIFIERS...] 
 } 

Lemon

#version 3.7;
global_settings { assumed_gamma 1.0 }

camera { location -560*z
         direction z
         up y
         right image_width*x/image_height
         angle 5
       }

#include "colors.inc"

lemon { -18*y-10*x, 0, 18*y-10*x, 0, 30 texture { pigment { color CH2RGB(30) filter 0.45 } } }
lemon { +10*x+1*y, 5, 18*y+10*x, 0, 15 texture { pigment { color CH2RGB(100) filter 0.45 } } }
lemon { -1*y+10*x, 5, -18*y+10*x, 5, 15 texture { pigment { color CH2RGB(150) filter 0.45 } } }

box { 10*z-20*x-20*y, 10*z+20*x+20*y texture { pigment { color White }}}

light_source { 10*<0,0,-20>, 0.9 }
light_source { 10*<-5,10,-50>, 0.9 }
light_source { 10*<-10,10,-50>, 0.9 }
light_source { 10*<5,10,-50>, 0.9 }
light_source { 10*<10,10,-50>, 0.9 }

rational_bezier_patch

syntax is

rational_bezier_patch {
  Usize, Vsize [accuracy Precision]
  ULINE (repeated Vsize time)
  [OBJECTS_MODIFIERS...] 
 }

ULINE := WEIGHTED_POINT (repeated Usize time)
WEIGHTED_POINT := < X, Y, Z, W >

Rational_Bezier_Patch

#version 3.7;
global_settings{ assumed_gamma 1.0 }

camera {location -30*z
direction z
up y
right x*image_width/image_height
angle 25
rotate 40*x
}

#include "colors.inc"
#include "woods.inc"
cylinder { -6*y, 4*y, 1 open texture { pigment { White } } }

#declare RA = seed(122);

light_source { -100*z, 1 }
light_source { 100*y, 1 }
light_source { 100*y-100*z, 1 }
light_source { 100*y-100*x, 1 }

plane { y, -6
texture { checker texture { pigment { Yellow } }  texture { pigment { Green } } }
}
#declare Texture = texture { T_Wood5 rotate 90*x };
#declare R1=2;
#declare R2=3;
#declare R3=4;
#declare R4=5;
#declare R5=6;
#declare S=1/5;
#declare N=8/S;
rational_bezier_patch{ 5,N+1 // accuracy 0.0000001
#for(i,-4,4,S)
#local In=rand(RA);
<(R1+In)*cos(i),i,(R1+In)*sin(i),1> 
<(R2+In/2)*cos(i),i+2*rand(RA),(R2+In/2)*sin(i),0.707> 
<R3*cos(i),i,R3*sin(i),1> 
<(R4-In/2)*cos(i),i-2*rand(RA),(R4-In/2)*sin(i),0.707> 
<(R5-In)*cos(i),i,(R5-In)*sin(i),1> 
#end
texture { uv_mapping Texture scale <1/4, 1/34,1> }
}

skeleton of mesh

syntax is

grid{ 
  Mesh_object [, Diameter [, Normal ] ] 
  [OBJECTS_MODIFIERS...] 
 } 
  • Diameter : for cylinders and spheres, default to 0.01
  • Normal : lenght of normals, default to 0 (not drawn)

Grid

#version 3.7;
global_settings { assumed_gamma 1.0 }

camera { location -20*z
 direction z
 up y
 right image_width*x/image_height
 angle 4
 look_at <0.5,0.5,0>
}

#include "colors.inc"

#declare Mesh = 
mesh2 {
   vertex_vectors {
      24, 
      <0,0,0>, <0.5,0,0>, <0.5,0.5,0>, //1
      <0.5,0,0>, <1,0,0>, <0.5,0.5,0>, //2
      <1,0,0>, <1,0.5,0>, <0.5,0.5,0>, //3
      <1,0.5,0>, <1,1,0>, <0.5,0.5,0>, //4
      <1,1,0>, <0.5,1,0>, <0.5,0.5,0>, //5
      <0.5,1,0>, <0,1,0>, <0.5,0.5,0>, //6
      <0,1,0>, <0,0.5,0>, <0.5,0.5,0>, //7
      <0,0.5,0>, <0,0,0>, <0.5,0.5,0>  //8
   }
   face_indices {
      8, 
      <0,1,2>,    <3,4,5>,       //1 2
      <6,7,8>,    <9,10,11>,     //3 4
      <12,13,14>, <15,16,17>,    //5 6
      <18,19,20>, <21,22,23>     //7 8
   }
   pigment {rgb 1}
}


light_source { 10*<0,10,-20>, 0.9 }

grid { Mesh, 0.04 texture { pigment { color rgb 0.75 } } }

Clone this wiki locally