|
|
This is from November 2016, where there was some experimentation with scanning
objects with trace() and building triangles. Obviously still needs some work.
;)
Also, Jerome Grimbert has some excellent additions that do exactly this in
HgPOV-Ray.
http://wiki.povray.org/content/User:Le_Forgeron/tesselation
===========================================================================
#version 3.7;
global_settings {
assumed_gamma 1.0
ambient_light color rgb <1, 1, 1>
}
#include "colors.inc"
#include "math.inc"
#include "transforms.inc"
#declare Camera_Origin = camera {
location <0, 0, 0>
right x*image_width/image_height
look_at <0, 0, 0.01>}
#declare Camera_Angle = camera {
location <0.0 , 0.0, 0.0>
right x*image_width/image_height
look_at <100, 30, 0>}
#declare Camera_Front = camera {
location <2, 5, -30.0>
//location <0.0, 12, -10.0>
right x*image_width/image_height
sky y
look_at <2, 5, 0>}
#declare Camera_Rear = camera {
location <0.0, -100.0, -300.0>
right x*image_width/image_height
look_at <0, 0, 0>}
#declare Camera_Top = camera {
location <0, 25.0, 0>
right x*image_width/image_height
look_at <0, 0, 0>}
#declare Camera_Iso = camera {
location <-50, 0, 0>
right x*image_width/image_height
look_at <0, 0, 0>}
//####################
//camera {Camera_Front}
//####################
light_source{ <50, 50, -100> color rgb <1, 1, 1>} // White top
// Create an infinite sphere around scene and allow any pigment on it
sky_sphere{ pigment { gradient <0,1,0>
color_map { [0.00 rgb <0.6, 0.7, 1.0>]
[0.35 rgb <0.0, 0.1, 0.8>]
[0.65 rgb <0.0, 0.1, 0.8>]
[1.00 rgb <0.6, 0.7, 1.0>]
}
scale 2
} // end of pigment
} //end of skysphere -------------------------------------
#declare Cylinder = cylinder {<0, 0, 0>, <0, 10, 0> 2 pigment {Red} }
#declare Sphere = sphere {<0, 0, 0>, 2 pigment {Red} }
#declare Box = box {-1, 1 pigment {Red} }
#declare Cross = union {
cylinder {<0, 0, 0>, <0, 10, 0> 1 pigment {Red} }
cylinder {<-5, 5, 0>, <5, 5, 0> 1 pigment {Red} }
}
#declare Cross2 = union {
cylinder {<0, 0, 0>, <0, 10, 0> 1 pigment {Red} }
cylinder {<-5, 5, 0>, <5, 5, 0> 1 pigment {Red} }
cylinder {<0, 5, -5>, <0, 5, 5> 1 pigment {Red} }
}
#declare Torus = torus {3, 0.5 pigment {Red} rotate x*0}
#declare Blob =
//union {
blob {
threshold .65
sphere { <.5,0,0>, .8, 1 pigment {Blue} }
sphere { <-.5,0,0>,.8, 1 pigment {Red} }
finish { phong 1 }
}
//sphere { <.5,0,0>, .8 pigment { Blue transmit .9 }}
//sphere { <-.5,0,0>, .8 pigment { Red transmit .9 }}
//cylinder {<-1, 0, 0>, <1, 0, 0>, 0.65/2 pigment {color White transmit 0.9}
no_shadow}
//}
#declare Object = object {Cylinder}
object {Cylinder}
// Scan object with a loop of traces
#declare Min = min_extent (Object);
#declare Max = max_extent (Object);
#declare MidHeight = (Min.y + Max.y)/2;
#declare Move = (Max.x*2)+4;
#declare Center = (Min.x + Move)/2;
camera {
location <Center, MidHeight, (Min.z*10)>
//location <0.0, 12, -10.0>
right x*image_width/image_height
sky y
look_at <Center, MidHeight, 0>}
#declare TraceRadius = max (Min.x, Max.x, Min.z, Max.z) * 2;
#declare Step = 0.5;
#declare Arcs = 36;
#declare TraceNormal = <0, 0, 0>;
#declare Degrees = 360/Arcs;
#declare OddShift = Degrees/2;
#declare Levels = (Max.y-Min.y)/Step;
#debug concat( " Levels = ", str(Levels, 3, 1), "\n")
#declare TraceMeshArray = array [Levels+1][Arcs+1];
#declare ArrayY = 0;
#declare ArrayX = 0;
#for (Y, Min.y, Max.y, Step)
#if (odd(ArrayY))
#declare Shift = OddShift;
#else
#declare Shift = 0;
#end
#for (Theta, 0, 360, Degrees)
#declare MyTransform = transform { rotate y*(Theta+Shift) };
#declare TracePoint = vtransform (<TraceRadius, Y, 0>, MyTransform);
#declare TraceMeshArray[ArrayY][ArrayX] = trace(Object, <0, Y, 0>, TracePoint,
TraceNormal);
//#debug concat( " Y = ", str(ArrayY, 3, 1), " X = ", str(ArrayX, 3, 1),
" TraceNormal = ", vstr(3, TraceNormal, ", ", 3, 0), "\n")
cylinder {TracePoint, <0, Y, 0> 0.005 pigment {Blue} }
#declare TraceNormal = <0, 0, 0>;
#declare ArrayX = ArrayX+1;
#end
#declare ArrayX = 0; // reset X
#declare ArrayY = ArrayY+1;
#end
// plot mesh vertices
#declare ArrayY = 0;
#declare ArrayX = 0;
#declare SphereRadius = 0.03;
#for (Y, Min.y, Max.y, Step)
#for (Theta, 0, 360, Degrees)
sphere {TraceMeshArray[ArrayY][ArrayX], SphereRadius pigment {Black} translate
x*Move}
#declare ArrayX = ArrayX+1;
#end
#declare ArrayX = 0; // reset X
#declare ArrayY = ArrayY+1;
#end
// draw mesh edges
#declare SphereRadius = 0.025;
#declare ArrayY = 0;
#declare ArrayX = 0;
#declare SphereRadius = 0.0125;
#for (Y, Min.y, Max.y, Step)
#for (Theta, 0, 360, Degrees)
//horizontal edges
#if (ArrayX >= 1)
//#debug concat( "TraceMeshArray[ArrayY][ArrayX] = ", vstr(3,
TraceMeshArray[ArrayY][ArrayX], ", ", 3, 3), "
TraceMeshArray[ArrayY][ArrayX-1] = ", vstr(3, TraceMeshArray[ArrayY][ArrayX-1],
", ", 3, 3),"\n")
cylinder {TraceMeshArray[ArrayY][ArrayX],
TraceMeshArray[ArrayY][ArrayX-1]+0.001, SphereRadius pigment {Green} translate
x*Move}
#end
// diagonal edges
#if (Y > Min.y)
cylinder {TraceMeshArray[ArrayY][ArrayX],
TraceMeshArray[ArrayY-1][ArrayX]+0.001, SphereRadius pigment {Green} translate
x*Move}
#if (odd(ArrayY))
#if (ArrayX < Arcs)
cylinder {TraceMeshArray[ArrayY][ArrayX],
TraceMeshArray[ArrayY-1][ArrayX+1]+0.001, SphereRadius pigment {Green} translate
x*Move}
#else
cylinder {TraceMeshArray[ArrayY][ArrayX],
TraceMeshArray[ArrayY-1][0]+0.001, SphereRadius pigment {Green} translate
x*Move}
#end
#else
#if (ArrayX > 0)
cylinder {TraceMeshArray[ArrayY][ArrayX],
TraceMeshArray[ArrayY-1][ArrayX-1]+0.001, SphereRadius pigment {Green} translate
x*Move}
#else
cylinder {TraceMeshArray[ArrayY][ArrayX],
TraceMeshArray[ArrayY-1][0]+0.001, SphereRadius pigment {Green} translate
x*Move}
#end
#end
#end
#declare ArrayX = ArrayX+1;
#end
#declare ArrayX = 0; // reset X
#declare ArrayY = ArrayY+1;
#end
Post a reply to this message
|
|