POV-Ray : Newsgroups : povray.general : Combining variables with Strings : Re: Combining variables with Strings Server Time
13 Aug 2024 21:17:50 EDT (-0400)
  Re: Combining variables with Strings  
From: Chris Colefax
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.