|
|
or am I just plain dense
Consider the following piece of code
Including a datafile in the main body works, but
including it inside a #macro results in an error
at random frames in the animation. It can be at
frame 10 or at frame 500.
Content of data.inc looks like this
#declare CFS[0] = <45.139115, 100.000000, 18.290612>;
.
.
#declare CFS[49] = <44.641327, 100.000000, 17.771019>;
// CODE
#version 3.7;
#declare CenterOfMass = yes;
#declare COMF = 50;
#declare StartLookAt = <0, 80, 0>;
#declare CFS = array[COMF];
#declare LookAt = <500, 100, 0>;
#declare CenterOfMassLookAt = <0, 0, 0>;
#macro WriteCOMFile()
#fopen filehandle "data/data.inc" write
#for(Count, 0, COMF-1, 1)
#write(filehandle, "#declare CFS[",str(Count,0,0),"] = <", vstr(3,
CFS[Count], ", ", -1,-1),">;\n")
#end
#fclose filehandle
#end
#macro InitCenterOfMass()
#for(Count,0, COMF-1, 1)
#declare CFS[Count] = StartLookAt;
#end
WriteCOMFile()
#end
#macro ParseCenterOfMass(NewCenter)
// Including the data file here works sometimes
//#include "data/data.inc"
#for(Count, COMF-1, 1, -1)
#declare CFS[Count] = CFS[Count-1];
#end
#declare CFS[0] = NewCenter;
WriteCOMFile()
#local COMLookAt = <0, 0, 0>;
#declare Count = 0;
#for(Count, 0, COMF-1, 1)
#local COMLookAt = COMLookAt + CFS[Count];
#end
#local COMLookAt = COMLookAt / COMF;
#declare CenterOfMassLookAt = COMLookAt;
#end
#if(frame_number=0)
InitCenterOfMass()
#end
#declare CameraLocation = < 900, 800,-2900>;
#declare Direction = 1;
// Including the data file here works all the time
#include "data/data.inc"
#if(frame_number=1)
#declare LookAt = ParseCenterOfMass(StartLookAt);
#else
ParseCenterOfMass(LookAt)
#declare LookAt = CenterOfMassLookAt;
#end
#declare Direction = vlength(CameraLocation-LookAt)/2000;
camera {
location CameraLocation
look_at LookAt
direction z * Direction
right image_width / image_height * x
}
--
Ger
Post a reply to this message
|
|