できた・・・のかな。
まあそれっぽいのを作るのが目標だからいいや。
ビットマップをいじれるようになるとやることの幅が増えていいですね。
次は何しようかな~。
関係ないけど囲碁のAIつくりに興味を持ち出した今日このごろです。
毎回見苦しいコードを張ってる上に自分用クラス使ってるから他の人が見ても何してるかわからないっていう・・・
void CtestView::OnDraw(CDC* pDC)
{
CtestDoc* pDoc =GetDocument();
// 背景
bkcolor = RGB(255,255,255);
// 簡単のためカメラは原点に
CRect rc;
GetClientRect(&rc);
POINT org = {300, 300};
double ang = 3.14/3;
double z = 100 - pDoc->z;
MYPOINT3 p = {0, 0, z};
MYPOINT3 plight = {100, 400, -100};
COLORREF light = RGB(255,255,255);
double r = 30;
double t = tan(ang);
double r2 = r / p.z / t * rc.Height();
COLORREF col = RGB(255,255,50);
double spratter = 0.8; // 拡散係数(ホンマかいな)
double base = 0.5;
MYBITMAP bmp(MYBITMAP::RGB24, 2*r2,2*r2);
double cx = bmp.getw()/2;
double cy = bmp.geth()/2;
double ratio = r2/r;
int x;
int y;
for(int i=0;i= sqrt(r2*r2-x*x))
{
memset(bmp.getvp()+i*bmp.getww()+j*3,0,3);
continue;
}
MYPOINT3 vlight = {plight.x,plight.y,z-plight.z};
MYPOINT3 vgrad = {x/ratio,y/ratio,sqrt(r2*r2-x*x-y*y)/ratio};
double strength = MYGetCos(vlight,vgrad);
if(strength >8)*min(strength + base, 1));
*(bmp.getvp()+i*bmp.getww()+j*3+2)=(char)((BYTE)(col>>16)*min(strength + base, 1));
}
}
bmp.Draw(pDC->m_hDC, org.x-r2/2, org.y-r2/2,true);
}