|
|
John VanSickle <evi### [at] hotmailcom> wrote:
> Kaka22 wrote:
> > Is it possible to put an image (instead of a color)as a background in a
> > scene ?
> >
> > thanks
>
> Yes. Apply the image to a large polygon and put the polygon in the
> background.
>
> Regards,
> John
Can you please give me a small example...because I tried:
polygon {
4,
<0, 0>, <0, 300>, <300, 300>, <300, 0>
texture {
finish { ambient 1 diffuse 0 }
pigment { image_map { gif "test.gif" } }
}
}
and the image repeats instead of having the whole picture as my background.
thanks
Post a reply to this message
|
|
|
|
Kaka22 wrote:
> John VanSickle <evi### [at] hotmailcom> wrote:
>
>>Kaka22 wrote:
>>
>>>Is it possible to put an image (instead of a color)as a background in a
>>>scene ?
>>>
>>>thanks
>>
>>Yes. Apply the image to a large polygon and put the polygon in the
>>background.
>>
>>Regards,
>>John
>
>
> Can you please give me a small example...because I tried:
> polygon {
> 4,
> <0, 0>, <0, 300>, <300, 300>, <300, 0>
> texture {
> finish { ambient 1 diffuse 0 }
> pigment { image_map { gif "test.gif" } }
> }
> }
> and the image repeats instead of having the whole picture as my background.
> thanks
>
>
>
the image_map is scaled from <0,0> to <1,1> by default so you have to
either
a:
scale the texture to match the size of your object
or
b:
first apply the texture to a unit sized object then scale up the object.
Post a reply to this message
|
|
|
|
Hi, use this code for the usual camera type.
You have to adapt the first lines and the name of the background image
to your scene.
If you use z direction as up, you have to change cam_s to z too.
//____________________________________________________________________________
#declare cam_loc = <0,1.5,-8>; // camera location
#declare lookat = <0,0.5,0>; // camera look_at
#declare cam_ang = 67; // camera angle
#declare back_dist = 1000; // how far away the background should be
#declare cam_mirror = 1; // 1 for normal / -1 for mirror image
#include "transforms.inc"
#declare cam_z = 0.5*image_width/image_height/tan (radians (cam_ang*0.5));
#declare cam_ang_up = degrees (2*atan2(0.5/cam_z,1));
#declare cam_a = cam_mirror*image_width/image_height;
#declare cam_s = y;
#declare cam_d = vnormalize (lookat-cam_loc);
#declare cam_r = vnormalize (vcross (cam_s,cam_d));
#declare cam_up = vnormalize (vcross (cam_d,cam_r));
#declare cam_dir = cam_d*cam_z;
#declare cam_right = cam_r*cam_a;
#declare fz = vlength (cam_dir);
#declare fx = vlength (cam_right)/2;
#declare fy = vlength (cam_up)/2;
#macro OrientZ (p1,p2,cs) // looks like Reorient_trans macro!
#local nz = vnormalize (p2-p1);
#local nx = vnormalize (vcross (cs,nz));
#local ny = vcross (nz,nx);
matrix <nx.x,nx.y,nx.z,ny.x,ny.y,ny.z,nz.x,nz.y,nz.z,p1.x,p1.y,p1.z>
#end
camera {
location cam_loc
up cam_up
right cam_right
direction cam_dir
}
/*
camera { // equivalent camera definition
location cam_loc
right cam_right
look_at lookat
angle cam_ang
}
*/
//_background________________________________________________________________
box {
<0,0,0> <1,1,0.1>
texture {
pigment {
image_map {png "sky" once map_type 0 interpolate 2}
}
finish {ambient 1 diffuse 0}
}
translate <-0.5,-0.5,0>
scale 2*<cam_mirror*fx,fy,0.5>
translate fz*z
scale back_dist
OrientZ (cam_loc,lookat,cam_up)
}
//______________________________________________________________________________
Regards
Norbert Kern
Post a reply to this message
|
|