tailieunhanh - Advanced 3D Game Programming with DirectX - phần 10
Kể từ khi chương trình này phức tạp mã, tôi đã chọn để đi với một phổ quát w-giá trị của 0,0 thay vì (giải quyết để hình trên 9,24). Các mặt nạ bướm sửa đổi sẽ xuất hiện trong hình 9,25. Các mặt nạ bướm thay đổi tính toán vị trí của | const polygon points in int i m camLoc camLoc m nPlanes 0 for i 0 i i Plane i contains the camera location and the ith edge around the polygon m planes m nPlanes plane3 camLoc i 1 i bool cViewCone Clip const polygon point3 in polygon point3 out Temporary polygons. This isn t thread safe static polygon point3 a 32 b 32 polygon point3 pSrc a polygon point3 pDest b int i Copy the input polygon to a. 640 for i 0 i i i i Iteratively clip the polygon for i 0 i m nPlanes i if m planes i .Clip pSrc pDest Failure return false std swap pSrc pDest If we make it here we have a polygon that survived. Copy it to out. out- nElem pSrc- nElem for i 0 i pSrc- nElem i out- pList i pSrc- pList i 641 Success return true You can perform portal rendering in one of two ways depending on the fill rate of the hardware you re running on and the speed of the host processor. The two methods are exact portal rendering and approximative portal rendering. Exact Portal Rendering To render a portal scene using exact portal rendering you use a simple recursive algorithm. Each cell has a list of polygons a list of portals and a visited bit. Each portal has a pointer to the cell adjacent to it. You start the algorithm knowing where the camera is situated where it s pointing and which cell it is sitting in. From this along with other information like the height width and field of view of the camera you can determine the initial viewing cone that represents the entire viewable area on the screen. Also you clear the valid bit for all the cells in the scene. You draw all of the visible regions of the cell s polygons the visible regions are found by clipping the polygons against the current viewing cone . Also you set the visited bit to true. Then you walk the list of portals for the cell. If the cell on the other side hasn t been visited you try to clip the portal against the viewing cone. If a valid portal fragment results from
đang nạp các trang xem trước