POV-Ray : Newsgroups : povray.text.tutorials : Calling a C function from povray? Server Time
4 May 2024 19:56:08 EDT (-0400)
  Calling a C function from povray? (Message 1 to 4 of 4)  
From: Stefan Riedel
Subject: Calling a C function from povray?
Date: 30 Dec 1998 13:04:49
Message: <368A6923.1DC04E88@sz-online.de>
How is it possible to call a C? function (one which takes a time and a
day and gives back
a direction vector - the sun's position for an animation of shadows over
a year)

In hope for an answer


Post a reply to this message

From: Jerry Anning
Subject: Re: Calling a C function from povray?
Date: 30 Dec 1998 15:11:52
Message: <368A88FE.1129061A@dhol.com>
Stefan Riedel wrote:
> 
> How is it possible to call a C? function (one which takes a time and a
> day and gives back
> a direction vector - the sun's position for an animation of shadows over
> a year)

If you only need to call the function once per frame, and know the
calling parameters before you start to render the frame, you can write
the function as a standalone program that takes a command line and saves
a text file containing the desired vector.  Then, in your .ini file, add
a line like this:

PreFrameCommand=C:\Stuff\Sun.exe -t 0800 -d 03041999 -p 800315e472238n

--- or whatever parameters your program takes.  Then use the file
reading ability of 3.1 to read in the vector in the pov code for the
frame.  Or get the macro SunPos (by ingo) at
http://twysted.net/macroscope, tinker it a bit to output your desired
format, and do the calculations with it strictly in your POV code.

Jerry Anning
cle### [at] dholcom


Post a reply to this message

From: Jerry Anning
Subject: Re: Calling a C function from povray? (addendum)
Date: 30 Dec 1998 15:43:18
Message: <368A905F.A4509E70@dhol.com>
Jerry Anning wrote:
> 
> Stefan Riedel wrote:
> >
> > How is it possible to call a C? function (one which takes a time and a
> > day and gives back
> > a direction vector - the sun's position for an animation of shadows over
> > a year)
> 
> If you only need to call the function once per frame, and know the
> calling parameters before you start to render the frame, you can write
> the function as a standalone program that takes a command line and saves
> a text file containing the desired vector.  Then, in your .ini file, add
> a line like this:
> 
> PreFrameCommand=C:\Stuff\Sun.exe -t 0800 -d 03041999 -p 800315e472238n
> 
> --- or whatever parameters your program takes.  Then use the file
> reading ability of 3.1 to read in the vector in the pov code for the
> frame.  Or get the macro SunPos (by ingo) at
> http://twysted.net/macroscope, tinker it a bit to output your desired
> format, and do the calculations with it strictly in your POV code.

I overlooked another method, perhaps the most like what you want.  Get
either Dan Connelly's #system patch or the SuperPatch, which contains
it.  If you are on a nonWindows system, you'll have to get the former
and compile it in.  This gives you the #system command.  You use it like
the #debug command, except that it sends the string you give it to the
shell from inside your scene file and executes it via the system
command.  So you would say this in your .pov file:

#system "C:\Stuff\Sun.exe -t 0800 -d 03041999 -p 800315e472238n"

Jerry Anning
cle### [at] dholcom


Post a reply to this message

From: Jerry Anning
Subject: Re: Calling a C function from povray? (addendum)
Date: 30 Dec 1998 15:46:21
Message: <368A9118.2FEA28EB@dhol.com>
Jerry Anning wrote:

> Get
> either Dan Connelly's #system patch or the SuperPatch, which contains
> it.

I forgot to say that both are found on PatchStation at
http://twysted.net/PatchStation .

Jerry Anning
cle### [at] dholcom


Post a reply to this message

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