public void CopyValuesTo(MTX44 m) { for (int i = 0; i < 0x10; i++) { m._array[i] = this[i]; } }
public NsbmdModel.ShapeInfoStruct process3DCommand(byte[] polydata, NsbmdModel.ShapeInfoStruct poly) { if (polydata == null) { return(poly); } else { MemoryStream polyStream = new MemoryStream(); polyStream.Write(polydata, 0, polydata.Length); var reader = new BinaryReader(polyStream); reader.BaseStream.Position = 0; var actualCommand = new NsbmdModel.CommandStruct(); poly.commandList = new List <NsbmdModel.CommandStruct>(); int cur_vertex, idCounter; int blockCounter = 0; float[] vtx_state = { 0.0f, 0.0f, 0.0f }; float[] vtx_trans = { 0.0f, 0.0f, 0.0f }; cur_vertex = gCurrentVertex; // for vertex_mode CurrentMatrix = MatrixStack[stackID].Clone(); while (reader.BaseStream.Position < polyStream.Length) { idCounter = initId(ref poly, polyStream, reader); renderPackedCommand(ref poly, polyStream, reader, ref actualCommand, ref cur_vertex, ref idCounter, ref blockCounter, vtx_state, ref vtx_trans); } return(poly); } }
public Renderer(MapEditor mapEditor) { for (int i = 0; i < MatrixStack.Length; i++) { MatrixStack[i] = new MTX44(); } this.mapEditor = mapEditor; }
public MTX44 Clone() { MTX44 mtx = new MTX44(); for (int i = 0; i < 0x10; i++) { mtx._array[i] = _array[i]; } return(mtx); }
public void Scale(float x, float y, float z) { MTX44 b = new MTX44(); b.LoadIdentity(); b[0] = x; b[5] = y; b[10] = z; MultMatrix(b).CopyValuesTo(this); }
private void reactionMatrixRestore(BinaryReader reader) { /* * MTX_RESTORE - Restore Current Matrix from Stack (W) * Sets C=[N]. The stack pointer S is not used, and is left unchanged. * Parameter Bit0-4: Stack Address (0..30) (31 causes overflow in GXSTAT.15) * Parameter Bit5-31: Not used */ stackID = reader.ReadInt32() & 0x0000001F; CurrentMatrix = MatrixStack[stackID].Clone(); }
public float[] MultVector(float[] v) { MTX44 mtx = this; float[] numArray = new float[3]; float num = v[0]; float num2 = v[1]; float num3 = v[2]; numArray[0] = (((num * mtx[0]) + (num2 * mtx[4])) + (num3 * mtx[8])) + mtx[12]; numArray[1] = (((num * mtx[1]) + (num2 * mtx[5])) + (num3 * mtx[9])) + mtx[13]; numArray[2] = (((num * mtx[2]) + (num2 * mtx[6])) + (num3 * mtx[10])) + mtx[14]; return(numArray); }
public MTX44 MultMatrix(MTX44 b) { MTX44 mtx = new MTX44(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { mtx[(i << 2) + j] = 0f; for (int k = 0; k < 4; k++) { MTX44 mtx4; int num4; (mtx4 = mtx)[num4 = (i << 2) + j] = mtx4[num4] + (mtx[(k << 2) + j] * b[(i << 2) + k]); } } } return(mtx); }