|
|
Hi All
Im new to povray and Im studying computer graphics as a module for my final
uni course.
Ive been having a play around with povray and Im trying to make a lego brick
wall.
Ive written a macro that creates a lego brick of what ever size u want to
make it then ive written a loop which will create a brick wall given in a
multidimensional array
so if the array is like
2,4,4,4,2
4,4,4,4,0
then the brick wall should look like this
[..][..][..][..]
[][..][..][..][]
but somewhere my maths for the brick translation has gone wrong and what i
actually get is this
[..][..][..][..]
[][..] [..][..][]
i know i need to some how translate each brick based on the size of the
previous brick as well as the current brick size but i just cant get my
head around what i need to do.
here is the povray code:-
global_settings{ambient_light 1}
#include "colors.inc"
#include "textures.inc"
#include "transforms.inc"
#declare block=
union{
box{<0,0,0><0.15,0.25,0.15>}
difference{
cylinder{<0,0,0><0,0.04,0>0.06 translate<0.075,0.25,0.075>}
//text{
// ttf "arial.ttf",
// "LEGO",0.45,0
// rotate <0,90,-90> scale <0.025,0.025,0.025> translate<0.06,0.295,0.1> }
}
}
#macro legobrick(X,Z,col,xup,yup,lastX)
#declare icount=0;
#declare myblock=
union
{
#while(icount<Z)
#declare jcount=0;
#while(jcount<X)
object {block pigment{col} translate<(jcount*0.15),0,icount*0.15>}
#declare jcount=jcount+1;
#end
#declare icount=icount+1;
#end
}
object{myblock translate<(lastX*0.15)*xup,yup*0.25,0>}
#end
#declare WallX=5;
#declare WallY=2;
#declare Wall =
array[WallY][WallX]
{
{2,4,4,4,2},
{4,4,4,4,0}
}
#declare R1 = seed(0);
#declare lx=Wall[0][0];
#declare aicnt=0;
#while(aicnt<WallY)
#declare ajcnt=0;
#while(ajcnt<WallX)
legobrick(Wall[aicnt][ajcnt],2,pigment{rgb<rand(R1),rand(R1),rand(R1)>},ajcnt,aicnt,lx)
#declare lx=Wall[aicnt][ajcnt] ;
#declare ajcnt=ajcnt+1;
#end
#declare aicnt=aicnt+1;
#end
background {color rgb <0.500, 0.500, 1.000>}
light_source {<0,15,-25> White}
light_source {<30,10,50> White}
light_source {<0,50,0> White}
light_source {<-8,14.6,3> rgbt<0.6,0.2,0.2,0.6>}
camera{location <4,1,-2> look_at <1,0,1>}
If anyone can post the right way of doing this so the bricks translate
properly id be very grateful:D
thank you in advance
Post a reply to this message
|
|