POV-Ray : Newsgroups : povray.binaries.images : G Lissajous - gpovtest.jpg (1/1) : G Lissajous - gpovtest.jpg (1/1) Server Time
14 Aug 2024 11:24:36 EDT (-0400)
  G Lissajous - gpovtest.jpg (1/1)  
From: Christopher James Huff
Date: 27 Oct 2002 17:18:56
Message: <chrishuff-7F4D0F.16412127102002@netplex.aussie.org>
This was done with the G patch I've been talking about on some of the 
other groups. I thought I'd test out G functions with a simple Lissajous 
figure. It currently works, but the G code has to be in a separate file, 
I'm thinking of possible ways to fix that. This demonstrates the use of 
G functions as user-defined vector functions, I'll be working on a way 
to use them in pigments as well, maybe as full-blown shaders.

Here's the G code used (in the file gpovtest.g):

function vector Position(scalar in) {
    scalar t = in*2*pi;
    return [sin(t*9), cos(t*7), cos(t*5)];
};

function vector Color(vector pt) {
    return [sin(pt.x*5)*cos(pt.x*9), sin(pt.x*5)*cos(pt.y*8), 
sin(pt.z*11)*cos(pt.z*7)];
};


And here's the POV code:

global_settings {
    assumed_gamma 1
}

camera {
    location < 0, 0,-5>
    look_at < 0, 0, 0>
    angle 45
}

light_source {<-50, 50,-50>, color rgb 1}
light_source {< 0, 0,-5>, color rgb 0.1}

plane {-z, -1
    texture {
        pigment {checker color rgb 0, color rgb 1}
        finish {ambient 0 diffuse 1}
    }
}

//Compile the G code
g "gpovtest.g"

//hook up POV functions to the G functions
//this just tells POV the name, return type, and parameter types
#declare pointFn = function {g vector Position(scalar)}
#declare colorFn = function {g vector Color(vector)}

#declare J = 0;
#declare N = 3000;
#while(J < N)
    #declare ptA = pointFn(J/N);
    #declare ptB = pointFn((J+1)/N);
    union {
        sphere {ptA, 0.035}
        cylinder {ptA, ptB, 0.05}
        texture {
//            pigment {color rgb ptA/2 + 0.5}
            pigment {color rgb colorFn(ptA.x, ptA.y, ptA.z)}
            finish {
                ambient 0 diffuse 1
                specular 1 roughness 0.01
            }
        }
    }
    #declare J = J + 1;
#end

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message


Attachments:
Download 'gpovtest.jpg' (31 KB)

Preview of image 'gpovtest.jpg'
gpovtest.jpg


 

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