POV-Ray : Newsgroups : povray.general : texturing in csg : Re: texturing in csg - perhaps not texturing Server Time
8 Aug 2024 01:22:50 EDT (-0400)
  Re: texturing in csg - perhaps not texturing  
From: Wlodzimierz ABX Skiba
Date: 27 Mar 2001 05:04:18
Message: <3ac065a2@news.povray.org>
Francois Labreque wrote in message <3ABFE731.4DB35D6B@videotron.ca>...
> I think Wlodimierz will have to post actual code and images to see what
> is going on.


I try. My project is rather large but I try separate all code and connect all
include files.
Althought I'm not sure if there is problem in texturing - I observe crashing and
strange things when I add macros for arrays for big polygons.
At first take a look at my macro set:

// ============= START OF MACROS INCLUDE FILE

#macro CountSize(Array)
  dimension_size(Array,1)
#end

#macro CountEntries(Array)
  #local Size=CountSize(Array);
  #local counter=0;
  #local Finish=no;
  #while(!Finish)
    #if(counter>=Size)
      #local Finish=yes;
    #else
      #if(!defined(Array[counter]))
        #local Finish=yes;
      #else
        #local counter=counter+1;
      #end
    #end
  #end
  counter
#end

#macro AddPoint(Array,Point)
  #local Size=CountSize(Array);
  #local Entries=CountEntries(Array);
  #if(Size!=Entries)
    #declare Array[Entries]=Point;
  #else
    #local NewArray=array[Size+1]
    #local counter=0;
    #while(counter<Size)
      #local NewArray[counter]=Array[counter];
      #local counter=counter+1;
    #end
    #local NewArray[counter]=Point;
    #declare Array=NewArray
  #end
#end

#macro AddCircle(Array,P0,R)
  #local P1=P0+<0,0,R>;
  AddPoint(Array,P1)
  #local counter=1;
  #local CAqu=100;
  #while(counter<(CAqu-1))
    #local P=P0+vrotate(<0,0,R>,y*counter*360/(CAqu-1));
    AddPoint(Array,P)
    #local counter=counter+1;
  #end
  AddPoint(Array,P1)
#end

#macro AddRectangle(Array,P0,L,W)
  AddPoint(Array,(P0+x*L/2+z*W/2))
  AddPoint(Array,(P0+x*L/2-z*W/2))
  AddPoint(Array,(P0-x*L/2-z*W/2))
  AddPoint(Array,(P0-x*L/2+z*W/2))
  AddPoint(Array,(P0+x*L/2+z*W/2))
#end

#macro ListPoints(Array)
  #local Entries=CountEntries(Array);
  Entries
  #local counter=0;
  #while(counter<Entries)
    Array[counter]
    #local counter=counter+1;
  #end
#end

// ============= END OF MACROS INCLUDE FILE

ok.
I think it shoud works for any start size of array

#declare Start=2;
#local List=array[Start]
AddPoint(List,...)
AddPoint(List,...)
AddPoint(List,...)
AddPoint(List,...)
AddPoint(List,...)
AddCircle(List,...,...)
AddCircle(List,...,...)
polygon{ ListPoints(List) texture{...}}

But it crashes after some added points (I think it is memory allocation
problem). Becouse it crashed I try to calculate number of entries before
creating List and declare proper value for Start and than it works fine but ...
Sometimes I forget to close point in AddPoint for example AddPoint(List,<3,4,7)
or forget write first argument AddPoint(<3,4,7>) and parsing stops but parser
points warning inside macro AddPoint. I correct my mistake and run it again but
than parser says that some "Points in polygon are no coplanar and will be
ignored" (or something like this) but it is rendered ok. After some more such
mistakes and repairs appear two things - parser crashes or goes to infinity!!!
After restart it parses correctly without any warning.

I'm talking about runing with MegaPOV 0.7 but this source should works with pure
POV-Ray 3.1 I think

I'll try investigate texturing problem after moment.

ABX


Post a reply to this message

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