POV-Ray : Newsgroups : povray.general : writing a texture identifier to file Server Time
31 Oct 2024 16:17:19 EDT (-0400)
  writing a texture identifier to file (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Thomas de Groot
Subject: writing a texture identifier to file
Date: 19 Jan 2016 03:13:38
Message: <569df032$1@news.povray.org>
I am baffled.

I have this array:

#declare TexArray =
   array[12]{
     T_Stone1,  T_Stone2,
     T_Stone3,  T_Stone4,
     T_Stone5,  T_Stone6,
     T_Stone7,  T_Stone8,
     T_Stone9,  T_Stone10,
     T_Stone11, T_Stone12
   };

I want to write a selected /texture_identifier/ (like "T_stone1" for 
instance) to a file as a string. However, I do not succeed. I thought 
that Parse_String() would do the trick but it generates an error telling 
me that it expects a string but sees a texture_identifier instead.

What to do? Thanks.
-- 
Thomas


Post a reply to this message

From: Jaime Vives Piqueres
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 03:27:16
Message: <569df364$1@news.povray.org>
El 19/01/16 a las 09:13, Thomas de Groot escribió:
> I want to write a selected /texture_identifier/ (like "T_stone1" for
>  instance) to a file as a string. However, I do not succeed. I
> thought that Parse_String() would do the trick but it generates an
> error telling me that it expects a string but sees a
> texture_identifier instead.
>
> What to do? Thanks.

   If I read the docs correctly, Parse_String() does just the contrary:
it takes a string and writes it to a file as an identifier, then
includes that file.

   That is, given the following array...

#declare TexArray =
    array[12]{
      "T_Stone1",  "T_Stone2",
      "T_Stone3",  "T_Stone4",
      "T_Stone5",  "T_Stone6",
      "T_Stone7",  "T_Stone8",
      "T_Stone9",  "T_Stone10",
      "T_Stone11", "T_Stone12"
    };

   ...you would be able to use these as texture identifiers like this:

texture{Parse_String(TexArray[0])}

--
jaime


Post a reply to this message

From: Bill Pragnell
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 03:30:00
Message: <web.569df30c34b3d48e5b7d07940@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> I am baffled.
[snip]

Parse_String() seems to do the opposite of what you want - given a string, it
allows you to use it as an identifier. However I don't know if what you want is
even possible. No doubt Sensei Clipka will elucidate further at some point :)


Post a reply to this message

From: scott
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 03:37:51
Message: <569df5df$1@news.povray.org>
> I am baffled.
>
> I have this array:
>
> #declare TexArray =
>    array[12]{
>      T_Stone1,  T_Stone2,
>      T_Stone3,  T_Stone4,
>      T_Stone5,  T_Stone6,
>      T_Stone7,  T_Stone8,
>      T_Stone9,  T_Stone10,
>      T_Stone11, T_Stone12
>    };
>
> I want to write a selected /texture_identifier/ (like "T_stone1" for
> instance) to a file as a string.

I don't see how something like that would work, because if it did, how 
would it cope with this:

#declare A = 1;
#declare FloatArray =
  array[4]{
        A,A*A,sin(A),MyMacro(A)
  }

What I guess you're asking is if the array somehow remembers the SDL 
text string that was used to create each element (and does it expand 
macros?)? I would be surprised if it did (but then, this is no ordinary 
programming language...).


Post a reply to this message

From: Thomas de Groot
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 03:49:11
Message: <569df887$1@news.povray.org>
On 19-1-2016 9:25, Bill Pragnell wrote:
> Thomas de Groot <tho### [at] degrootorg> wrote:
>> I am baffled.
> [snip]
>
> Parse_String() seems to do the opposite of what you want - given a string, it
> allows you to use it as an identifier. However I don't know if what you want is
> even possible. No doubt Sensei Clipka will elucidate further at some point :)
>
>
Yes, I see where I went wrong indeed. I misread the docs.

-- 
Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 03:54:22
Message: <569df9be$1@news.povray.org>
On 19-1-2016 9:27, Jaime Vives Piqueres wrote:
> El 19/01/16 a las 09:13, Thomas de Groot escribió:
>> I want to write a selected /texture_identifier/ (like "T_stone1" for
>>  instance) to a file as a string. However, I do not succeed. I
>> thought that Parse_String() would do the trick but it generates an
>> error telling me that it expects a string but sees a
>> texture_identifier instead.
>>
>> What to do? Thanks.
>
>    If I read the docs correctly, Parse_String() does just the contrary:
> it takes a string and writes it to a file as an identifier, then
> includes that file.
>
>    That is, given the following array...
>
> #declare TexArray =
>     array[12]{
>       "T_Stone1",  "T_Stone2",
>       "T_Stone3",  "T_Stone4",
>       "T_Stone5",  "T_Stone6",
>       "T_Stone7",  "T_Stone8",
>       "T_Stone9",  "T_Stone10",
>       "T_Stone11", "T_Stone12"
>     };
>
>    ...you would be able to use these as texture identifiers like this:
>
> texture{Parse_String(TexArray[0])}
>
> --
> jaime

The problem is I do not want this, although it could be a solution if 
nothing else pops up that is. I would prefer to write the texture 
identifier as a text string.

To explain a bit more, I am adapting tiling.inc to include textures 
instead of just colours. It is a simple straightforward process where 
running the scene is concerned; however, the writing option for this is 
more tricky than expected.
-- 
Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 03:56:19
Message: <569dfa33$1@news.povray.org>
On 19-1-2016 9:37, scott wrote:
>> I am baffled.
>>
>> I have this array:
>>
>> #declare TexArray =
>>    array[12]{
>>      T_Stone1,  T_Stone2,
>>      T_Stone3,  T_Stone4,
>>      T_Stone5,  T_Stone6,
>>      T_Stone7,  T_Stone8,
>>      T_Stone9,  T_Stone10,
>>      T_Stone11, T_Stone12
>>    };
>>
>> I want to write a selected /texture_identifier/ (like "T_stone1" for
>> instance) to a file as a string.
>
> I don't see how something like that would work, because if it did, how
> would it cope with this:
>
> #declare A = 1;
> #declare FloatArray =
>   array[4]{
>         A,A*A,sin(A),MyMacro(A)
>   }
>
> What I guess you're asking is if the array somehow remembers the SDL
> text string that was used to create each element (and does it expand
> macros?)? I would be surprised if it did (but then, this is no ordinary
> programming language...).

Yes, it is this text string I want to write but it looks like I will 
need to consider another approach, in the way Jaime indicates...
-- 
Thomas


Post a reply to this message

From: dick balaska
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 11:40:01
Message: <569e66e1$1@news.povray.org>
On 1/19/2016 3:13 AM, Thomas de Groot wrote:
> I am baffled.

> What to do? Thanks.

I had a similar need. I ended up doing this and using the appropriate 
array as needed...

#declare TexArray =
   array[12]{
     T_Stone1,  T_Stone2,
     T_Stone3,  T_Stone4,
     T_Stone5,  T_Stone6,
     T_Stone7,  T_Stone8,
     T_Stone9,  T_Stone10,
     T_Stone11, T_Stone12
   };
#declare TexArrayText =
   array[12]{
     "T_Stone1",  "T_Stone2",
     "T_Stone3",  "T_Stone4",
     "T_Stone5",  "T_Stone6",
     "T_Stone7",  "T_Stone8",
     "T_Stone9",  "T_Stone10",
     "T_Stone11", "T_Stone12"
   };


Post a reply to this message

From: clipka
Subject: Re: writing a texture identifier to file
Date: 19 Jan 2016 12:45:28
Message: <569e7638$1@news.povray.org>
Am 19.01.2016 um 09:54 schrieb Thomas de Groot:

>> #declare TexArray =
>>     array[12]{
>>       "T_Stone1",  "T_Stone2",
>>       "T_Stone3",  "T_Stone4",
>>       "T_Stone5",  "T_Stone6",
>>       "T_Stone7",  "T_Stone8",
>>       "T_Stone9",  "T_Stone10",
>>       "T_Stone11", "T_Stone12"
>>     };

> The problem is I do not want this, although it could be a solution if
> nothing else pops up that is. I would prefer to write the texture
> identifier as a text string.

The trouble there is, once the texture is inside the array, there is no
trace of the texture identifier left alongside it.

(Or, more to the point, the texture now has a /new/ identifier,
TexArray[something].)

(Actually, even that is a simplified picture of the matter. What you
/really/ have is a /copy/ of the original texture.)

Also note that if you're starting out with an array of textures, you
might have to deal with something like this:

  #declare TexArray =
    array[12]{
      T_Stone1,
      T_Stone2,
      texture {...},
      T_Stone4,
      ...
    };

No "original" identifier there at all for TexArray[2].


Post a reply to this message

From: Thomas de Groot
Subject: Re: writing a texture identifier to file
Date: 20 Jan 2016 02:42:57
Message: <569f3a81$1@news.povray.org>
On 19-1-2016 18:45, clipka wrote:
> Am 19.01.2016 um 09:54 schrieb Thomas de Groot:
>
>>> #declare TexArray =
>>>      array[12]{
>>>        "T_Stone1",  "T_Stone2",
>>>        "T_Stone3",  "T_Stone4",
>>>        "T_Stone5",  "T_Stone6",
>>>        "T_Stone7",  "T_Stone8",
>>>        "T_Stone9",  "T_Stone10",
>>>        "T_Stone11", "T_Stone12"
>>>      };
>
>> The problem is I do not want this, although it could be a solution if
>> nothing else pops up that is. I would prefer to write the texture
>> identifier as a text string.
>
> The trouble there is, once the texture is inside the array, there is no
> trace of the texture identifier left alongside it.
>
> (Or, more to the point, the texture now has a /new/ identifier,
> TexArray[something].)
>
> (Actually, even that is a simplified picture of the matter. What you
> /really/ have is a /copy/ of the original texture.)
>
> Also note that if you're starting out with an array of textures, you
> might have to deal with something like this:
>
>    #declare TexArray =
>      array[12]{
>        T_Stone1,
>        T_Stone2,
>        texture {...},
>        T_Stone4,
>        ...
>      };
>
> No "original" identifier there at all for TexArray[2].
>

Thanks indeed Christoph, very clear. Happy to have learned something 
again and deepened my understanding of POV-Ray.

-- 
Thomas


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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