|
|
Le 19-02-09 à 12:15, ingo a écrit :
> Quite often I run ito the problem that polygons won't render because not
> all the points are on the same plane. Today I figured out how to fix
> that, scene below, but is there a more efficient way?
>
>
> ---%<------%<------%<---
> #version 3.7;
> global_settings{ assumed_gamma 1.0 }
> #default{ finish{ ambient 0.1 diffuse 0.9 }}
> #include "math.inc"
> #include "transforms.inc"
>
> camera {
> perspective angle 5
> location <0 , 10 ,-10>
> look_at <0,0,0>
> }
> light_source{< 500,3000,-500> rgb 1}
> light_source{<-3000,3000,-3000> rgb .5}
>
> #declare Point=array[6]{
> <0.429381,-0.055167, 0.379816>,
> <0.516580,-0.092380, 0.240426>,
> <0.291647,-0.556033,-0.000017>,
> <0.185583,-0.627011, 0.044906>,
> <0.097999,-0.570008, 0.205955>,
> <0.172851,-0.214639, 0.501546>,
> };
> #declare Normal = <0.614179,-0.577098,0.538277>;
>
> // distance from the first point to the plane
> #declare Distance = vdot(Normal,Point[0]);
> #declare T = transform{translate Normal*Distance};
> #for(I,0,dimension_size(Point,1)-1,1)
> // push the points to the aligned plane
> #declare Point[I] = VProject_Plane(Point[I], Normal);
> // translate them to their 'original' positions
> #declare Point[I] = vtransform(Point[I], T);
> #end
>
> polygon{
> 7,
> Point[0]
> Point[1]
> Point[2]
> Point[3]
> Point[4]
> Point[5]
> Point[0]
> pigment{rgb 1}
> }
> sphere{0,0.01 pigment{rgb x}}
>
If you create your polygon on the X-Y plane, you won't have any problem.
Then, it's just a mater of rotating it as needed :
#declare Point=array[6]{
<0.429381,-0.055167>,
<0.516580,-0.092380>,
<0.291647,-0.556033>,
<0.185583,-0.627011>,
<0.097999,-0.570008>,
<0.172851,-0.214639>,
};
polygon{
7,
Point[0]
Point[1]
Point[2]
Point[3]
Point[4]
Point[5]
Point[0]
pigment{rgb 1}
rotate Some_Rotation
}
Post a reply to this message
|
|