POV-Ray : Newsgroups : povray.text.scene-files : DNA Macro Server Time
31 Oct 2024 23:27:16 EDT (-0400)
  DNA Macro (Message 1 to 1 of 1)  
From: Noam Lewis
Subject: DNA Macro
Date: 24 Dec 1998 16:09:49
Message: <368204D4.DA20C28@tx.technion.ac.il>
This is a little macro I made (for Pov 3.1). It creates a user-defined
DNA string.

documentation coming soon! (The POV file is attached for convenience,
you don't have to copy and paste)

#macro DNA2(BallRad, BallThres, StickRad, Len, Dens, NumBalls, BallUseT,
BallTex, StickUseT, StickTex)

#macro SphereStringTex(Radius, Length, Pack, InitBallCount, UseTex,
BallTexture, Rot)
        #declare BallCount = -(InitBallCount*Length);
        #while (BallCount <= (InitBallCount*Length))
                #declare X = (BallCount*10)/(InitBallCount*Pack*2);
                sphere
                {
                        < X ,1,0>, //BallCount/Length/InitBallCount
                        Radius, 1
                        #if (UseTex != 0)
                                texture {
                                        BallTexture
                                }
                        #end
                        rotate <(BallCount/InitBallCount)*360+Rot,0,0>
                }
                #declare BallCount = BallCount+1; // increment our
counter
        #end
#end

#macro StickStringTex(Radius, Length, Pack, InitBallCount, UseTex,
BallTexture)
#declare BallCount = -(InitBallCount*Length);
#local s1 = seed(33);
#local s2 = seed(27567);

#while (BallCount <= (InitBallCount*Length))
  #declare X = (BallCount*10)/(InitBallCount*Pack*2);
  cylinder
  {
    <X, 1, 0>, //BallCount/Length/InitBallCount
    <X, 0, 0>,
    Radius,1
    #if (UseTex != 0)
    texture {
        BallTexture
    }
    #else
        #declare c = rand(s1)*4;
        #if (c<=1)
                #declare r = 0;
                #declare g = 0;
                #declare b = 1;
        #else
        #if (c<=2)
                #declare r = 0;
                #declare g = 1;
                #declare b = 0;
        #else
        #if (c<=3)
                #declare r = 1;
                #declare g = 0;
                #declare b = 0;
        #else
        #if (c<=4)
                #declare r = 1;
                #declare g = 1;
                #declare b = 0;
        #end
        #end
        #end
        #end
        texture {
                pigment { color rgb <r, g, b> }
        }
    #end
    rotate <(BallCount/InitBallCount)*360,0,0>
  }
  cylinder
  {
    <X, 0, 0>, //BallCount/Length/InitBallCount
    <X, -1, 0>,
    Radius,1
    #if (UseTex != 0)
    texture {
        BallTexture
    }
    #else
        #if (c<=1)
                #declare r = 0;
                #declare g = 1;
                #declare b = 0;
        #else
        #if (c<=2)
                #declare r = 0;
                #declare g = 0;
                #declare b = 1;
        #else
        #if (c<=3)
                #declare r = 1;
                #declare g = 1;
                #declare b = 0;
        #else
        #if (c<=4)
                #declare r = 1;
                #declare g = 0;
                #declare b = 0;
        #end
        #end
        #end
        #end
        texture {
                pigment { color rgb <r, g, b> }
        }
    #end
    rotate <(BallCount/InitBallCount)*360,0,0>
  }
  #declare BallCount = BallCount+1; // increment our counter
#end
#end


blob {
       threshold BallThres
       SphereStringTex(BallRad, Len, Dens, NumBalls, BallUseT,
BallTex,0)
       SphereStringTex(BallRad, Len, Dens, NumBalls, BallUseT, BallTex,
180)
       StickStringTex(StickRad, Len, Dens, NumBalls, StickUseT,
StickTex)
}
#end


Post a reply to this message


Attachments:
Download 'us-ascii' (5 KB)

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