|
![](/i/fill.gif) |
ingo <ing### [at] tag povray org> wrote in news:Xns### [at] povray org:
> in news:Xns### [at] 204 213 191 226 Helen wrote:
>
>> Is there any way to choose textures for some random objects defined
>> in a macro?
>>
>
> Declare the textures you want to choose from, then put the texture-names
> in an array and use the "Rand_Array_Item" from "arrays.inc". See chapter
> 7.1 from the docs.
>
> Ingo
>
>
Thank you.
The array works (sort of), but I am lost.
I declare the array and put the textures in it, then use the macro
Rand_Array_Item (#macro Rand_Array_Item(TexArray, stream).
The stream beats me however. I thought it was a number, but it doesn't
accept numbers or seed(whatever).
It accepts macros and expressions from rand.inc like Rand_Gauss or RdmA,
but not seed(123).
The problem is that I can't see it work.
I put as texture in the object Rand_Array_Item(.... , it almost looks like
the textures are used (all the asteroids look brownish in the small preview
- the look of the first texture in the array), but when I test it using
intense colors with red/blue green/textures, the objects still look
brownish, even though there is no brown texture defined anywhere. It seems
like it keeps the memory of the first texture used and refuses to change
it. I deleted the RCA file, in case that was causing the problem - no
change.
I tried it on a new scene and there are no textures - everything is black.
I don't have any error messages, apart from the usual max_gradient ones for
each of the objects (found too high for some) and a warning "No pigment
type given" at the end of the object on the 3rd line from the end.
I suspect there is something wrong with the stream, but what? What is a
stream anyway? Only text streams come to my mind.
Or else, I am getting these strange errors, because of my haziness in macro
use? The macro is getting too complicated for me and I am not sure if I
missed something.
Full source, below.
-------------------
#include "colors.inc"
#include "arrays.inc"
#include "rand.inc"
#include "Aster-Tex.inc"//texture definitions
global_settings
{
assumed_gamma 1.0
radiosity {}
ambient_light 0
}
light_source {
<-100,100,-100>
color rgb <0.9, 0.8, 0.7>
}
camera {
location <0, -4.5, -12>
look_at <0, 0, 0>
right x*image_width/image_height
}
sky_sphere {
pigment {
gradient y
color_map { [0 color rgb <0.65, 0.75, 0.85> ]
[1 color rgb <0.35, 0.45, 0.55> ]
} rotate <-50,0,0>
}}
//----Stone Textures array
#declare TexArray = array[7];
#declare TexArray[0] = texture {Tex1};
#declare TexArray[1] = texture {Tex2};
#declare TexArray[2] = texture {Tex3};
#declare TexArray[3] = texture {Tex4};
#declare TexArray[4] = texture {Tex5};
#declare TexArray[5] = texture {Tex6};
#declare TexArray[6] = texture {Tex7};
#macro Rand_Array_Item(TexArray, RdmA)
#end
#declare Sphere = function(x,y,z,Radius) {
pow(x,2) + pow(y,2) + pow(z,2) - pow(Radius,2)
}
#macro MyPebble()
object { pebble scale 1}
#end
#declare Size = seed (6);
#declare MyPebble_count = 30;
#declare locations1 = seed(3);
#declare locations2 = seed(5);
#declare locations3 = seed(7);
#declare rotations1 = seed(1);
#declare rotations2 = seed(2);
#declare rotations3 = seed(4);
#declare scales1 = seed(2);
#while (MyPebble_count > 0)
#declare x_loc = rand(locations1)*6-1;
#declare z_loc = rand(locations2)*8-0.5;
#declare y_loc = rand(locations3)*6-1;
#declare x_rot = rand(rotations1)*90-0;
#declare z_rot = rand(rotations2)*90-0;
#declare y_rot = rand(rotations3)*90-0;
#declare sca1 = rand(scales1)*5-2;
#declare MySize = rand (Size)*0.1-1.2;
#declare pebble =
isosurface {
function { Sphere(x,y,z,1)- f_noise3d(x,y,z)*MySize
}
max_gradient 2 evaluate 5, 1.2, 0.95
texture {Rand_Array_Item(TexArray, RdmA)}
scale 1 }
object { MyPebble()
translate <x_loc, y_loc, z_loc>
rotate <x_rot, y_rot, z_rot>
scale sca1
}
#declare MyPebble_count = MyPebble_count - 1;
#end
-----------------------
Helen
Post a reply to this message
|
![](/i/fill.gif) |