  | 
  | 
 
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
I am generating an animation which involves loading a different mesh
each frame.  The mesh is in an include file and i can compute the names
of the include file and the mesh object from the frame number.  
How can i instantiate an object from a string whose contents are the
text of the object's identifier?
ie
#declare OBJECTNAME = concat("mesh", str(frame_number,0,0));
and there's an included file with 
#declare MYMESH1 = mesh2 { ... }
(for the next frame, it'd be
#declare MYMESH2 = mesh2 { ... }
)
i'd like to say:
object { OBJECTNAME
...
}
but this doesn't work because OBJECTNAME is a string identifier... how
to achieve the effect of object{} reading the contents of the string as
the identifier?
thanks,
peter
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
You either put all the #declared mesh identifiers in an array and
you index that array with your frame number, or you can write the
meshes directly in the include files (and not as #declared identifiers)
and then #include that include file directly (perhaps inside an
object {} block if you want to eg. transform it).
-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
On Fri, 30 Jan 2004 13:58:53 -0800, Peter MacMurchy <pet### [at] cpsc ucalgary ca>
wrote:
>How can i instantiate an object from a string whose contents are the
>text of the object's identifier?
It could be the extension, I often use incriminatingly named meshes generated by
Poser. Here is my method, please excuse the strange variable names, also there
is a bit of "logic" from when I used the clock variable and there was a problem
going from 9 to 10.
#declare Cycle01_Max = 120;                              //      Number of
frames in the cycle.
#declare F_Name = "nene_bal1303a_"       ;      //      incriminating mesh 1
#declare F_Name2 = "Suit_Bal1303a_"       ;     //      incriminating mesh 2
#if (frame_number < 1 )
                #declare Cycle01Pos = 0;     
                 #declare
Material_clock1=concat(F_Name,str(int(Cycle01Pos+0),-1,0),"_o.inc") 
                 #declare
Material_clock2=concat(F_Name2,str(int(Cycle01Pos+0),-1,0),"_o.inc") 
                #else 
                
                #declare Cycle01Pos =  mod (frame_number-1, Cycle01_Max); 
                #declare
Material_clock1=concat(F_Name,str(int(Cycle01Pos-0),-1,0),"_o.inc")
                #declare
Material_clock2=concat(F_Name2,str(int(Cycle01Pos-0),-1,0),"_o.inc")
                #end
//#include "nene_bal1303a_0_p.inc"	// This is the original line generated
by Moray.
#include "Nene_Bal1303a_0_moray_mat.inc" 
// This uses the same material map (UV mapping) for each mesh
#include Material_clock1        // This is the incriminating mesh
Regards
        Stephen
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
Wasn't it Warp who wrote:
>  You either put all the #declared mesh identifiers in an array and
>you index that array with your frame number, or you can write the
>meshes directly in the include files (and not as #declared identifiers)
>and then #include that include file directly (perhaps inside an
>object {} block if you want to eg. transform it).
Or you could be more clumsy and use Parse_String.
#include "strings.inc"
#declare OBJECTNAME = concat("MYMESH",str(frame_number,0,0))
object { Parse_String(OBJECTNAME) 
 ...
}
-- 
Mike Williams
Gentleman of Leisure
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 
 | 
  |