POV-Ray : Newsgroups : povray.text.scene-files : BlobObject macros Server Time
28 Jul 2024 12:37:59 EDT (-0400)
  BlobObject macros (Message 1 to 1 of 1)  
From: Chris Huff
Subject: BlobObject macros
Date: 20 Mar 2000 07:29:45
Message: <chrishuff_99-758684.07314820032000@news.povray.org>
#version unofficial MegaPov 0.4;

#declare rs = seed(4654786);
#macro BlobObject(containerObj, compNum, Strength, Rad)
// containerObj is the object to hold all of the blob components.
// compNum is the number of components.
// Strength is the strength for the components.
// Rad is the radius of the components.
    #local K=0;
    #while(K<compNum)
        #local Pos = < rand(rs), rand(rs), rand(rs)>*
                    (max_extent(containerObj)-min_extent(containerObj))+
                    min_extent(containerObj);
        #while(eval_pattern(object {containerObj}, Pos) = 0)
            #local Pos = < rand(rs), rand(rs), rand(rs)>*
                        
(max_extent(containerObj)-min_extent(containerObj))+
                        min_extent(containerObj);
        #end
        sphere {Pos, Rad strength Strength}
        #local K=K+1;
    #end
#end
#macro BlobObject2(containerObj, compNum, Strength, Rad)
// containerObj is the object to hold all of the blob components.
// compNum is the blob resolution. It is a vector where the x, y, and z
//     values are the number of components the grid will have on each 
axis.
// Strength is the strength for the components.
// Rad is the radius of the components.
    #local compCnt = 0;
    #local J=0;
    #while(J<compNum.x)
    #local K=0;
        #while(K<compNum.y)
            #local L=0;
            #while(L<compNum.z)
                #local Pos = < J/(compNum.x), K/(compNum.y), 
L/(compNum.z)>*
                            
(max_extent(containerObj)-min_extent(containerObj))+
                            min_extent(containerObj)+0.001;
                #if(eval_pattern(object {containerObj}, Pos) > 0)
                    sphere {Pos, Rad strength Strength}
                    #local compCnt=compCnt+1;
                #end
                #local L=L+1;
            #end
            #local K=K+1;
        #end
        #local J=J+1;
    #end
    #debug concat("\ncomponents in blob: ", str (compCnt, 2, 5), "\n")
#end


Example:
object {// Obj
    blob {
        BlobObject(Obj, 6000, 0.5, 0.05)
//      BlobObject2(Obj, < 512, 64, 1>, 2, 0.05)
        threshold 0.5
    }
    texture {
        pigment {color rgb < 0.45, 1, 0.3>}
        finish {
            blinn 1
            metallic
            reflection_min 0
            reflection_max 0.25
            reflection_type 1
            reflect_metallic
        }
    }
    interior {ior 1.22}
}

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

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