19 30 58void DrawFig HDC hdc Vector vec POINT int red grn blu Vector i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
19:30:58void DrawFig(HDC hdc, Vector vec[])
{
POINT P[3];
int red,grn,blu;
Vector intens_v(int_x,int_y,int_z),max,mid,min,max1,min1,v1,v2,a,b,n,T;
double k=0.5,K=1,Int,d;
for (int i = 0; i < NS; i++)
{
if(!visible[i]) continue;
a=(v[side[i][0]-1]-v[side[i][1]-1]);
b=(v[side[i][2]-1]-v[side[i][1]-1]);
n=a^b;
n=Normalize(n);
T=((v[side[i][0]-1]+v[side[i][1]-1])/2+v[side[i][2]-1])/2;
T=T-intens_v;
d=pow(T.x*T.x+T.y*T.y+T.z*T.z,0.5);
Int=(n&Normalize(intens_v))*intens*k*1000/(d+K);
if(Int<2.0) Int=2.0;
red=R*Int/3; grn=G*Int/3; blu=B*Int/3;
if(red>255) red=255; if(grn>255) grn=255; if(blu>255) blu=255;
HPEN hPen=CreatePen(PS_SOLID,3, RGB(red,grn,blu));
SelectObject(hdc, hPen);
if(vec[side[i][0]-1].y>vec[side[i][1]-1].y&&vec[side[i][0]-1].y>vec[side[i][2]-1].y)
{
max=vec[side[i][0]-1];
if(vec[side[i][1]-1].y>vec[side[i][2]-1].y)
{
mid=vec[side[i][1]-1];
min=vec[side[i][2]-1];
}
else
{
mid=vec[side[i][2]-1];
min=vec[side[i][1]-1];
}
}
else
{
if(vec[side[i][1]-1].y>vec[side[i][2]-1].y)
{
ma