POV-Ray : Newsgroups : povray.binaries.images : Second preview of tesselation patch : Second preview of tesselation patch Server Time
19 Aug 2024 08:24:05 EDT (-0400)
  Second preview of tesselation patch  
From: Warp
Date: 13 Dec 2000 14:50:18
Message: <3a37d2f8@news.povray.org>
This scene demonstrates how the patches can be used to create a PCM file
from a mesh (which is created by tesselating an object).

  It would be possible to create only the hairs with the pcmhair macro and
then apply the hairs to the original object.


#macro ExportToPCM(Mesh, FileName)
  #fopen OutFile FileName write
  #local vrt_cnt = get_vertex_count(Mesh);
  #local nrm_cnt = get_normal_count(Mesh);
  #write(OutFile, "\"PCM1\",\n", vrt_cnt+nrm_cnt, ",\n")
  #local VInd = 0;
  #while(VInd < vrt_cnt)
    #local V = get_vertex(Mesh, VInd);
    #write(OutFile, V.x, ",", V.y, ",", V.z, ",")
    #local VInd = VInd+1;
  #end
  #local NInd = 0;
  #while(NInd < nrm_cnt)
    #local N = get_normal(Mesh, NInd);
    #write(OutFile, N.x, ",", N.y, ",", N.z, ",")
    #local NInd = NInd+1;
  #end
  #local tr_cnt = get_triangle_count(Mesh);
  #write(OutFile, "\n0,", tr_cnt, ",\n")
  #local TInd = 0;
  #while(TInd < tr_cnt)
    #local Ind1 = get_vertex_indices(Mesh, TInd);
    #local Ind2 = vrt_cnt + get_normal_indices(Mesh, TInd);
    #write(OutFile,
      Ind1.x, ",", Ind2.x, ",",
      Ind1.y, ",", Ind2.y, ",",
      Ind1.z, ",", Ind2.z, ",")
    #local TInd = TInd+1;
  #end
  #fclose OutFile
#end


#include "pcmhair.mcr"

background { rgb z*.5 }
#default { pigment { rgb <1,1,0> } finish { specular .5 } }

#declare Obj =
  union
  { sphere { y,.5 }
    cylinder { y,-y*.5,.25 }
    sphere { -y*.5,.25 }
    cylinder { y*.5, -x*.6, .2 }
    sphere { -x*.6, .2 }
    cylinder { y*.5, x*.6, .2 }
    sphere { x*.6, .2 }
    cylinder { -y*.5, -x*.4-y, .2 }
    sphere { -x*.4-y, .2 }
    cylinder { -y*.5, x*.4-y, .2 }
    sphere { x*.4-y, .2 }
  }

#declare Mesh = tesselate(Obj, 30, yes)
ExportToPCM(Mesh, "test.pcm")

object { Mesh translate -x }

#declare hair_length = .1;
#declare hair_thickness = .01;
#declare hair_objects_per_unit = 200;
#declare hair_patch_size = 0.1;
#declare hair_rotate_to_surface = true;
object { read_mesh("test.pcm") translate x }

camera { location <0,2,-13>/2 look_at y*.2 angle 35 }
light_source { <200,100,-150>, 1 }
light_source { <-200,100,-100>, x*.5 }


Post a reply to this message


Attachments:
Download 'tesselationtest2.jpg' (137 KB)

Preview of image 'tesselationtest2.jpg'
tesselationtest2.jpg


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.