|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I use balls with various colors that should be changed frequently based on
the ball's property such as energy (ball = atom). How do I do that?
The following code reads the file consisting of three coordinates x,y,z of
atoms and draws the balls. However, I need to use a 4th variable, e.g.
energy, E and read the following string:
x,y,z,E
and then somehow use E as a feature to change the color of an atom. How do I
do that?
#while (defined(MyFile))
#read (MyFile, MyVectX, MyVectY, MyVectZ)
#declare MyVect = <MyVectX, MyVectY, MyVectZ>;
sphere {MyVect, 1 texture {pigment {color rgb <a,b,c>}}}
#end
#fclose MyFile
Can I automatically define and declare three constants a,b,c?
thanks
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
If you're able to control the format of that file it would be easier to have
the syntax:
<x,y,z>,E
and read MyVect directly:
#while (defined(MyFile))
#read (MyFile, MyVect)
sphere {MyVect, 1 texture {pigment {color rgb <a,b,c>}}}
#end
#fclose MyFile
To answer your question, it is possible.
The easiest approach i'm aware of is declaring the color in HSL color space
(hue, saturation, lighness) and convert it to RGB color (red, green, blue)
with the function CHSL2RGB(Color) in "colors.inc"
(see documentation for details
http://www.povray.org/documentation/view/3.6.1/434/)
then something like
pigment { color rgb CHSL2RGB<E,240,120> }
where E is in the range 160 (blue) to 0 (red) should do.
It's possible that i'm confusing the range of the HSL values. i think its
<0,0,0> to <240,240,240> but i'm not sure. you might need some testing or
an advice of another person...
Hope that helps
Regards Roman
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I just checked. It seems like the HSL colors are in the range <0,0,0> to
<360,1,1>. Also i forgot the brackets at the function. It should be
pigment { color rgb CHSL2RGB(<E,1,0.5>) }
with E in the range 240 (blue) to 0 (red).
Regards Roman
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Roman Reiner" <lim### [at] gmxde> wrote:
> If you're able to control the format of that file it would be easier to have
> the syntax:
>
> <x,y,z>,E
>
> and read MyVect directly:
>
> #while (defined(MyFile))
> #read (MyFile, MyVect)
> sphere {MyVect, 1 texture {pigment {color rgb <a,b,c>}}}
> #end
> #fclose MyFile
>
> To answer your question, it is possible.
> The easiest approach i'm aware of is declaring the color in HSL color space
> (hue, saturation, lighness) and convert it to RGB color (red, green, blue)
> with the function CHSL2RGB(Color) in "colors.inc"
> (see documentation for details
> http://www.povray.org/documentation/view/3.6.1/434/)
>
> then something like
>
> pigment { color rgb CHSL2RGB<E,240,120> }
>
> where E is in the range 160 (blue) to 0 (red) should do.
>
> It's possible that i'm confusing the range of the HSL values. i think its
> <0,0,0> to <240,240,240> but i'm not sure. you might need some testing or
> an advice of another person...
>
> Hope that helps
> Regards Roman
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hi!
How do read a file in this format: <x,y,z>,E?
the following lines do not work:
#read (MyFile, MyVect; E)
#read (MyFile, MyVect, E)
Thanks.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Roman Reiner" <lim### [at] gmxde> wrote:
> I just checked. It seems like the HSL colors are in the range <0,0,0> to
> <360,1,1>. Also i forgot the brackets at the function. It should be
>
> pigment { color rgb CHSL2RGB(<E,1,0.5>) }
>
> with E in the range 240 (blue) to 0 (red).
>
> Regards Roman
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
OK.
I was able to read in the format <x,y,z>,E
Now the following lines are not accepted - shows error
#declare a = (11 - E)/11*240;
sphere {MyVect, 1 texture {pigment {color rgb CHSL2RGB(<a,1,0.5>) }}}
what is wrong in the above lines?
Thanks.
Post a reply to this message
|
|
| |
| |
|
|
From: Tim Attwood
Subject: Re: How to autmatically change the color of balls?
Date: 29 Aug 2006 00:05:03
Message: <44f3bcef$1@news.povray.org>
|
|
|
| |
| |
|
|
> the following lines do not work:
>
> #read (MyFile, MyVect; E)
> #read (MyFile, MyVect, E)
OK, first you need to check your I/O restrictions...
Options, Script I/O restrictions, No Restrictions
Options, Script I/O restrictions,
Make sure permit read/write in current directory is checked
Secondly, POVray expects comma seperated values...
that means you need trailing commas on every line except
the last. Something like:
<0, 0, 0>, 1.0,
<0, 0.1, 0>, 0.5,
<0, 0.2, 0>, 0.0
You can set the color in various ways, selecting one from
a spline color function is a good way, or you can just
have the full color vector in the file instead.
// set colors based on a float
#declare MyColors = function {
spline {
linear_spline
0.0, Red
0.5, Green
1.0, Blue
}
};
// read the file and make spheres
#fopen FileHandle "test_data.txt" read
#while (defined(FileHandle))
#read (FileHandle, Vector, E)
sphere {Vector, 0.1
pigment { color MyColors(E) }
}
#end
#fclose FileHandle
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Tim Attwood" <tim### [at] comcastnet> wrote:
> Secondly, POVray expects comma seperated values...
> that means you need trailing commas on every line except
> the last. Something like:
>
> <0, 0, 0>, 1.0,
> <0, 0.1, 0>, 0.5,
> <0, 0.2, 0>, 0.0
>
It works! The commas were missing. Thanks.
Post a reply to this message
|
|
| |
| |
|
|
From: Alain
Subject: Re: How to autmatically change the color of balls?
Date: 29 Aug 2006 19:51:12
Message: <44f4d2f0@news.povray.org>
|
|
|
| |
| |
|
|
iz2517 nous apporta ses lumieres en ce 28/08/2006 20:32:
> "Roman Reiner" <lim### [at] gmxde> wrote:
>> I just checked. It seems like the HSL colors are in the range <0,0,0> to
>> <360,1,1>. Also i forgot the brackets at the function. It should be
>>
>> pigment { color rgb CHSL2RGB(<E,1,0.5>) }
>>
>> with E in the range 240 (blue) to 0 (red).
>>
>> Regards Roman
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> OK.
>
> I was able to read in the format <x,y,z>,E
>
> Now the following lines are not accepted - shows error
>
> #declare a = (11 - E)/11*240;
> sphere {MyVect, 1 texture {pigment {color rgb CHSL2RGB(<a,1,0.5>) }}}
>
> what is wrong in the above lines?
> Thanks.
>
>
What is the error?
If it's about undeclared identifier, did you #include "colors.inc"?
--
Alain
-------------------------------------------------
If That Phone Was Up Your Butt, Maybe You Could Drive A Little Better!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alain <ele### [at] netscapenet> wrote:
> What is the error?
> If it's about undeclared identifier, did you #include "colors.inc"?
> Alain
> -------------------------------------------------
> <0, 0, 0>, 1.0, <--------------
> <0, 0.1, 0>, 0.5, <--------------
> <0, 0.2, 0>, 0.0
The error was because the last commas in a row shown by the arrows were
missing.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|