POV-Ray : Newsgroups : povray.general : string interpretation Server Time
28 Nov 2024 02:53:06 EST (-0500)
  string interpretation (Message 1 to 5 of 5)  
From: Jim
Subject: string interpretation
Date: 17 Sep 2007 20:05:00
Message: <web.46ef14c6c496b69291227f400@news.povray.org>
I'm trying to create a sort of "catalog" of textures in the various standard
include files - for instance, "woods.inc" which defines T_Wood1 through
T_Wood35.

After setting up a simple test scene, I convert it into an animation so that
each texture is rendered in its own frame. I find myself wanting to define
the texture that is used based on the frame number thusly:

#declare textString = concat ("T_Wood",str(frame_number,2,0));
[...]
texture { textString }

That doesn't work. :(


So am I left with a hand-coded #switch statement with a series of #cases-
#case(n)
#declare MyTexture = texture{T_Wood<n>}
#break

There's no "casting" of a string to any other type. Or is there perhaps some
magic solution I'm not seeing?

The "woods" file is actually pretty easy to enumerate compared to some of
the others - so I'm really after a more general solution. I know I could
whip something up in Perl that would spit out scene files dynamically (and
of course call up POV with input from stdin) but I would like to keep
everything in the POV SDL if possible.

Thanks for any tips/hints anyone can offer.


Post a reply to this message

From: Tom York
Subject: Re: string interpretation
Date: 17 Sep 2007 20:35:00
Message: <web.46ef1c5d490f90337d55e4a40@news.povray.org>
"Jim" <nomail@nomail> wrote:
> There's no "casting" of a string to any other type. Or is there perhaps some
> magic solution I'm not seeing?

Parse_String() might be what you want. See 3.7.16, documentation for the
strings.inc standard include file.

Tom


Post a reply to this message

From: Alain
Subject: Re: string interpretation
Date: 18 Sep 2007 00:45:06
Message: <46ef57d2$1@news.povray.org>
Jim nous apporta ses lumieres en ce 2007/09/17 19:59:
> I'm trying to create a sort of "catalog" of textures in the various standard
> include files - for instance, "woods.inc" which defines T_Wood1 through
> T_Wood35.
> 
> After setting up a simple test scene, I convert it into an animation so that
> each texture is rendered in its own frame. I find myself wanting to define
> the texture that is used based on the frame number thusly:
> 
> #declare textString = concat ("T_Wood",str(frame_number,2,0));
> [...]
> texture { textString }
> 
> That doesn't work. :(
> 
> 
> So am I left with a hand-coded #switch statement with a series of #cases-
> #case(n)
> #declare MyTexture = texture{T_Wood<n>}
> #break
> 
> There's no "casting" of a string to any other type. Or is there perhaps some
> magic solution I'm not seeing?
> 
> The "woods" file is actually pretty easy to enumerate compared to some of
> the others - so I'm really after a more general solution. I know I could
> whip something up in Perl that would spit out scene files dynamically (and
> of course call up POV with input from stdin) but I would like to keep
> everything in the POV SDL if possible.
> 
> Thanks for any tips/hints anyone can offer.
> 
> 
Already done for you. Look at the portfolio folder and run the various *.ini 
files you find there. It will generate all the textures, pigments, materials, 
primitives and some more, and the html code to view them in any browser.

For example, you will get 7 wood pages showing 6 wooden textures each.

-- 
Alain
-------------------------------------------------
   It's tough to stay married. My wife kisses the dog on the lips, Yet she won't 
drink from my glass!
	Rodney Dangerfield


Post a reply to this message

From: Jim
Subject: Re: string interpretation
Date: 18 Sep 2007 19:15:00
Message: <web.46f05b83490f903391227f400@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
> Already done for you. Look at the portfolio folder and run the various *.ini
> files you find there. It will generate all the textures, pigments, materials,
> primitives and some more, and the html code to view them in any browser.
>
> For example, you will get 7 wood pages showing 6 wooden textures each.

Somehow I missed that particular directory - sure enough, it gives me almost
everything I wanted. As I said *any* tips are welcome. Many thanks.


Post a reply to this message

From: Sherry Shaw
Subject: Re: string interpretation
Date: 22 Sep 2007 12:58:00
Message: <46f54998@news.povray.org>
Jim wrote:
> 
> #declare textString = concat ("T_Wood",str(frame_number,2,0));
> 

Tried sending that to #debug and got "T_Wood 0"; try this instead:

    #declare textString = concat ("T_Wood",str(frame_number,1,0));

The "L" parameter (the 1 in the middle) is the *minimum* length of the 
formatted number, so it doesn't truncate the value.  Didn't try it in a 
scene, and didn't use frame_number but rather just a loop index, but it 
looks right in the Messages pane.

--Sherry Shaw



-- 
#macro T(E,N)sphere{x,.4rotate z*E*60translate y*N pigment{wrinkles scale
.3}finish{ambient 1}}#end#local I=0;#while(I<5)T(I,1)T(1-I,-1)#local I=I+
1;#end camera{location-5*z}plane{z,37 pigment{granite color_map{[.7rgb 0]
[1rgb 1]}}finish{ambient 2}}//                                   TenMoons


Post a reply to this message

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