11.07.2015 Views

Chapter 54

Chapter 54

Chapter 54

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

cmp bx.90*10j a Quadrant2shl bx.2mov ax.word ptr CosTableCbx]mov dx.word ptr CosTable[bx+2]neg bxmov cx.word ptr CosTable[90*10*4+bx+2]mov bx.word ptr CosTable[90*10*4+bxlneg cxneg bxsbb cx.0jmp short CSDonea1 ign ALIGNMENTQuadrant2:neg bxadd bx.180*10shl bx.2mov ax.word ptr CosTable[bx]mov dx.word ptr CosTable[bx+P]neg dxneg axsbb dx,Oneg bxmov cx.word ptr CosTable[90*10*4+bx+2]mov bx.word ptr CosTable[90*10*4+bx]neg cxneg bxsbb cx.0CSDone:push bxmov bx, [ bpl .Cosmov [bx] ,axmov [ bx+2] , dxmov bx. [bpl .SinPOP axmov [bx].axmov Cbx+Zl .cx;quadrant 2 or 3:quadrant 3:look up cosine;sin(Angle) - cos(90-Angle);look ;p sine;negative in this:convert to angle:look up cosine:negative in thisquadrantbetween 0 and 90quadrant:sin(Angle) - cos(90-Angle);look UD sine:negative in this quadrantendif ;USE386POPretXosSinbPendp:restore stack frame; Matrix multiplies Xform by SourceVec. and stores the result in; OestVec. Multiplies a 4x4 matrix times a 4x1 matrix; the result; is a 4x1 matrix. Cheats by assuming the W coord is 1 and the; bottom row of the matrix is 0 0 0 1. and doesn't bother to set: the W coordinate of the destination.; C near-callable as:; void XformVec(Xform WorkingXform. Fixedpoint *SourceVec.Fixedpoint *DestVec);; This assembly code is equivalent to this C code:; int i;3-D Shading 101 5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!