POV-Ray : Newsgroups : povray.general : Combining variables with Strings Server Time
16 Nov 2024 15:16:56 EST (-0500)
  Combining variables with Strings (Message 1 to 3 of 3)  
From: Greg Sanders
Subject: Combining variables with Strings
Date: 11 Jun 1998 18:02:39
Message: <6lpjrd$q85$1@oz.aussie.org>
Help!  I am trying to combine a string of text with clock to create an
object name.

For Instance:

clock=0 to 1
frames=100

I want to use various objects named
Target1
Target2
Target3...Target100

I want to multiply clock value by 100 to get integer value (x) and then
place object{TargetX}

Can this be done in POV3?


Post a reply to this message

From: Roland Mas
Subject: Re: Combining variables with Strings
Date: 11 Jun 1998 19:07:17
Message: <m367i74jx6.fsf@clodomir.rezel.enst.fr>
"Greg Sanders" <gvi### [at] oraclerenonvus> writes:

> I want to multiply clock value by 100 to get integer value (x) and then
> place object{TargetX}

> Can this be done in POV3?

  Maybe, but my idea is, uh... tricky. You could try writing a .inc file (in
your .pov file, with #debug directives or so) containing the name of the object
you want to use, then include this file. Will it work? I do not know, since
the file will not have been closed before you attempt to read it. It might be
worth trying, though.

Roland.
-- 

bob### [at] casimirrezelenstfr -- Linux, POV-Ray, LaTeX


Post a reply to this message

From: Chris Colefax
Subject: Re: Combining variables with Strings
Date: 14 Jun 1998 02:39:41
Message: <3583702D.5F0A4736@geocities.com>
Greg Sanders wrote:
> 
> Help!  I am trying to combine a string of text with clock to create an
> object name.
> 
> For Instance:
> 
> clock=0 to 1
> frames=100
> 
> I want to use various objects named
> Target1
> Target2
> Target3...Target100
> 
> I want to multiply clock value by 100 to get integer value (x) and then
> place object{TargetX}

Ideally, you would use an array of declared objects for this purpose;
unfortunately, you will have to wait for POV 3.1 (or perhaps download a
patch) to enable this.  Otherwise, I would suggest using an include
file, containing all your desired objects, wrapped in #switch ... #end
statements, eg:

   #switch (int(clock * 100))
   #case (0)
      object {[... full definition for object 0 ...]}
      #break

   #case (1)
      object {[... full definition for object 1 ...]}
      #break

   ....
   #case (100)
      object {[... final object definition ...]}
   #end

You can then include the file (eg. #include "Target.obj") when you need
the object.  You can even use multiple copies by declaring the include
file as an object variable, eg:

   #declare TargetObject = #include "Target.obj"

This method has the advantage of only requiring memory for the object
being used in the current frame, rather than all 100 objects.  Of
course, you may want to predeclare all 100 objects for some reason or
another (eg. you want to use various Target* objects in a single frame);
in this case, declare all the objects using the desired names (Target1,
Target2, etc.), and change the include file to just read:

   #switch (int(clock * 100))
      #case (0) object {Target1} #break
      #case (1) object {Target2} #break
       ...
      #case (100) object {Target100} #end


Post a reply to this message

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