P i , r, : r , i n, (. 2).
. , r i n,
r=αi+βn. (1)
= ,
(-i, n) = cos = cos = (r, n).
r = i - 2(i, n)n. (2)
, , (2), .
, . , , , , (i, n).
, P i, t (. 2). , i, n t . (3)
t . :
r=αi+βn. (4)
(3) :
,
. (5)
. (6)
,
. (7)
t
. (8)
(7), :
, (9)
.
, .
, (10)
. (11)
(12)
, ,
(13)
. (14)
, () , .
, t: (t, n) < 0 .
. ,
. (15)
:
, (16)
. (17)
(15) .
, (18)
.
, . , .
, (), (. 3).
|
|
n ( ), h α ,
α = arccos(n, h).
D(α), α ( D(α) δ- ).
D(α):
, (19)
. (20)
m m, .
, P , l. n . , . , v. , , ,. , h
. (21)
, , ,
.
, , :
. (22)
. (23)
, .
(23) , ( , ) . , l . , .
, , .
:
;
;
( ).
P ( ).
P . .
, , .
, .
, P , :
, (24)
;
i- ;
|
|
, ;
, ;
P;
;
;
;
;
P;
P i- ;
( );
;
, ;
, ;
;
.
, , , . , :
. (25)
, , . , , , , , λ.
(, ), , .
:
. (26)
.
DirectX API
Microsoft's DirectX API :
- DirectDraw -
- DirectSound -
- DirectPlay - multiplayer mode
- DirectInput -
, ( ) . DirectDraw.
DirectDraw
DirectDraw . . , -> ... . , DirectDraw , , z - ... 5 DirectX ( ) X - 64 .
DirectDraw , ->. , , 1 .
DirectDraw -
, , , , . DirectDraw . (bitmap), . DirectDraw (surfaces). - ( ( - )), .
DirectDraw - , . DirectDraw 2 M ,
|
|
DirectDraw
LPDIRECTDRAW lpDD; // DirectDraw
// DirectDraw
// 1) Direct Draw Object
// 2)
// 3)
BOOL DirectDrawInit(HWND hwnd)
{
HRESULT ddrval;
// () DirectDraw.
ddrval = DirectDrawCreate(NULL, &lpDD, NULL);
if(ddrval!= DD_OK)
{
goto lError;
}
// DDSCL_EXCLUSIVE -
// DDSCL_FULLSCREEN, ..
// DDSCL_NORMAL - .
ddrval = lpDD->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
if(ddrval!= DD_OK)
{
lpDD->Release();
//lError:
return FALSE;
}
// 800x600 256
// , DDSCL_EXCLUSIVE
ddrval = lpDD->SetDisplayMode(800, 600, 8);
if(ddrval!= DD_OK)
{
lpDD->Release();
goto lError;
}
return TRUE;
}
DirectDraw
, .
. (), , ( , ).
, , , , , , . , .
. ; , , , (. 9).
, ( 4 , , ). , , .
(Binary Space Partitioning), . :
struct BSPNode
{
Facet *facet; // corresponding facet
Vector n; // normal to facet (plane)
Double d; // plane parameter
BSPNode *Left; // left subtree
BSPNode *Right; // right subtree
}
Left , (p, n)>d, Right , (p, n)<d.
, . . :
|
|
;
.
, , , , .
, . C.
void DrawBSPTree(BSPNode *Tree)
{
if((Tree->n & c) > Tree -> d)
{
if (Tree -> Right!= NULL) DrawBSPTree(Tree -> Right);
DrawFacet(Tree -> facet);
if (Tree -> Left!= NULL) DrawBSPTree(Tree -> Left);
}
else
{
if (Tree ->Left!= NULL) DrawBSPTree(Tree -> Left);
DrawFacet(Tree -> facet);
if (Tree -> Right!= NULL) DrawBSPTree(Tree -> Right);
}
}
, .
. z-
z- ( ). .
(x, y) , , , z(x, y) ( ).
+∞.
. , , z-, z-.
. .
, , .
, . , , .
, , (. 7). , .
( ) .
, , , .
, (. 8); , .
. , Oz.
P , Q, Oz P, P. , P . 5 :
1. Ox?
2. Oy?
3. P , Q, ()?
4. Q , P, ()?
5. ?
, P Q , P . , , :
|
|
3. Q , P, ?
4. P , Q, ?
, , , . .
, (. 3). , n l, , , . . , , .
(n, l) ≤ 0,
l .
C P
l = C P.
, , P
(n, l) ≤ 0.
, , , , .
, , .
, .