📄 vectors.cpp
字号:
/* Vectors.CPP
*
* provides Vector-Operations
*
* Copyright 2003 by PaP / JTMK
*/
#include "stdio.h"
#include <math.h>
#include <windows.h>
#include "SystemIO.h"
#include "vectors.h"
long ErrorVar=0;
HWND MainWindow;
tP3D vNull;
tP3D v100=vSet(1,0,0),v010=vSet(0,1,0),v001=vSet(0,0,1);
tP3D v110=vSet(1,1,0),v011=vSet(0,1,1),v101=vSet(1,0,1);
tP3D vn00=vSet(-1,0,0),v0n0=vSet(0,-1,0),v00n=vSet(0,0,-1);
tP3D v111=vSet(1,1,1);
tOMatrix ErrorMatrix;
tOMatrix Kart_Matrix=KartMatrix();
int Random(long Len)
{
long L;
L=rand()-16384;
if(L<0) L=-L;
return((L*Len)/16384);
}
char *ToString(const char *string, ...)
{
char text[256]; // Holds Our String
char *OutP;
va_list aP; // Pointer To List Of Arguments
if (string == NULL) // If There's No Text
return(""); // Do Nothing
va_start(aP, string); // Parses The String For Variables
vsprintf(text, string, aP); // And Converts Symbols To Actual Numbers
va_end(aP); // Results Are Stored In Text
OutP=text;
return(OutP);
}
// Berechnet neue Orientierungsmatrix
// P1 ist der Punkt mit der alten Matrix
// P2 is der neue
tOMatrix CalcNewMatrix(tP3D P1,tP3D P2,tOMatrix *Matrix,float Roll)
{
__asm
{
mov edi,[ebp+8];
mov esi,Matrix
// mov edi,Matrix
fld1 // 1
fld dword ptr [P1.X] // P1.X
fld dword ptr [P2.X] // P2.X
fsubp st(1),st(0) // P1.X-P2.X
fst dword ptr [edi+tOMatrix.Up.X]
fmul st(0),st(0) // E
fld dword ptr [P1.Y] // P1.Y | E
fld dword ptr [P2.Y] // P2.Y | E
fsubp st(1),st(0) // P1.Y-P2.Y | E
fst dword ptr [edi+tOMatrix.Up.Y]
fmul st(0),st(0)
faddp st(1),st(0) // E
fld dword ptr [P1.Z] // P1.Z | E
fld dword ptr [P2.Z] // P2.Z | E
fsubp st(1),st(0) // P1.Z-P2.Z | E
fst dword ptr [edi+tOMatrix.Up.Z]
fmul st(0),st(0)
faddp st(1),st(0) // E
fsqrt // E / 1
fdivp st(1),st(0) // 1/E
fld dword ptr [edi+tOMatrix.Up.X]
fmul st(0),st(1)
fstp dword ptr [edi+tOMatrix.Up.X]
fld dword ptr [edi+tOMatrix.Up.Y]
fmul st(0),st(1)
fstp dword ptr [edi+tOMatrix.Up.Y]
fld dword ptr [edi+tOMatrix.Up.Z]
fmul st(0),st(1)
fstp dword ptr [edi+tOMatrix.Up.Z]
faddp st(0),st(0)
fld dword ptr [esi+tOMatrix.Forward.Y]
fld dword ptr [edi+tOMatrix.Up.Z]
fmulp st(1),st(0)
fld dword ptr [esi+tOMatrix.Forward.Z]
fld dword ptr [edi+tOMatrix.Up.Y]
fmulp st(1),st(0)
fsubp st(1),st(0)
fld dword ptr [esi+tOMatrix.Forward.Z]
fld dword ptr [edi+tOMatrix.Up.X]
fmulp st(1),st(0)
fld dword ptr [esi+tOMatrix.Forward.X]
fld dword ptr [edi+tOMatrix.Up.Z]
fmulp st(1),st(0)
fsubp st(1),st(0)
fld dword ptr [esi+tOMatrix.Forward.X]
fld dword ptr [edi+tOMatrix.Up.Y]
fmulp st(1),st(0)
fld dword ptr [esi+tOMatrix.Forward.Y]
fld dword ptr [edi+tOMatrix.Up.X]
fmulp st(1),st(0)
fsubp st(1),st(0)
// NMatrix.Left Z | Y | X
fld dword ptr [edi+tOMatrix.Up.Y]
fmul st(0),st(1)
fld dword ptr [edi+tOMatrix.Up.Z]
fmul st(0),st(3)
fsubp st(1),st(0)
// ForX | LZ | LY | LX
fld dword ptr [edi+tOMatrix.Up.Z]
fmul st(0),st(4)
fld dword ptr [edi+tOMatrix.Up.X]
fmul st(0),st(3)
fsubp st(1),st(0)
// ForY | ForX | LZ | LY | LX
fld dword ptr [edi+tOMatrix.Up.X]
fmul st(0),st(4)
fld dword ptr [edi+tOMatrix.Up.Y]
fmul st(0),st(6)
fsubp st(1),st(0)
// ForX | ForY | ForX | LZ | LY | LX
fld dword ptr [Roll]
fcos
fmul st(4),st(0)
fmul st(5),st(0)
fmulp st(6),st(0)
fld dword ptr [Roll]
fsin
fmul st(1),st(0)
fmul st(2),st(0)
fmulp st(3),st(0)
faddp st(3),st(0)
faddp st(3),st(0)
faddp st(3),st(0)
// Z | Y | X
fld st(2)
fmul st(0),st(0)
// X
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -