|
|
Hi All,
I have been attempting to write a simple function to help me with making quick
and dirty solar system models...
I have attempted to read the user defined function manual, but it doesn't really
go into much detail, or give examples of anything more than a one line function.
You can probably tell what I want to do with this function (does not run!)
#declare drawPlanet = function(siz, rads, ang, col)
{
xcord = rads * cos(ang * (pi / 180) )
zcord = rads * sin(ang * (pi / 180) )
sphere
{
<xcord, 0, zcord>, siz
texture { pigment col } }
}
}
If I #declare xcord, then I will get an error message, because I can not use an
uninitialized identifier. From what I could tell, #declares are more one off
variables, or globals, rather than function specific.
Without the #declare in xcoord, I get:
File Context (5 lines):
xcord = rads * cos(ang * (pi / 180) )
zcord
Parse Error: Expected 'operator', undeclared identifier 'zcord' found instead.
I am not sure if there is a specific way you declare a temporary float in povray
(say in C you would have float $xcoord, or so on... my C is pretty rusty too!)
Considering I have to do about 40 of these basic systems, I'd hate to have to
create each system by hand, rather than using a simple function like this.
If there is any other documentation on function writing, I found this page
(http://www.povray.org/documentation/view/3.6.1/231/) did not give enough info
for me to be able to work it out on my own :)
Ryan
Post a reply to this message
|
|
|
|
> I have attempted to read the user defined function manual, but it
doesn't really
> go into much detail, or give examples of anything more than a one
line function.
That's because functions don't support what you're trying to do. They
only support simple mathematical expressions. You probably want to make
a #macro instead. Then #declare will work.
#macro drawPlanet(siz, rads, ang, col)
#declare xcord = rads * cos(ang * (pi / 180) );
#declare zcord = rads * sin(ang * (pi / 180) );
sphere
{
<xcord, 0, zcord>, siz
texture { pigment { col } }
}
#end
- Slime
Post a reply to this message
|
|
|
|
Ryan Abrahams <nomail@nomail> wrote:
> I have attempted to read the user defined function manual, but it doesn't really
> go into much detail, or give examples of anything more than a one line function.
That's because user-defined functions do not support anything else than
what is documented.
What you are looking for is the #macro feature.
--
- Warp
Post a reply to this message
|
|