POV-Ray : Newsgroups : povray.newusers : Tiles Server Time
2 Jul 2024 21:32:27 EDT (-0400)
  Tiles (Message 1 to 3 of 3)  
From: Haakon Meland Eriksen
Subject: Tiles
Date: 10 Aug 2010 17:00:00
Message: <web.4c61bd92ddd4abbffd54cae30@news.povray.org>
Hello, I've written a simple file I call tiles.pov, which let's you declare a
tile and then loop it to create a roof, a chessboard, a wall or some other tiled
object. Now I need some help to turn it into a macro, something like this

#macro
Tile(ObjectToTile,OffsetX,OffsetY,OffsetZ,DistanceXtile,DistanceYtile,DistanceZtile,RotateXtile,RotateYtile,RotateZtile
)
#end

Unfortunately, I've been unable to figure out how to specify the first
parameter, ObjectToTile. I want this to be any previously declared object. Can
anyone help me solve this?

Here is the current code:


// Persistence of Vision Ray Tracer Scene Description File
// File: tiles.pov
// Vers: 3.6
// Desc: Tiles
// Date: 08/03/2010
// Auth: Haakon Meland Eriksen
// Copyright: GNU LGPLv3

#version 3.6;

#include "colors.inc"
#include "math.inc"
#include "textures.inc"

global_settings {
assumed_gamma 1.0
}

// ----------------------------------------
// perspective (default) camera
camera {
  location  <-3.0, 5.0, -3.0>
  look_at   <4.0, 1.5,  2.0>
  right     x*image_width/image_height
}

sky_sphere {
pigment {
gradient y
color_map {
[0.0 rgb <0.6,0.7,1.0>]
[0.7 rgb <0.0,0.1,0.8>]
}
}
}
light_source {
  0*x                 // light's position (translated below)
  color rgb 1.0       // light's color
  area_light
  <-8, 0, 0> <0, 0, 8> // lights spread out across this distance (x * z)
  4, 4                // total number of lights in grid (4x*4z = 16 lights)
  adaptive 0          // 0,1,2,3...
  jitter              // adds random softening of light
  circular            // make the shape of the light circular
  orient              // orient light
  translate <40, 80, -40>   // <x y z> position of light
}
plane {
y, 0
pigment { color rgb <0.7,0.5,0.3> }
}

// TILE0  - Flat arrow pointed - Grey
#declare Tile0 =
cone {
  0.005*y,  0.145,
  0*y, 0.15
  // open
  texture{
        pigment { color Grey
        }

        normal {pigment_pattern{crackle
                                        colour_map {[0, rgb 0]
                                                    [1, rgb 1]}
                                        scale 0.0001}2}


        finish {ambient 0.1 diffuse 0.9
                phong 1
                phong_size 250
                reflection 0.15
        }

  }
  scale x*0.3
  rotate x*0 // Rotating the single tile
}
// Tile1 - Half cylinder - clay-coloured
#declare Tile1 =
difference {

cylinder {
  0*x,  0.3*z,  0.10
  // open

}

cylinder {
  <0,0,-0.1>,  0.35*z,  0.09
  // open
  }

cylinder {
  <0,-0.05,-0.1>,  0.35*z,  0.10
  // open

}

texture {pigment {color MandarinOrange}}
rotate x*3
}
// Tile2 - Brick - clay-coloured
#declare Tile2 =

box {
  <0, 0, 0>  // one corner position <X1 Y1 Z1>
  < 0.3,  0.1,  0.15>  // other corner position <X2 Y2 Z2>
texture {pigment {color MandarinOrange} normal {bumps 14.5 scale 0.005}}
}
#declare OffsetX = 0.00;
#declare OffsetY = 0.00;
#declare OffsetZ = 0.00;
// Move tile up or down.
#declare DistanceYtile = 0.02;
// Move tile forward or backward
#declare DistanceZtile = 0.25;
// Move tile left or right
#declare DistanceXtile = 0.20;
// Rotate tile forward or backward.
#declare RotateXtile = 0.00;
// Rotate tile left or right.
#declare RotateYtile = 0.00;
// Rotate tile up or down.
#declare RotateZtile = 0.00;
#declare Tiles = union {

#declare TileX = 0;
#declare TileEndX = 90;

