Replace invalid characters with HTML entities
— with — ’ with ’ + with + × with x ç with ç “ with “ ” with ” ‘ with ‘ • with • – with - µ with µ † with † Fix C++ θ with θ Yen symbol instead of times Fix broken apos Bullet again E-circumflex
This commit is contained in:
parent
9e52de9586
commit
500e7f5654
353 changed files with 5091 additions and 5091 deletions
112
62-02.html
112
62-02.html
|
|
@ -45,8 +45,8 @@
|
|||
Full source code for the BSP-based renderer, and for the
|
||||
accompanying BSP compiler, may be downloaded from
|
||||
ftp.idsoftware.com/mikeab, in the file ddjbsp2.zip.
|
||||
Tested with VC++ 2.0 running on Windows NT 3.5. */
|
||||
#define FIXEDPOINT(x) ((FIXEDPOINT)(((long)x)*((long)0×10000)))
|
||||
Tested with VC++ 2.0 running on Windows NT 3.5. */
|
||||
#define FIXEDPOINT(x) ((FIXEDPOINT)(((long)x)*((long)0x10000)))
|
||||
#define FIXTOINT(x) ((int)(x >> 16))
|
||||
#define ANGLE(x) ((long)x)
|
||||
#define STANDARD_SPEED (FIXEDPOINT(20))
|
||||
|
|
@ -78,7 +78,7 @@ typedef struct _NODE {
|
|||
FIXEDPOINT screenytopstart, screenybottomstart;
|
||||
FIXEDPOINT screenytopend, screenybottomend;
|
||||
} NODE, *PNODE;
|
||||
char * pDIB; // pointer to DIB section we’ll draw into
|
||||
char * pDIB; // pointer to DIB section we’ll draw into
|
||||
HBITMAP hDIBSection; // handle of DIB section
|
||||
HPALETTE hpalDIB;
|
||||
int iteration = 0, WorldIsRunning = 1;
|
||||
|
|
@ -106,7 +106,7 @@ int WallFacingViewer(NODE * pwall)
|
|||
/* // equivalent C code
|
||||
if (( ((pwall->pstartvertex->viewx >> 16) *
|
||||
((pwall->pendvertex->viewz -
|
||||
pwall->pstartvertex->viewz) >> 16)) +
|
||||
pwall->pstartvertex->viewz) >> 16)) +
|
||||
((pwall->pstartvertex->viewz >> 16) *
|
||||
((pwall->pstartvertex->viewx -
|
||||
pwall->pendvertex->viewx) >> 16)) )
|
||||
|
|
@ -138,13 +138,13 @@ WFVDone:
|
|||
void UpdateViewPos()
|
||||
{
|
||||
if (currentspeed != 0) {
|
||||
currentlocation.x += FixedMul(currentdirection.x,
|
||||
currentlocation.x += FixedMul(currentdirection.x,
|
||||
currentspeed);
|
||||
if (currentlocation.x <= WORLD_MIN_X)
|
||||
currentlocation.x = WORLD_MIN_X;
|
||||
if (currentlocation.x >= WORLD_MAX_X)
|
||||
currentlocation.x = WORLD_MAX_X - 1;
|
||||
currentlocation.z += FixedMul(currentdirection.z,
|
||||
currentlocation.z += FixedMul(currentdirection.z,
|
||||
currentspeed);
|
||||
if (currentlocation.z <= WORLD_MIN_Z)
|
||||
currentlocation.z = WORLD_MIN_Z;
|
||||
|
|
@ -152,7 +152,7 @@ void UpdateViewPos()
|
|||
currentlocation.z = WORLD_MAX_Z - 1;
|
||||
}
|
||||
if (currentYSpeed != 0) {
|
||||
fxViewerY += currentYSpeed;
|
||||
fxViewerY += currentYSpeed;
|
||||
if (fxViewerY <= WORLD_MIN_Y)
|
||||
fxViewerY = WORLD_MIN_Y;
|
||||
if (fxViewerY >= WORLD_MAX_Y)
|
||||
|
|
@ -166,18 +166,18 @@ void TransformVertices()
|
|||
FIXEDPOINT tempx, tempz;
|
||||
int vertex;
|
||||
pvertex = pvertexlist;
|
||||
for (vertex = 0; vertex < numvertices; vertex++) {
|
||||
for (vertex = 0; vertex < numvertices; vertex++) {
|
||||
// Translate the vertex according to the viewpoint
|
||||
tempx = pvertex->x - currentlocation.x;
|
||||
tempz = pvertex->z - currentlocation.z;
|
||||
// Rotate the vertex so viewpoint is looking down z axis
|
||||
pvertex->viewx = FixedMul(FixedMul(tempx,
|
||||
currentorientation.z) +
|
||||
currentorientation.z) +
|
||||
FixedMul(tempz, -currentorientation.x),
|
||||
FIXEDPOINT(PROJECTION_RATIO));
|
||||
pvertex->viewz = FixedMul(tempx, currentorientation.x) +
|
||||
pvertex->viewz = FixedMul(tempx, currentorientation.x) +
|
||||
FixedMul(tempz, currentorientation.z);
|
||||
pvertex++;
|
||||
pvertex++;
|
||||
}
|
||||
}
|
||||
// 3-D clip all walls. If any part of each wall is still visible,
|
||||
|
|
@ -192,8 +192,8 @@ void ClipWalls()
|
|||
VERTEX *pstartvertex, *pendvertex;
|
||||
VERTEX *pextravertex = pextravertexlist;
|
||||
pwall = pnodelist;
|
||||
for (wall = 0; wall < numnodes; wall++) {
|
||||
// Assume the wall won’t be visible
|
||||
for (wall = 0; wall < numnodes; wall++) {
|
||||
// Assume the wall won’t be visible
|
||||
pwall->isVisible = 0;
|
||||
// Generate the wall endpoints, accounting for t values and
|
||||
// clipping
|
||||
|
|
@ -205,13 +205,13 @@ void ClipWalls()
|
|||
if (pwall->tstart == FIXEDPOINT(0))
|
||||
tempstartz = pstartvertex->viewz;
|
||||
else
|
||||
tempstartz = pstartvertex->viewz +
|
||||
tempstartz = pstartvertex->viewz +
|
||||
FixedMul((pendvertex->viewz-pstartvertex->viewz),
|
||||
pwall->tstart);
|
||||
if (pwall->tend == FIXEDPOINT(1))
|
||||
tempendz = pendvertex->viewz;
|
||||
else
|
||||
tempendz = pstartvertex->viewz +
|
||||
tempendz = pstartvertex->viewz +
|
||||
FixedMul((pendvertex->viewz-pstartvertex->viewz),
|
||||
pwall->tend);
|
||||
// Clip to the front plane
|
||||
|
|
@ -225,7 +225,7 @@ void ClipWalls()
|
|||
pwall->clippedtend =
|
||||
FixedDiv(pstartvertex->viewz - FrontClipPlane,
|
||||
pstartvertex->viewz-pendvertex->viewz);
|
||||
tempendz = pstartvertex->viewz +
|
||||
tempendz = pstartvertex->viewz +
|
||||
FixedMul((pendvertex->viewz-pstartvertex->viewz),
|
||||
pwall->clippedtend);
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ void ClipWalls()
|
|||
pwall->clippedtstart =
|
||||
FixedDiv(FrontClipPlane - pstartvertex->viewz,
|
||||
pendvertex->viewz-pstartvertex->viewz);
|
||||
tempstartz = pstartvertex->viewz +
|
||||
tempstartz = pstartvertex->viewz +
|
||||
FixedMul((pendvertex->viewz-pstartvertex->viewz),
|
||||
pwall->clippedtstart);
|
||||
} else {
|
||||
|
|
@ -247,13 +247,13 @@ void ClipWalls()
|
|||
if (pwall->clippedtstart == FIXEDPOINT(0))
|
||||
tempstartx = pstartvertex->viewx;
|
||||
else
|
||||
tempstartx = pstartvertex->viewx +
|
||||
tempstartx = pstartvertex->viewx +
|
||||
FixedMul((pendvertex->viewx-pstartvertex->viewx),
|
||||
pwall->clippedtstart);
|
||||
if (pwall->clippedtend == FIXEDPOINT(1))
|
||||
tempendx = pendvertex->viewx;
|
||||
else
|
||||
tempendx = pstartvertex->viewx +
|
||||
tempendx = pstartvertex->viewx +
|
||||
FixedMul((pendvertex->viewx-pstartvertex->viewx),
|
||||
pwall->clippedtend);
|
||||
// Clip in x as needed
|
||||
|
|
@ -264,7 +264,7 @@ void ClipWalls()
|
|||
// side as the start point
|
||||
if (((tempstartx>tempstartz) && (tempendx>tempendz)) ||
|
||||
((tempstartx<-tempstartz) && (tempendx<-tempendz)))
|
||||
// Fully clipped—trivially reject
|
||||
// Fully clipped—trivially reject
|
||||
goto NextWall;
|
||||
// Clip the start point
|
||||
if (tempstartx > tempstartz) {
|
||||
|
|
@ -272,8 +272,8 @@ void ClipWalls()
|
|||
pwall->clippedtstart =
|
||||
FixedDiv(pstartvertex->viewx-pstartvertex->viewz,
|
||||
pendvertex->viewz-pstartvertex->viewz -
|
||||
pendvertex->viewx+pstartvertex->viewx);
|
||||
tempstartx = pstartvertex->viewx +
|
||||
pendvertex->viewx+pstartvertex->viewx);
|
||||
tempstartx = pstartvertex->viewx +
|
||||
FixedMul((pendvertex->viewx-pstartvertex->viewx),
|
||||
pwall->clippedtstart);
|
||||
tempstartz = tempstartx;
|
||||
|
|
@ -281,9 +281,9 @@ void ClipWalls()
|
|||
// Clip the start point on the left side
|
||||
pwall->clippedtstart =
|
||||
FixedDiv(-pstartvertex->viewx-pstartvertex->viewz,
|
||||
pendvertex->viewx+pendvertex->viewz -
|
||||
pendvertex->viewx+pendvertex->viewz -
|
||||
pstartvertex->viewz-pstartvertex->viewx);
|
||||
tempstartx = pstartvertex->viewx +
|
||||
tempstartx = pstartvertex->viewx +
|
||||
FixedMul((pendvertex->viewx-pstartvertex->viewx),
|
||||
pwall->clippedtstart);
|
||||
tempstartz = -tempstartx;
|
||||
|
|
@ -297,8 +297,8 @@ void ClipWalls()
|
|||
pwall->clippedtend =
|
||||
FixedDiv(pstartvertex->viewx-pstartvertex->viewz,
|
||||
pendvertex->viewz-pstartvertex->viewz -
|
||||
pendvertex->viewx+pstartvertex->viewx);
|
||||
tempendx = pstartvertex->viewx +
|
||||
pendvertex->viewx+pstartvertex->viewx);
|
||||
tempendx = pstartvertex->viewx +
|
||||
FixedMul((pendvertex->viewx-pstartvertex->viewx),
|
||||
pwall->clippedtend);
|
||||
tempendz = tempendx;
|
||||
|
|
@ -306,9 +306,9 @@ void ClipWalls()
|
|||
// Clip the end point on the left side
|
||||
pwall->clippedtend =
|
||||
FixedDiv(-pstartvertex->viewx-pstartvertex->viewz,
|
||||
pendvertex->viewx+pendvertex->viewz -
|
||||
pendvertex->viewx+pendvertex->viewz -
|
||||
pstartvertex->viewz-pstartvertex->viewx);
|
||||
tempendx = pstartvertex->viewx +
|
||||
tempendx = pstartvertex->viewx +
|
||||
FixedMul((pendvertex->viewx-pstartvertex->viewx),
|
||||
pwall->clippedtend);
|
||||
tempendz = -tempendx;
|
||||
|
|
@ -334,37 +334,37 @@ void ClipWalls()
|
|||
// Outside view triangle, trivially clipped
|
||||
goto NextWall;
|
||||
}
|
||||
// Partially clipped in Y; we’ll do Y clipping at
|
||||
// Partially clipped in Y; we’ll do Y clipping at
|
||||
// drawing time
|
||||
}
|
||||
// The wall is visible; mark it as such and project it.
|
||||
// +1 on scaling because of bottom/right exclusive polygon
|
||||
// +1 on scaling because of bottom/right exclusive polygon
|
||||
// filling
|
||||
pwall->isVisible = 1;
|
||||
pwall->screenxstart =
|
||||
(FixedMulDiv(tempstartx, fxHalfDIBWidth+FIXEDPOINT(0.5),
|
||||
tempstartz) + fxHalfDIBWidth + FIXEDPOINT(0.5));
|
||||
(FixedMulDiv(tempstartx, fxHalfDIBWidth+FIXEDPOINT(0.5),
|
||||
tempstartz) + fxHalfDIBWidth + FIXEDPOINT(0.5));
|
||||
pwall->screenytopstart =
|
||||
(FixedMulDiv(tempstartwalltop,
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempstartz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempstartz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
pwall->screenybottomstart =
|
||||
(FixedMulDiv(tempstartwallbottom,
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempstartz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempstartz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
pwall->screenxend =
|
||||
(FixedMulDiv(tempendx, fxHalfDIBWidth+FIXEDPOINT(0.5),
|
||||
tempendz) + fxHalfDIBWidth + FIXEDPOINT(0.5));
|
||||
(FixedMulDiv(tempendx, fxHalfDIBWidth+FIXEDPOINT(0.5),
|
||||
tempendz) + fxHalfDIBWidth + FIXEDPOINT(0.5));
|
||||
pwall->screenytopend =
|
||||
(FixedMulDiv(tempendwalltop,
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempendz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempendz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
pwall->screenybottomend =
|
||||
(FixedMulDiv(tempendwallbottom,
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempendz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5), tempendz) +
|
||||
fxHalfDIBHeight + FIXEDPOINT(0.5));
|
||||
NextWall:
|
||||
pwall++;
|
||||
pwall++;
|
||||
}
|
||||
}
|
||||
// Walk the tree back to front; backface cull whenever possible,
|
||||
|
|
@ -377,29 +377,29 @@ void DrawWallsBackToFront()
|
|||
POINT2INT apoint[4];
|
||||
pwall = pnodelist;
|
||||
pendingnodes[0] = (NODE *)NULL;
|
||||
pendingstackptr = pendingnodes + 1;
|
||||
pendingstackptr = pendingnodes + 1;
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
// Descend as far as possible toward the back,
|
||||
// remembering the nodes we pass through on the way.
|
||||
// Figure whether this wall is facing frontward or
|
||||
// backward; do in viewspace because non-visible walls
|
||||
// aren’t projected into screenspace, and we need to
|
||||
// aren’t projected into screenspace, and we need to
|
||||
// traverse all walls in the BSP tree, visible or not,
|
||||
// in order to find all the visible walls
|
||||
if (WallFacingViewer(pwall)) {
|
||||
// We’re on the forward side of this wall, do the back
|
||||
// We’re on the forward side of this wall, do the back
|
||||
// children first
|
||||
pFarChildren = pwall->backtree;
|
||||
} else {
|
||||
// We’re on the back side of this wall, do the front
|
||||
// We’re on the back side of this wall, do the front
|
||||
// children first
|
||||
pFarChildren = pwall->fronttree;
|
||||
}
|
||||
if (pFarChildren == NULL)
|
||||
break;
|
||||
*pendingstackptr = pwall;
|
||||
pendingstackptr++;
|
||||
pendingstackptr++;
|
||||
pwall = pFarChildren;
|
||||
}
|
||||
for (;;) {
|
||||
|
|
@ -419,21 +419,21 @@ void DrawWallsBackToFront()
|
|||
FillConvexPolygon(apoint, pwall->color);
|
||||
}
|
||||
}
|
||||
// If there’s a near tree from this node, draw it;
|
||||
// If there’s a near tree from this node, draw it;
|
||||
// otherwise, work back up to the last-pushed parent
|
||||
// node of the branch we just finished; we’re done if
|
||||
// node of the branch we just finished; we’re done if
|
||||
// there are no pending parent nodes.
|
||||
// Figure whether this wall is facing frontward or
|
||||
// backward; do in viewspace because non-visible walls
|
||||
// aren’t projected into screenspace, and we need to
|
||||
// aren’t projected into screenspace, and we need to
|
||||
// traverse all walls in the BSP tree, visible or not,
|
||||
// in order to find all the visible walls
|
||||
if (WallFacingViewer(pwall)) {
|
||||
// We’re on the forward side of this wall, do the
|
||||
// We’re on the forward side of this wall, do the
|
||||
// front children now
|
||||
pNearChildren = pwall->fronttree;
|
||||
} else {
|
||||
// We’re on the back side of this wall, do the back
|
||||
// We’re on the back side of this wall, do the back
|
||||
// children now
|
||||
pNearChildren = pwall->backtree;
|
||||
}
|
||||
|
|
@ -441,7 +441,7 @@ void DrawWallsBackToFront()
|
|||
if (pNearChildren != NULL)
|
||||
goto WalkNearTree;
|
||||
// Pop the last-pushed wall
|
||||
pendingstackptr—;
|
||||
pendingstackptr—;
|
||||
pwall = *pendingstackptr;
|
||||
if (pwall == NULL)
|
||||
goto NodesDone;
|
||||
|
|
@ -464,7 +464,7 @@ void UpdateWorld()
|
|||
TransformVertices();
|
||||
ClipWalls();
|
||||
DrawWallsBackToFront();
|
||||
// We’ve drawn the frame; copy it to the screen
|
||||
// We’ve drawn the frame; copy it to the screen
|
||||
hdcScreen = GetDC(hwndOutput);
|
||||
holdpal = SelectPalette(hdcScreen, hpalDIB, FALSE);
|
||||
RealizePalette(hdcScreen);
|
||||
|
|
@ -476,7 +476,7 @@ void UpdateWorld()
|
|||
ReleaseDC(hwndOutput, hdcScreen);
|
||||
SelectObject(hdcDIBSection, holdbitmap);
|
||||
ReleaseDC(hwndOutput, hdcDIBSection);
|
||||
iteration++;
|
||||
iteration++;
|
||||
}
|
||||
</PRE>
|
||||
<!-- END CODE //-->
|
||||
|
|
|
|||
Loading…
Reference in a new issue