Platform SDK: DirectX |
IDirect3DDevice7::ComputeSphereVisibility メソッドは、このデバイスの現在のビューポートにおける球の配列の可視性 (完全、一部、不可視) を計算する。
HRESULT ComputeSphereVisibility( LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues );
基本クリッピング フラグ
組み合わせと一般フラグ
クリップ交差フラグ
クリップ結合フラグ
成功すれば D3D_OK を返す。
失敗すれば、次のいずれかの値を返す。
D3DERR_INVALIDMATRIX |
DDERR_INVALIDOBJECT |
DDERR_INVALIDPARAMS |
球の可視性は、ワールド、ビュー、および射影の合成行列の逆行列を使って視錐台をモデル空間に逆トランスフォームすることにより計算する。この合成行列を逆行列にトランスフォームできない場合 (行列式が 0 の場合) は、メソッドは失敗し、D3DERR_INVALIDMATRIX を返す。
次の C コードは、ComputeSphereVisibility の使用方法を示す。
D3DVECTOR center = {0,0,0}; D3DVALUE radius = 1; DWORD result = 0; res = m_pd3dDevice->ComputeSphereVisibility(¢er, &radius, 1, 0, &result); if (res == D3D_OK) { if (result & D3DSTATUS_CLIPINTERSECTIONALL) { // 球が外側にある。 if (result & D3DSTATUS_CLIPINTERSECTIONLEFT) printf("Sphere left outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONRIGHT) printf("Sphere right outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONTOP) printf("Sphere top outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONBOTTOM) printf("Sphere bottom outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONFRONT) printf("Sphere front outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONBACK) printf("Sphere back outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONGEN0) printf("Sphere gen0 outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONGEN1) printf("Sphere gen1 outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONGEN2) printf("Sphere gen2 outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONGEN3) printf("Sphere gen3 outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONGEN4) printf("Sphere gen4 outside\n"); if (result & D3DSTATUS_CLIPINTERSECTIONGEN5) printf("Sphere gen5 outside\n"); } else if (result & D3DSTATUS_CLIPUNIONALL) { // 球が視錘台と交差する。 if (result & D3DSTATUS_CLIPUNIONLEFT) printf("Sphere left intersect\n"); if (result & D3DSTATUS_CLIPUNIONRIGHT) printf("Sphere right intersect\n"); if (result & D3DSTATUS_CLIPUNIONTOP) printf("Sphere top intersect\n"); if (result & D3DSTATUS_CLIPUNIONBOTTOM) printf("Sphere bottom intersect\n"); if (result & D3DSTATUS_CLIPUNIONFRONT) printf("Sphere front intersect\n"); if (result & D3DSTATUS_CLIPUNIONBACK) printf("Sphere back intersect\n"); if (result & D3DSTATUS_CLIPUNIONGEN0) printf("Sphere gen0 intersect\n"); if (result & D3DSTATUS_CLIPUNIONGEN1) printf("Sphere gen1 intersect\n"); if (result & D3DSTATUS_CLIPUNIONGEN2) printf("Sphere gen2 intersect\n"); if (result & D3DSTATUS_CLIPUNIONGEN3) printf("Sphere gen3 intersect\n"); if (result & D3DSTATUS_CLIPUNIONGEN4) printf("Sphere gen4 intersect\n"); if (result & D3DSTATUS_CLIPUNIONGEN5) printf("Sphere gen5 intersect\n"); } else { printf("Sphere is inside\n"); } } else printf("Invalid return value\n");
Windows NT/2000 :Windows 2000 が必要。
Windows 95/98 : Windows 95 以降が必要。Windows 95 用に再配布可能な形で使用可能。
バージョン :DirectX 7.0 が必要。
ヘッダー : d3d.h で宣言。