#while (TileX <= TileEndX)    // Start making a tile in the X-direction before
continuing.




                #declare TileZ = 0;
                #declare TileEndZ = 9;
                #while (TileZ <= TileEndZ)   // Start making a rooftile in the
Z-direction before continuing.





                                #declare TileY = 0;
                                #declare TileEndY = 0;
                                #while (TileY <= TileEndY)     // Start making a
rooftile in the Y-direction before continuing.




                                                object {Tile1
                                                        translate <
                                                        #declare EvenZ =
even(TileZ);
                                                        #declare OffsetTileX =
TileX+OffsetX;
                                                        #if (EvenZ)
                                                        TileX*DistanceXtile
                                                        #else

OffsetTileX*DistanceXtile
                                                        #end
                                                        ,
                                                        #declare OffsetTileY =
TileZ+OffsetZ;
                                                        #if (EvenZ)

OffsetTileY*DistanceYtile
                                                        #else

OffsetTileY*DistanceYtile
                                                        #end
                                                        , TileZ*DistanceZtile>

                                                        rotate x*RotateXtile
                                                        rotate y*RotateYtile
                                                        rotate z*RotateZtile
                                                        }



                                #declare TileY = TileY + 1;
                                #end



                #declare TileZ = TileZ + 1;
                #end



#declare TileX = TileX + 1;
#end
}
union {
object { Tiles rotate x*-25 translate x*0 translate y*0 translate z*0}
object { Tiles rotate x*-25 rotate y*180 translate x*18 translate y*0 translate
z*4.5 }
translate y*3
}

You can see the result on my homepage, http://far.no/fram/index.php?title=Tiles
If someone can help me, it would be much appreciated.

Yours sincerely,
Haakon Meland Eriksen


Post a reply to this message

From: clipka
Subject: Re: Tiles
Date: 10 Aug 2010 20:01:40
Message: <4c61e864$1@news.povray.org>
Am 10.08.2010 22:58, schrieb Haakon Meland Eriksen:
> Hello, I've written a simple file I call tiles.pov, which let's you declare a
> tile and then loop it to create a roof, a chessboard, a wall or some other tiled
> object. Now I need some help to turn it into a macro, something like this
>
> #macro
>
Tile(ObjectToTile,OffsetX,OffsetY,OffsetZ,DistanceXtile,DistanceYtile,DistanceZtile,RotateXtile,RotateYtile,RotateZtile
> )
> #end
>
> Unfortunately, I've been unable to figure out how to specify the first
> parameter, ObjectToTile. I want this to be any previously declared object. Can
> anyone help me solve this?

Just pass the object to the macro, such as in:

     #declare MyObject = sphere {...}
     Tile ( MyObject, ... )

or even:

     Tile ( sphere {...} , ... )

In the macro, use "ObjectToTile" just like you would use any #declare'd 
object, e.g.

     #macro Tile ( ObjectToTile, ... )
       ...
       object { ObjectToTile }
       ...
     #end


Post a reply to this message

From: Haakon Meland Eriksen
Subject: Re: Tiles
Date: 11 Aug 2010 13:15:01
Message: <web.4c62d9d232ef7009b52d43ba0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 10.08.2010 22:58, schrieb Haakon Meland Eriksen:
> > Hello, I've written a simple file I call tiles.pov, which let's you declare a
> > tile and then loop it to create a roof, a chessboard, a wall or some other tiled
> > object. Now I need some help to turn it into a macro
>
> Just pass the object to the macro, such as in:
>
>      #declare MyObject = sphere {...}
>      Tile ( MyObject, ... )
>
> or even:
>
>      Tile ( sphere {...} , ... )
>
> In the macro, use "ObjectToTile" just like you would use any #declare'd
> object, e.g.
>
>      #macro Tile ( ObjectToTile, ... )
>        ...
>        object { ObjectToTile }
>        ...
>      #end

Thanks, clipka! That did the trick! Here is the new version below, and a new
pov-file, include-file and a new image at
http://far.no/fram/index.php?title=Tiles

Cheers,
Haakon


// Persistence of Vision Ray Tracer Scene Description File
// File: tiles.pov
// Vers: 3.6
// Desc: Tiles
// Date: 08/03/2010
// Auth: Haakon Meland Eriksen
// Copyright: GNU LGPLv3

#version 3.6;

#include "colors.inc"

#include "textures.inc"

global_settings {
assumed_gamma 1.0
}

