📄 hxfassemble.c
字号:
}
}
if(bDraw != HFALSE)
{
if(HFALSE == bInPrimitive)
{
bInPrimitive = HTRUE;
ctlBeginPrimitiveList( pState, NULL, NULL, 0 );
}
ctlVertex( pState, pVtx0, NULL, NULL );
}
(HBYTE *) pVtx0 += pState->OutVertexSize;
bDraw = HTRUE;
}
// All done; if still in strip, then end list.
if(HFALSE != bInPrimitive)
{
ctlEndPrimitiveList( pState );
}
}
/* ************************************************************************* *\
FUNCTION: HXFAssembleLineList
DESCRIPTION:Line List - Actually line segments..
Draw a pair of connected vertices. All individual.
Basically, submit 2 vertices at a time. No culling, but clipping.
\* ************************************************************************* */
void HXFAssembleLineList(HXFState* pState)
{
HBOOL bInPrimitive = HFALSE;
HBOOL bDraw = HTRUE;
HUINT32 count;
void* pVtx0, *pVtx1;
HUINT16* pSegs = (HUINT16*) pState->pIndices;
HUINT8* pFlags = pState->pOutClipFlags;
HUINT8* pCF1 = NULL;
HUINT8* pCF2 = NULL;
// Algorithm: Take consecutive point pairs {(0,1), (2,3), ...} and submit
// individual Line Strips.
pVtx0 = pState->pOutVertices ;
for (count = 0; count < ((HUINT32) (pState->NumPrimitives) ); count++)
{
pVtx1 = (HBYTE *) pVtx0 + pState->OutVertexSize;
{
pCF1 = pFlags++;
pCF2 = pFlags++;
if (0 != ((*pCF1 & *pCF2)))
{ // Test to see if both points are outside of the same boundary
bDraw = HFALSE;
}
else if (0 != ((*pCF1 | *pCF2)))
{ // Test to see if the triangle spans no boundaries
bDraw = HFALSE;
HXFClipLine(pState, pCF1, pCF2);
}
}
if (bDraw)
{
ctlBeginPrimitiveList( pState, pVtx0, pVtx1, 0 );
ctlEndPrimitiveList( pState );
}
else
{
// Check if we are close to overflow on the clip vertices
if( ((HXF_CLIP_VTX_SPACE - pState->NumClippedVertices)
<= HXF_CLIP_VERTEX_BUFFER_PAD )
|| ((HXF_CLIP_PRIMITIVE_SPACE - pState->NumClippedPrimitives)
<= HXF_CLIP_PRIMITIVE_BUFFER_PAD))
{
HXFDrawClippedLines(pState);
}
}
pVtx0 = (HBYTE *) pVtx1 + pState->OutVertexSize;
bDraw = HTRUE;
}
// Draw the Clipped Vertices
if(pState->NumClippedPrimitives)
{
HXFDrawClippedLines(pState);
}
}
/* ************************************************************************* *\
FUNCTION: HXFAssembleLineStrip
DESCRIPTION: Line List - Actually a connected polyling.
Draw a connected polyline.
Submit 1 vertex at a time. No culling, but clipping.
\* ************************************************************************* */
void HXFAssembleLineStrip(HXFState* pState)
{
HBOOL bInPrimitive = HFALSE;
HBOOL bDraw = HTRUE;
HUINT32 count;
void* pVtx0, *pVtx1;
HUINT16 * pSegs = (HUINT16*) pState->pIndices;
HUINT8* pFlags = pState->pOutClipFlags;
HUINT8* pCF1 = NULL;
HUINT8* pCF2 = NULL;
pVtx0 = pState->pOutVertices;
pCF2 = pFlags++;
for (count = 1; count <= ((HUINT32) (pState->NumPrimitives) ); count++)
{
pVtx1 = (HBYTE *) pVtx0 + pState->OutVertexSize;
{
pCF1 = pCF2;
pCF2 = pFlags++;
if (0 != ((*pCF1 & *pCF2)))
{
bDraw = HFALSE;
}
else if (0 != ((*pCF1 | *pCF2)))
{ // Test to see if the triangle spans no boundaries
bDraw = HFALSE;
HXFClipLine(pState, pCF1, pCF2);
}
}
if(bDraw != HFALSE)
{
if(HFALSE == bInPrimitive) // first triangle in visible strip segment!
{
bInPrimitive = HTRUE;
ctlBeginPrimitiveList( pState, pVtx0, NULL, 0 );
}
ctlVertex( pState, pVtx1, NULL, NULL );
}
else
{
if(HFALSE != bInPrimitive)
{ // For lists we only need to end the list when we flush the
// clip cache. For Strips and Fans this will need to be done
// when ever a triangle is not drawn
bInPrimitive = HFALSE;
ctlEndPrimitiveList( pState );
}
// Check if we are close to overflow on the clip vertices
if( ((HXF_CLIP_VTX_SPACE - pState->NumClippedVertices)
<= HXF_CLIP_VERTEX_BUFFER_PAD )
|| ((HXF_CLIP_PRIMITIVE_SPACE - pState->NumClippedPrimitives)
<= HXF_CLIP_PRIMITIVE_BUFFER_PAD))
{
HXFDrawClippedLines(pState);
}
}
pVtx0 = pVtx1;
bDraw = HTRUE;
}
// All done; if still in strip, then end list.
if(HFALSE != bInPrimitive)
{
ctlEndPrimitiveList( pState );
}
// Draw the Clipped Vertices
if(pState->NumClippedPrimitives)
{
HXFDrawClippedLines(pState);
}
}
/* ************************************************************************* *\
FUNCTION: HXFAssembleLineLoop
DESCRIPTION: Line List - Actually a connected CLOSED polyline
Draw a connected polyline.
Submit 1 vertex at a time. No culling, but clipping.
For the last vertex, submit the first vertex of the primitive.
\* ************************************************************************* */
void HXFAssembleLineLoop(HXFState* pState)
{
HBOOL bInPrimitive = HFALSE;
HBOOL bDraw = HTRUE;
HUINT32 count;
void* pVtx0, *pVtx1;
HUINT16 * pSegs = (HUINT16*) pState->pIndices;
HUINT8* pFlags = pState->pOutClipFlags;
HUINT8* pCF1 = NULL;
HUINT8* pCF2 = NULL;
pCF2 = pFlags++;
pVtx0 = pState->pOutVertices;
for (count = 1; count <= ((HUINT32) (pState->NumPrimitives) ); count++)
{
pVtx1 = (HBYTE *) pVtx0 + pState->OutVertexSize;
{
pCF1 = pCF2;
pCF2 = pFlags++;
if (0 != ((*pCF1 & *pCF2)))
{ // Test to see if both points are outside of the same boundry
bDraw = HFALSE;
}
else if (0 != ((*pCF1 | *pCF2)))
{ // Test to see if the triangle spans no boundaries
bDraw = HFALSE;
HXFClipLine(pState, pCF1, pCF2);
}
}
if(bDraw != HFALSE)
{
if(HFALSE == bInPrimitive) // first triangle in visible strip segment!
{
bInPrimitive = HTRUE;
ctlBeginPrimitiveList( pState, pVtx0, NULL, 0 );
}
ctlVertex( pState, pVtx1, NULL, NULL );
}
else
{
if(HFALSE != bInPrimitive)
{
ctlEndPrimitiveList( pState );
bInPrimitive = HFALSE;
}
// Check if we are close to overflow on the clip vertices
if( ((HXF_CLIP_VTX_SPACE - pState->NumClippedVertices)
<= HXF_CLIP_VERTEX_BUFFER_PAD )
|| ((HXF_CLIP_PRIMITIVE_SPACE - pState->NumClippedPrimitives)
<= HXF_CLIP_PRIMITIVE_BUFFER_PAD))
{
HXFDrawClippedLines(pState);
}
}
pVtx0 = pVtx1;
bDraw = HTRUE;
}
// Send the closing link
{
pCF1 = pCF2;
pCF2 = pState->pOutClipFlags;
if (0 != ((*pCF1 & *pCF2)))
{ // Test to see if both points are outside of the same boundry
bDraw = HFALSE;
}
else if (0 != ((*pCF1 | *pCF2)))
{ // Test to see if the triangle spans no boundaries
bDraw = HFALSE;
HXFClipLine(pState, pCF1, pCF2);
}
}
if(bDraw != HFALSE)
{
if(HFALSE == bInPrimitive) // first triangle in visible strip segment!
{
bInPrimitive = HTRUE;
ctlBeginPrimitiveList( pState, pVtx0, NULL, 0 );
}
pVtx1 = pState->pOutVertices;
ctlVertex( pState, pVtx1, NULL, NULL );
}
// All done; if still in strip, then end list.
if(HFALSE != bInPrimitive)
{
ctlEndPrimitiveList( pState );
}
// Draw the Clipped Vertices
if(pState->NumClippedPrimitives)
{
HXFDrawClippedLines(pState);
}
}
/* ************************************************************************* *\
FUNCTION: HXFAssemblePoints
DESCRIPTION:
\* ************************************************************************* */
void HXFAssemblePoints(HXFState* pState)
{
HBOOL bInPrimitive = HFALSE;
HBOOL bDraw = HTRUE;
HUINT32 count = 0;
void* pVtx0 = NULL;
HUINT16* pArray = (HUINT16*)pState->pIndices;
HUINT8* pFlags = pState->pOutClipFlags;
pVtx0 = pState->pOutVertices;
for (count = 0; count < ((HUINT32) (pState->NumPrimitives) ); count++)
{
{
if(*pFlags++ & (HXF_VTX_CLIP_FLAG_NEG_Z | HXF_VTX_CLIP_FLAG_POS_Z) )
{
bDraw = HFALSE;
}
}
if(bDraw != HFALSE)
{
if(HFALSE == bInPrimitive)
{
bInPrimitive = HTRUE;
ctlBeginPrimitiveList( pState, NULL, NULL, 0 );
}
ctlVertex( pState, pVtx0, NULL, NULL );
}
((HBYTE *) pVtx0) += pState->OutVertexSize;
bDraw = HTRUE;
}
// All done; if still in strip, then end list.
if(HFALSE != bInPrimitive)
{
ctlEndPrimitiveList( pState );
}
}
/* ************************************************************************* *\
** ************************************************************************* **
** EOF
** ************************************************************************* **
\* ************************************************************************* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -