POV-Ray : Newsgroups : povray.object-collection : Polyhedra library : Re: Polyhedra library Server Time
24 May 2024 11:49:01 EDT (-0400)
  Re: Polyhedra library  
From: Warp
Date: 13 Aug 2009 15:50:11
Message: <4a846e73@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> To try and root out this common misconception: Specifying an 
> inside_vector is /not/ a prerequisite for a mesh to work properly with 
> CSG, as POV-Ray will automaticaly assume a default value.

> Specifying an inside_vector is only of use in case the default one 
> should happen to give you artifacts, but I've never seen any.

  Unfortunately you are wrong. No default inside_vector is used if none is
specified in a mesh definition. Here's a demo:

//=============================================================================
#declare MajorRadius = 1;
#declare MinorRadius = .5;
#declare Resolution1 = 60;
#declare Resolution2 = 30;
#declare Torus =
  mesh2
  { vertex_vectors
    { Resolution1 * Resolution2
      #declare Ind1 = 0;
      #while(Ind1 < Resolution1)
        #declare Angle1 = 360*Ind1/Resolution1;
        #declare Ind2 = 0;
        #while(Ind2 < Resolution2)
          #declare Angle2 = 360*Ind2/Resolution2;
          vrotate(vrotate(MinorRadius*x, z*Angle2) + x*MajorRadius, y*Angle1)
          #declare Ind2 = Ind2 + 1;
        #end
        #declare Ind1 = Ind1 + 1;
      #end
    }
    face_indices
    { Resolution1 * Resolution2 * 2
      #declare Ind1 = 0;
      #while(Ind1 < Resolution1)
        #declare VInd1_1 = Ind1 * Resolution2;
        #declare VInd1_2 =
          ((Ind1+1 = Resolution1) ? 0 : (Ind1+1)) * Resolution2;
        #declare Ind2 = 0;
        #while(Ind2 < Resolution2)
          #declare VInd2_2 = ((Ind2+1 = Resolution2) ? 0 : (Ind2+1));
          <VInd1_1 + Ind2, VInd1_1 + VInd2_2, VInd1_2 + Ind2>
          <VInd1_1 + VInd2_2, VInd1_2 + Ind2, VInd1_2 + VInd2_2>
          #declare Ind2 = Ind2 + 1;
        #end
        #declare Ind1 = Ind1 + 1;
      #end
    }

    // Uncomment this for proper behavior:
    //inside_vector y
  };

camera { location <0, 5, -5> look_at 0 angle 35 }
light_source { <5, 20, -10>, 1 }
plane { y, -.5 pigment { rgb <.5, .8, 1> } }
intersection
{ object { Torus }
  plane { y, .4 }
  pigment { rgb 1 }
}
//=============================================================================

-- 
                                                          - Warp


Post a reply to this message

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