All pastes #957354 Raw Edit

Untitled

public text v1 · immutable
#957354 ·published 2008-03-25 22:32 UTC
rendered paste body
// Persistence of Vision Ray Tracer Scene Description File// File: l_macros.inc// Vers: 3.6// Desc: Macros used by LEGO parts// Auth: Nicolas Alvarez// Date created: 24-2-2004// Last modification: 27-11-2004// 1 POV unit = 1/16 inch#ifndef(Colors_Inc_Temp)#error "this is not a scene!"#end#ifndef(LEGO_LIB_Inc_Temp)#declare LEGO_LIB_Inc_Temp = version;#version 3.5;#ifdef(View_POV_Include_Stack)   #debug "including l_macros.inc\n"#end#include "l_colors.inc"#include "shapes.inc"#include "myinc.inc"DefaultValueList("lego.tmp")	Value("StudType=1")	Value("StudLogo=no")	Value("Ior=yes")EndValueList()#declare SeamWidth=1 / <25,30,25>;#declare Plt=<5,2,5>; //size of p3024#declare Brk=<5,6,5>; //size of p3005#declare JoinMethod=1; //1: union, 2: merge#declare _MaxParts=60;#declare _PartList=array[_MaxParts];#declare _PartDesc=array[_MaxParts];#declare _PartAmnt=0;#macro AddPart(Name)	#if(_PartAmnt>(_MaxParts-1))		#error "Part limit exceeded!\nMake the _PartList array bigger."	#end	#local Idx=strfind(Name," ");	#local N=substr(Name,1,Idx-1);	#local D=substr(Name,Idx+1,strlen(Name)-Idx);	#declare _PartList[_PartAmnt]=N;	#declare _PartDesc[_PartAmnt]=D;	#declare _PartAmnt=_PartAmnt+1;#end#macro round(N) ((N < 0.5) ? floor(N) : ceil(N)) #end#macro Deg(Degrees, Minutes, Seconds) (Degrees + Minutes/60 + Seconds/3600) #end#macro Tb(X,Y,Z) translate Brk*<X,Y,Z> #end#macro Tp(X,Y,Z) translate Plt*<X,Y,Z> #end#macro Rt(  Y  ) rotate y*Y #end#macro UseUnion() #declare JoinMethod=1; #end#macro UseMerge() #declare JoinMethod=2; #end#macro Join()	#switch (JoinMethod)		#case(1)			union		#break		#case(2)			merge		#break		#else			#error "Incorrect JoinMethod number."		#break	#end#end#declare _Logo = union //"borrowed" from L3P{	sphere { <-59,0,-96>,6 }	cylinder { <-59,0,-96>,<59,0,-122>,6 open }	sphere { <59,0,-122>,6}	cylinder { <59,0,-122>,<59,0,-84>,6 open }	sphere { <59,0,-84>,6 }		sphere {<-59,0,-36>,6}	cylinder {<-59,0,-36>,<-59,0,1>,6 open}	sphere {<-59,0,1>,6}	cylinder {<0,0,-49>,<0,0,-25>,6 open}	sphere {<0,0,-25>,6}	sphere {<59,0,-62>,6}	cylinder {<59,0,-62>,<59,0,-24>,6 open}	sphere {<59,0,-24>,6}	cylinder {<-59,0,-36>,<59,0,-62>,6 open}		sphere {<-35.95,0,57>,6}	torus {18.45,6 clipped_by{plane{<40,0,-9>,0}} translate<-40,0,39>}	cylinder {<-44.05,0,21>,<35.95,0,3>,6 open}	torus {18.45,6 clipped_by{plane{<-40,0,9>,0}} translate<40,0,21>}	cylinder {<44.05,0,39>,<0,0,49>,6 open}	sphere {<0,0,49>,6}	cylinder {<0,0,49>,<0,0,34>,6 open}	sphere {<0,0,34>,6}		torus {18.45,6 clipped_by{plane{<40,0,-9>,0}} translate<-40,0,99>}	cylinder {<-44.05,0,81>,<35.95,0,63>,6 open}	torus {18.45,6 clipped_by{plane{<-40,0,9>,0}} translate<40,0,81>}	cylinder {<44.05,0,99>,<-35.95,0,117>,6 open}		scale 4.5/128	scale 1/4}//data for stdTopOpen#local innerRad=1.0;#local outerRad=1.4;#local Height=0.9;#switch(StudType)	#case(0)		#declare stdTop=sphere{0,0};		#declare stdTopOpen=sphere{0,0};		//no stud	#break	#case(1)		#declare stdTop=cylinder //normal top stud (= stud.dat in LDraw)		{			<0,-0.1,0>			<0,1,0>			1.5		}		#declare stdTopOpen=difference //open top stud (= stud2.dat in LDraw)		{			cylinder			{				<0,-0.1,0>				<0,1,0>				outerRad			}			cylinder			{				<0,-0.2,0>				<0,2,0>				innerRad			}		}	#break	#case(2)		#declare stdTop=Round_Cylinder(<0,-0.15,0>, <0,1,0>, 1.5, 0.125,0)		#declare stdTopOpen=merge		{			difference			{				cylinder				{					<0,-0.1,0>					<0,Height,0>					outerRad				}				cylinder				{					<0,-0.2,0>					<0,2,0>					innerRad				}			}			torus			{				((outerRad+innerRad)/2),((outerRad-innerRad)/2)				scale <1,1/4,1>				translate y*Height			}		}	#break	#else		#error concat("Wrong StudType (=",str(StudType,0,0),")")#end#if(StudLogo & StudType>0)#declare stdTop=union{	object{stdTop}	object	{		_Logo		translate <0,1,0>	}}#declare stdTopOpen=union{	object{stdTopOpen}	object	{		_Logo		scale 3/6		translate -y/10	}}#end#declare stdSmallHole=cylinder //bottom holes under stdTop (no LDraw equivalent){	<0, -SeamWidth.y,0>	<0,-2,0>	0.75}#declare stdBottomOpen=difference //bottom open stud (= stud4.dat in LDraw){	cylinder	{		<0,-1,0>		<0,-6,0>		2	}	cylinder	{		<0, 0,0>		<0,-7,0>		1.7	}}#declare stdBottomOpen_p=difference //bottom open stud (for plates){	cylinder	{		<0,-1,0>		<0,-2,0>		2	}	cylinder	{		<0, 0,0>		<0,-3,0>		1.7	}}#declare holeTechPlate=cylinder{	<0, 1,0>	<0,-3,0>	1.7}#declare stdTechHole1=cylinder {	<0,-2.5,+3>	<0,-2.5,-3>	2}#declare stdTechHole2=difference{	union	{		box		{			<-2.25,-0.5, (Brk.z/2-0.5)>			< 2.25,-2.5,-(Brk.z/2-0.5)>		}		cylinder 		{			<0,-2.5,+(Brk.z/2-0.5)>,			<0,-2.5,-(Brk.z/2-0.5)>,			2.25		}	}	cylinder 	{		<0,-2.5, 5>,		<0,-2.5,-5>,		1.6	}}//bottom closed thin stud (= stud3.dat in LDraw)#declare stdBottomThin=cylinder{	<0,-0.5,0>	<0,-5.9,0>	1}//bottom closed thin stud (for plates)#declare stdBottomThin_p=cylinder{	<0,-0.5,0>	<0,-5.9,0>/3	1}#declare stdBottomThinTB=cylinder{	<0,-0.5,0>	<0,-5.9,0>/3	1	Tp(0,-2,0)}#declare stdBottomThinH_p=difference{	object	{		stdBottomThin_p	}	cylinder	{		<0,0,0>		<0,-6,0>/3		0.6	}}#declare Div1=difference{	box	{		< 0.25,-1, 4>		<-0.25,-5,-4>	}	cylinder	{		<0,-1,0>		<0,-7,0>		2	}}#declare F_Lego=finish{	conserve_energy	phong 0.5	phong_size 40	specular 0.8	reflection	{		0,1		fresnel on	}	diffuse 0.6}#declare N_Lego=normal{	bumps 0.05	scale 10}#declare I_Lego=interior{	ior 1.25}#macro LoadMaterial()	#if(Ior)	interior	{		I_Lego	}	#end	LoadTexture()#end#macro LoadTexture()/*	normal	{		N_Lego	}*/	finish	{		F_Lego	}#end#macro Studs(objStud, cantX, cantZ)	#local I=0;	#local J=0;	#local firstStud=<-(cantX-1)*2.5, 0, -(cantZ-1)*2.5>;	#while (I<cantX & StudType > 0)		#declare J=0;		#while (J<cantZ)			object			{				objStud				translate firstStud+<I*5, 0, J*5>			}			#declare J=J+1;		#end		#declare I=I+1;	#end#end#macro StudsV(objStud, cantX, cantZ, Voided)	#local I=0;	#local J=0;	#local firstStud=<-(cantX-1)*2.5, 0, -(cantZ-1)*2.5>;	#while (I<cantX & StudType > 0)		#declare J=0;		#while (J<cantZ)			#if(!Vector_Is_In_Array(Voided,<I,J>))			object			{				objStud				translate firstStud+<I*5, 0, J*5>			}#end			#declare J=J+1;		#end		#declare I=I+1;	#end#end#macro Float_Is_In_Array(Array,fItem)	#local I=0;	#local Result=no;	#while(I<dimension_size(Array,1) & !Result)		#if(Array[I]=fItem)			#local Result=yes;		#end		#local I=I+1;	#end	(Result)#end#macro Vector_Is_In_Array(Array,vItem)	#local I=0;	#local Result=no;	#local vItem3=vItem*<1,1,1>;	#while(I<dimension_size(Array,1) & !Result)		#local V=Array[I]*<1,1,1>;		#if(V.x=vItem3.x & V.y=vItem3.y & V.z=vItem3.z)			#local Result=yes;		#end		#local I=I+1;	#end	(Result)#end#macro Parse_String(String)    #fopen FOut "lego.tmp" write    #write(FOut,String)    #fclose FOut    #include "lego.tmp"#end#macro DumpLegoLibraryStats()	#ifndef(Parts_Inc)		#warning "parts.inc is not loaded!\n"	#else		#local I=0;		#debug "Available parts are:\n"		#debug "Part n.    Description\n"		#while (I<_PartAmnt)			Parse_String(concat("#ifndef(p",_PartList[I],") #error \"part ",_PartList[I]," defined in list only!\"#end"))			#debug concat(str(val(_PartList[I]),5,0),"    ",_PartDesc[I],"\n")			#declare I=I+1;		#end/*		#local I=0;		#local Columns=4;		#local Rows=div(PartAmnt,Columns);		#while (I<div(PartAmnt,Columns))			#local J=I;			#while (J<PartAmnt)				#declare J=J+Rows;			#end			#debug concat("\n")			#declare I=I+1;		#end*/		#debug concat("\nTotal parts: ",str(_PartAmnt,0,0),".\n")	#end	#debug "\n"#end#macro UpdateMLCadFavorites()	#ifndef(Parts_Inc)		#warning "parts.inc is not loaded!\n"	#else		#fopen MLC_FAV "C:\\LDRAW\\MLCad\\MLC_Favorites.txt" write		#write (MLC_FAV,"[FAVORITES]\n")		#local I=0;		#debug "Updating MLC_Favorites...\n"		#while (I<_PartAmnt)			#switch(0)			#case(strcmp(_PartList[I],"0"))				#local Sfx="A";			#break			#case(strcmp(_PartList[I],"3709"))			#case(strcmp(_PartList[I],"3040"))				#local Sfx="B";			#break			#else				#local Sfx="";			#end			#write(MLC_FAV,_PartList[I],Sfx,".DAT\n")			#declare I=I+1;		#end//while		#fclose MLC_FAV	#end//else ifdef p	#debug "Finished.\n"	#debug "\n"#end//macro#macro Align(Obj)	object	{		Obj		Align_Trans(Obj,-y,0)	}#end#macro aBrick(X,Z)box{< Brk.x/2*X,  0,     Brk.z/2*Z>-SeamWidth,<-Brk.x/2*X, -Brk.y,-Brk.z/2*Z>+SeamWidth }#end#macro hBrick(X,Z)box{< Brk.x/2*X-1, -Brk.y-1, Brk.z/2*Z-1>,<-Brk.x/2*X+1, -1,      -Brk.z/2*Z+1> }#end#macro aPlate(X,Z)box{< Plt.x/2*X,  0,     Plt.z/2*Z>-SeamWidth,<-Plt.x/2*X, -Plt.y,-Plt.z/2*Z>+SeamWidth }#end#macro hPlate(X,Z)box{< Plt.x/2*X-1, -Plt.y-1, Plt.z/2*Z-1>,<-Plt.x/2*X+1, -1,      -Plt.z/2*Z+1> }#end#macro bBrick(X,Z)aBrick(X,Z)hBrick(X,Z)#end#macro bPlate(X,Z)aPlate(X,Z)hPlate(X,Z)#end#macro Part(Object,Position,RotationY)	object	{		Object		Rt(RotationY)		Tp(Position.x,Position.y,Position.z)	}#end#macro GetPart(partn)	#fopen tmp concat("lego",str(frame_number,0,0),".tmp") write	#write(tmp,"p",partn)	#fclose tmp	#include concat("lego",str(frame_number,0,0),".tmp")#end#version LEGO_LIB_Inc_Temp;#end //l_macros.inc