// ----------------------------------------
// perspective (default) camera
camera {
  location  <-3.0, 5.0, -3.0>
  look_at   <4.0, 1.5,  2.0>
  right     x*image_width/image_height
}

sky_sphere {
pigment {
gradient y
color_map {
[0.0 rgb <0.6,0.7,1.0>]
[0.7 rgb <0.0,0.1,0.8>]
}
}
}
light_source {
  0*x                 // light's position (translated below)
  color rgb 1.0       // light's color
  area_light
  <-8, 0, 0> <0, 0, 8> // lights spread out across this distance (x * z)
  4, 4                // total number of lights in grid (4x*4z = 16 lights)
  adaptive 0          // 0,1,2,3...
  jitter              // adds random softening of light
  circular            // make the shape of the light circular
  orient              // orient light
  translate <40, 80, -40>   // <x y z> position of light
}
plane {
y, 0
pigment { color rgb <0.7,0.5,0.3> }
}

// TILE0  - Flat arrow pointed - Grey
#declare Tile0 =
cone {
  0.005*y,  0.145,
  0*y, 0.15
  // open
  texture{
        pigment { color Grey
        }

        normal {pigment_pattern{crackle
                                        colour_map {[0, rgb 0]
                                                    [1, rgb 1]}
                                        scale 0.0001}2}


        finish {ambient 0.1 diffuse 0.9
                phong 1
                phong_size 250
                reflection 0.15
        }

  }
  scale x*0.3
  rotate x*0 // Rotating the single tile
}
// Tile1 - Half cylinder - clay-coloured
#declare Tile1 =
difference {

cylinder {
  0*x,  0.3*z,  0.10
  // open

}

cylinder {
  <0,0,-0.1>,  0.35*z,  0.09
  // open
  }

cylinder {
  <0,-0.05,-0.1>,  0.35*z,  0.10
  // open

}

texture {pigment {color MandarinOrange}}
rotate x*3
}
// Tile2 - Brick - clay-coloured
#declare Tile2 =

box {
  <0, 0, 0>  // one corner position <X1 Y1 Z1>
  < 0.3,  0.1,  0.15>  // other corner position <X2 Y2 Z2>
texture {pigment {color MandarinOrange} normal {bumps 14.5 scale 0.005}}
}



// Persistence of Vision Ray Tracer Macro File
// File: tile.inc
// Vers: 3.6
// Desc: Tiles
// Date: 08/11/2010
// Auth: Haakon Meland Eriksen
// Copyright: GNU LGPLv3

// You need math.inc. Comment out the next line if you have already included
math.inc.
#include "math.inc"

// Tile macro begins
#macro Tile (
                ObjectToTile,   // ObjectToTile - any previously declared
object.
                OffsetX,        // OffsetX - odd rows are moved by this amount
along the X-axis.
                OffsetY,        // OffsetY - this works, but has no effect!
                OffsetZ,        // OffsetZ - this works, but has no effect!
                DistanceX,      // DistanceX - distance between instances of
object to tile along the X-axis.
                DistanceY,      // DistanceY - distance between instances of
object to tile along the Y-axis.
                DistanceZ,      // DistanceZ - distance between instances of
object to tile along the Z-axis.
                RotateX,        // RotateX - rotate ALL instances of object to
tile around the X-axis.
                RotateY,        // RotateY - rotate ALL instances of object to
tile around the Y-axis.
                RotateZ,        // RotateZ - rotate ALL instances of object to
tile around the Z-axis.
                TileX,          // Start instance of object to tile along the
X-axis at this value.
                TileEndX,       // Number of instances of object to tile along
the X-axis.
                StepX,          // Number of steps between creation of instance
of object to tile along the X-axis.
                // TileZ,       // This doesn't work!
                TileEndZ,       // Number of instances of object to tile along
the Z-axis.
                StepZ,          // Number of steps between creation of instance
of object to tile along the Z-axis.
                // TileY,       // This doesn't work!
                TileEndY,       // Number of instances of object to tile along
the Y-axis. This has no effect, but works!
                StepY           // Number of steps between creation of instance
of object to tile along the Y-axis. This has no effect, but works!
)



#while (TileX <= TileEndX)    // Start making a tile in the X-direction before
continuing.




                #declare TileZ = 0;

                #while (TileZ <= TileEndZ)   // Start making a rooftile in the
Z-direction before continuing.





                                #declare TileY = 0;

                                #while (TileY <= TileEndY)     // Start making a
rooftile in the Y-direction before continuing.




                                                object {ObjectToTile
                                                        translate <
                                                        #declare EvenZ =
even(TileZ);
                                                        #declare OffsetTileX =
TileX+OffsetX;
                                                        #if (EvenZ)
                                                        TileX*DistanceX
                                                        #else
                                                        OffsetTileX*DistanceX
                                                        #end
                                                        ,
                                                        #declare OffsetTileY =
TileZ+OffsetZ;
                                                        #if (EvenZ)
                                                        OffsetTileY*DistanceY
                                                        #else
                                                        OffsetTileY*DistanceY
                                                        #end
                                                        ,
                                                        TileZ*DistanceZ
                                                        >

                                                        rotate x*RotateX
                                                        rotate y*RotateY
                                                        rotate z*RotateZ
                                                        }



                                #declare TileY = TileY + StepY;
                                #end    // End of TileY-loop



                #declare TileZ = TileZ + StepZ;
                #end    // End of TileZ-loop



#declare TileX = TileX + StepX;
#end    // End of TileX-loop
#end    // End of Tile macro

#declare ClayRoof =
// A union to hold both sides of the roof.
union {

// Roof side 1
union {
Tile(
        Tile1,
        0.0,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        0.20,   // DistanceX
        0.02,   // DistanceY
        0.25,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        90,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        9,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )
rotate x*-25
translate x*0
translate y*0
translate z*0

}

// Roof side 2
union {
Tile(
        Tile1,
        0.0,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        0.20,   // DistanceX
        0.02,   // DistanceY
        0.25,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        90,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        9,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )
rotate x*-25
rotate y*180
translate x*18
translate y*0
translate z*4.5
}

// Translate both sides of the roof at the same time up 3 units.
translate y*3
}

// Tile ClayRoof several times with Tile macro
union {
Tile(
        ClayRoof,
        0.0,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        20.00,   // DistanceX
        0.02,   // DistanceY
        0.25,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        3,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        0,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )

}


#declare OldRoof =
// A union to hold both sides of the roof.
union {

// Roof side 1
union {
Tile(
        Tile0,
        0.15,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        0.09,   // DistanceX
        0.02,   // DistanceY
        0.10,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        90,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        9,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )
rotate x*-25
translate x*0
translate y*0
translate z*0

}

// Roof side 2
union {
Tile(
        Tile0,
        0.15,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        0.09,   // DistanceX
        0.02,   // DistanceY
        0.10,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        90,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        9,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )
rotate x*-25
rotate y*180
translate x*8.1
translate y*0
translate z*1.8
}

// Translate both sides of the roof at the same time up 4.5 units.
translate y*4.5
}

// Tile OldRoof several times with Tile macro
union {
Tile(
        OldRoof,
        0.0,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        20.00,   // DistanceX
        0.02,   // DistanceY
        0.25,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        3,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        0,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )

}




#declare Wall =
union {

// Wall side 1
union {
Tile(
        Tile2,
        0.50,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        0.35,   // DistanceX
        0.15,   // DistanceY
        0.00,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        20,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        9,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )
rotate x*0
translate x*2
translate y*0
translate z*0

}

// Wall side 2
union {
Tile(
        Tile2,
        0.50,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        0.35,   // DistanceX
        0.15,   // DistanceY
        0.00,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        20,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        9,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )
rotate x*0
rotate y*90
translate x*2
translate y*0
translate z*5
}

// Translate both walls at the same time down to 0 units.
translate y*0
}

// Tile OldRoof several times with Tile macro
union {
Tile(
        Wall,
        0.0,      // OffsetX
        0.0,      // OffsetY  - this works, but has no effect!
        0.0,      // OffsetZ  - this works, but has no effect!
        20.00,   // DistanceX
        0.02,   // DistanceY
        0.25,   // DistanceZ
        0,      // RotateX
        0,      // RotateY
        0,      // RotateZ
        0,      // Start X-loop at this value
        0,      // Number of instances in X-direction
        1,      // Steps in X-direction
        //0,      // Start Z-loop at this value - this doesn't work!
        0,      // Number of instances in z-direction
        1,       // Steps in Z-direction
        //0,    // Start Y-loop at this value - this doesn't work!
        0,      // Number of instances in Y-direction
        1       // Steps in Y-direction
        )

}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.