POV-Ray : Newsgroups : povray.newusers : parse error end of file but #end expected, is my code correct? : Re: parse error end of file but #end expected, is my code correct? Server Time
3 Dec 2021 02:08:44 EST (-0500)
  Re: parse error end of file but #end expected, is my code correct?  
From: Bald Eagle
Date: 3 Dec 2017 21:25:00
Message: <web.5a24b0d81496c9fd5cafe28e0@news.povray.org>
Well, you were obviously missing an #end.
I indented the [many :O ] nested #if/#else/#end statements and commented the
#ends, and then added variable definitions before the invocation of the second
macro, but that macro doesn't yet define an object to be used in an object {}
statement...

This ought to get you most of the way there:


#version 3.71;
global_settings {
 assumed_gamma 1.0
 ambient_light 4
}


#include "colors.inc"
#include "shapes.inc"
#include "math.inc"

#macro round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT)

 //Joining lines

 #local EdgeRadius = 1;

 union {
    object{Round_Cone2(p3, r3, p1, r1, EdgeRadius)texture{rT}   }
    object{Round_Cone2(p1, r1, p2, r2, EdgeRadius)texture{bT}   }
    object{Round_Cone2(p2, r2, p3, r3, EdgeRadius)texture{gT}   }
 }
#end

//Triangle definitions

#declare p1 = <-5,0,0>;
#declare p2 = <5,4,0>;
#declare p3 = <-5,9,0>;
#declare r1 = 5;
#declare r2 = 3;
#declare r3 = 1;

//Colour Textures
#declare bT   = texture{ pigment {  rgb<0,0,1> } }     //Blue
#declare rT   = texture{ pigment {  rgb<1,0,0> } }     //Red
#declare gT   = texture{ pigment {  rgb<0,1,0> } }     //Green
#declare vT   = texture{ pigment {  rgb<0.5,0,1> }}    //Violet

object {round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT) }


#macro SF_roundtriangleintpoints
(Point1,Point2,iNorm,vertA,vertB,vertC,radA,radB,radC)
 //
 #local vertA = <-5,0,0>;
 #local vertB = <5,4,0>;
 #local vertC = <-5,9,0>;
 #local radA = 5;
 #local radB = 3;
 #local radC = 1;
 //
 #if(radA<=0)
  #local iNorm  = 0;
  #local Point1 = vertA;
  #local Point2 = vertA;
 #else
  #local AtoB       = vertB - vertA;
  #local ellAB      = vlength(AtoB);

   #if(ellAB>abs(radA-radB))
  // May not degenerate to a single roundcone
   #local AtoB       = AtoB/ellAB;
   #local cyl1AB     = vertA + radA*(radA - radB)*AtoB/ellAB;
   #local sinalphaAB = (radA - radB)/ellAB;
   // Given the #if condition, 0 < sinalphaAB < 1
   #local cosalphaAB = sqrt(1-sinalphaAB*sinalphaAB);
   #local AtoC       = vertC - vertA;
   #local ellAC      = vlength(AtoC);

   #if(ellAC>abs(radA-radC))
    // May not degenerate to a single roundcone
    #local AtoC       = AtoC/ellAC;
    #local cyl1AC     = vertA + radA*(radA - radA)*AtoC/ellAC;
    #local cyl2AC     = vertC + radC*(radA - radC)*AtoC/ellAC;
    #local sinalphaAC = (radA - radC)/ellAC;
    // Given the #if condition, 0 < sinalphAC < 1
    #local cosalphaAC = sqrt(1-sinalphaAC*sinalphaAC);
    #local cosbetaABC = vdot(AtoB,AtoC);

    #if(cosbetaABC > 1)
     #local cosbetaABC = 1;
    #end // end #if(cosbetaABC > 1)

    #local sinbetaABC = sqrt(1 - cosbetaABC*cosbetaABC);
    #local AtoBperpC  = AtoC - cosbetaABC*AtoB;
    #local lAtoBperpC = vlength(AtoBperpC);

    #if(lAtoBperpC > 0)
     #local AtoBperpC  = AtoBperpC/vlength(AtoBperpC);
    #end // end #if(lAtoBperpC > 0)

    #local ABCperp    = vcross(AtoB,AtoC);
    #local ABCArea    = vlength(ABCperp);

    #if(ABCArea > 0)
     #local ABCperp    = ABCperp/ABCArea;
     #local yABC       =
radA*((radA-radC)/ellAC-cosbetaABC*(radA-radB)/ellAB)/sinbetaABC;
     #local zABC       = radA*radA - yABC*yABC -
(radA*(radA-radB)/ellAB)*(radA*(radA-radB)/ellAB);
    #else
     #local zABC       = -1;
    #end // end #if(ABCArea > 0)

    #if(zABC>=0.000000001)
     // Didn't degenerate into a single roundcone
     #local zABC   = sqrt(zABC);
     #local iNorm  = 1;
     #local Point1 = cyl1AB + yABC*AtoBperpC + zABC*ABCperp;
     #local Point2 = cyl1AB + yABC*AtoBperpC - zABC*ABCperp;
    #else
     #local iNorm  = -1;
     #local Point1 = vertA;
     #local Point2 = vertA;
    #end // end #if(zABC>=0.000000001)

   #else
    #local iNorm  = -1;
    #local Point1 = vertA;
    #local Point2 = vertA;
   #end // end #if(ellAC>abs(radA-radC))

  #else
   #local iNorm  = -1;
   #local Point1 = vertA;
   #local Point2 = vertA;
  #end // end #if(ellAB>abs(radA-radB))
 #end // end #if(radA<=0)
#end // end macro

#declare Point1 = <0, 0, 0>;
#declare Point2 = <5, 5, 5>;
#declare iNorm = 1;
#declare vertA = <2, 2, 2>;
#declare vertB = <3, 3, 3>;
#declare vertC = <4, 4, 4>;
#declare radA = 0.25;
#declare radB = 0.35;
#declare radC = 0.1;

// Nowhere in the SF_roundtriangleintpoints do you actually define an object....

object {SF_roundtriangleintpoints (Point1, Point2, iNorm, vertA, vertB, vertC,
radA, radB, radC) }

background {color White}
light_source { <20,20,-20> White shadowless}
camera {orthographic location <0, 0, -10> look_at <0, 0, 0>}


Post a reply to this message

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