// Stereo.inc - Viktor Ferenczi 2002 // // Usage: // // Create an animation with even number of frames. // Even frames will be the left, odd frames will be the right images. // Use clk on the place of clock and stereo_fnum on the place of frame_number for animations. // // #declare cyclic_animation 1; // Declare this for cyclic animation only // #include "Stereo.inc" // // ... // // camera { // StereoCamera1(<0,0.5,-1>, <0,0,0>, image_width/image_height,1,0.6, 0.065,0) // } #if(final_frame>initial_frame) #local df=frame_number-initial_frame; #local fn=final_frame-initial_frame+1; #local cd=final_clock-initial_clock; #declare stereo_fnum=div(df,2); #declare stereo_side=1-mod(df,2)*2; #ifdef(cyclic_animation) #declare clk=initial_clock+cd*stereo_fnum/div(fn+2,2); #else #declare clk=initial_clock+cd*stereo_fnum/div(fn,2); #end #else #declare stereo_fnum=0; #declare stereo_side=0; #declare clk=initial_clock #end #macro StereoCamera1(loc,look,rvs,uvs,dist,base,roll) // loc=average location of eyes // look=look_at destination // rvs=right vector size (for aspect ratio and camera angle control) // uvs=up vector size (for aspect ratio and camera angle control) // dist=distance of the image plane from the eyes (equal for left and right one) // base=stereo base (distance of the right eye from the left one) // roll=angle of the line between the left and right eyes and the XZ plane #local dv=look-loc; #local dvn=vnormalize(dv); #local rvn=vcross(dvn,-y); #if(vlength(rvn)<0.5) #local rvn=x; #end #local uvn=vcross(dvn,rvn); #local ssh=rvn*base*0.5*stereo_side; /* #debug "dv=" #debug concat(str(dv.x,0,3),",") #debug concat(str(dv.y,0,3),",") #debug concat(str(dv.z,0,3)," ") #debug "dvn=" #debug concat(str(dvn.x,0,3),",") #debug concat(str(dvn.y,0,3),",") #debug concat(str(dvn.z,0,3)," ") #debug "rvn=" #debug concat(str(rvn.x,0,3),",") #debug concat(str(rvn.y,0,3),",") #debug concat(str(rvn.z,0,3)," ") #debug "uvn=" #debug concat(str(uvn.x,0,3),",") #debug concat(str(uvn.y,0,3),",") #debug concat(str(uvn.z,0,3)," ") */ location loc+ssh direction dvn*dist-ssh right rvn*rvs up uvn*uvs #end