POV-Ray : Newsgroups : povray.general : Arrays of objects Server Time
16 Nov 2024 07:12:26 EST (-0500)
  Arrays of objects (Message 1 to 1 of 1)  
From: PoD
Subject: Arrays of objects
Date: 5 Sep 1998 17:14:52
Message: <35F19BB7.48CB@merlin.net.au>
Just in case you're not aware of it, arrays can apparently hold anything
which can be #declared.
I only got around to testing this tonight and was very happy to find
that arrays of objects, textures etc. are legal.  Here's a simple demo.

// arrays of objects and pigments
#include "colors.inc"
#global_settings{assumed_gamma 2.2}
#include "colors.inc"

camera
{
	right x*4/3
	direction z*2
	location  <5.0 , 25.0 ,-40.0>
	look_at   <0.0 , 0.0 , 0.0>
}

light_source
{
	-z*1000
	White
	rotate <30,30,0>
}
light_source
{
	-z*1000
	White
	rotate <50,-40,0>
}
#declare Pig = array[7]
{
	pigment{Red},
	pigment{Green},
	pigment{Yellow},
	pigment{Blue},
	pigment{Magenta},
	pigment{Cyan},
	pigment{White}
}
#declare Obj = array[4]
{
	sphere{0,.5},
	box{-.48,.48},
	cone{-y/2,.5,y/2,0},
	cylinder{-y*.48,y*.48,.5}
}

#declare S = seed(327);
#declare X = -10; #while(X <= 10)
	#declare Z = -8; #while(Z <= 8)
		object{ Obj[rand(S)*3.9999] pigment{Pig[rand(S)*6.9999]}
translate<X,0,Z> }
		#declare Z = Z+1; #end
	#declare X = X+1; #end	

Cheers, PoD.


Post a reply to this message

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