public void UpdateFromMarioTab() { // Get Mario position and rotation float x = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.XOffset); float y = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YOffset); float z = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.ZOffset); ushort marioFacing = Config.Stream.GetUInt16(MarioConfig.StructAddress + MarioConfig.FacingYawOffset); float rot = (float)MoreMath.AngleUnitsToDegrees(marioFacing); // Update Mario map object MarioMapObject.X = x; MarioMapObject.Y = y; MarioMapObject.Z = z; MarioMapObject.Rotation = rot; MarioMapObject.Show = true; // Get holp position float holpX = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.HolpXOffset); float holpY = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.HolpYOffset); float holpZ = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.HolpZOffset); // Update holp map object position HolpMapObject.X = holpX; HolpMapObject.Y = holpY; HolpMapObject.Z = holpZ; HolpMapObject.Show = true; // Update camera position and rotation float cameraX = Config.Stream.GetSingle(CameraConfig.StructAddress + CameraConfig.XOffset); float cameraY = Config.Stream.GetSingle(CameraConfig.StructAddress + CameraConfig.YOffset); float cameraZ = Config.Stream.GetSingle(CameraConfig.StructAddress + CameraConfig.ZOffset); ushort cameraYaw = Config.Stream.GetUInt16(CameraConfig.StructAddress + CameraConfig.FacingYawOffset); float cameraRot = (float)MoreMath.AngleUnitsToDegrees(cameraYaw); // Update floor triangle UInt32 floorTriangle = Config.Stream.GetUInt32(MarioConfig.StructAddress + MarioConfig.FloorTriangleOffset); if (floorTriangle != 0x00) { Int16 x1 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.X1); Int16 y1 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.Y1); Int16 z1 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.Z1); Int16 x2 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.X2); Int16 y2 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.Y2); Int16 z2 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.Z2); Int16 x3 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.X3); Int16 y3 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.Y3); Int16 z3 = Config.Stream.GetInt16(floorTriangle + TriangleOffsetsConfig.Z3); FloorTriangleMapObject.X1 = x1; FloorTriangleMapObject.Z1 = z1; FloorTriangleMapObject.X2 = x2; FloorTriangleMapObject.Z2 = z2; FloorTriangleMapObject.X3 = x3; FloorTriangleMapObject.Z3 = z3; FloorTriangleMapObject.Y = (y1 + y2 + y3) / 3; } FloorTriangleMapObject.Show = (floorTriangle != 0x00); // Update ceiling triangle UInt32 ceilingTriangle = Config.Stream.GetUInt32(MarioConfig.StructAddress + MarioConfig.CeilingTriangleOffset); if (ceilingTriangle != 0x00) { Int16 x1 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.X1); Int16 y1 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.Y1); Int16 z1 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.Z1); Int16 x2 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.X2); Int16 y2 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.Y2); Int16 z2 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.Z2); Int16 x3 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.X3); Int16 y3 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.Y3); Int16 z3 = Config.Stream.GetInt16(ceilingTriangle + TriangleOffsetsConfig.Z3); CeilingTriangleMapObject.X1 = x1; CeilingTriangleMapObject.Z1 = z1; CeilingTriangleMapObject.X2 = x2; CeilingTriangleMapObject.Z2 = z2; CeilingTriangleMapObject.X3 = x3; CeilingTriangleMapObject.Z3 = z3; CeilingTriangleMapObject.Y = (y1 + y2 + y3) / 3; } CeilingTriangleMapObject.Show = (ceilingTriangle != 0x00); //List<TriangleDataModel> cogFloorTris = TriangleUtilities.GetObjectTrianglesForObject(0x80341E28) List <TriangleDataModel> cogFloorTris = TriangleUtilities.GetTrianglesInRange(0x8016DE30, 20) .FindAll(tri => tri.Classification == TriangleClassification.Floor); for (int i = 0; i < _cogFloorTris.Count; i++) { if (i < cogFloorTris.Count) { _cogFloorTris[i].Update(cogFloorTris[i]); _cogFloorTris[i].Show = true; } else { _cogFloorTris[i].Show = false; } } //List<TriangleDataModel> cog2FloorTris = TriangleUtilities.GetObjectTrianglesForObject(0x80342088) List <TriangleDataModel> cog2FloorTris = TriangleUtilities.GetTrianglesInRange(0x8016E1F0, 20) .FindAll(tri => tri.Classification == TriangleClassification.Floor); for (int i = 0; i < _cog2FloorTris.Count; i++) { if (i < cog2FloorTris.Count) { _cog2FloorTris[i].Update(cog2FloorTris[i]); _cog2FloorTris[i].Show = true; } else { _cog2FloorTris[i].Show = false; } } List <TriangleShape> cogWallTris = TriangleUtilities.GetWallTriangleHitboxComponents( TriangleUtilities.GetObjectTrianglesForObject(0x80341E28) .FindAll(tri => tri.Classification == TriangleClassification.Wall)); for (int i = 0; i < _cogWallTris.Count; i++) { if (i < cogWallTris.Count) { _cogWallTris[i].Update(cogWallTris[i]); _cogWallTris[i].Show = true; } else { _cogWallTris[i].Show = false; } } for (int numSides = SHAPE_MIN_SIDES; numSides <= SHAPE_MAX_SIDSE; numSides++) { (List <TriangleShape> floors, List <TriangleShape> walls) = GetTriShapes(numSides); int index = numSides - SHAPE_MIN_SIDES; List <TriangleMap2Object> floorTris = _triObjectFloors[index]; List <TriangleMap2Object> wallTris = _triObjectWalls[index]; for (int i = 0; i < floorTris.Count; i++) { floorTris[i].Update(floors[i]); floorTris[i].Show = true; } for (int i = 0; i < wallTris.Count; i++) { wallTris[i].Update(walls[i]); wallTris[i].Show = true; } } // Update intended next position map object position float normY = floorTriangle == 0 ? 1 : Config.Stream.GetSingle(floorTriangle + TriangleOffsetsConfig.NormY); float hSpeed = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.HSpeedOffset); float floorY = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.FloorYOffset); bool aboveFloor = y > floorY + 0.001; double multiplier = aboveFloor ? 1 : normY; double defactoSpeed = hSpeed * multiplier; double defactoSpeedQStep = defactoSpeed * 0.25; ushort marioAngle = Config.Stream.GetUInt16(MarioConfig.StructAddress + MarioConfig.FacingYawOffset); ushort marioAngleTruncated = MoreMath.NormalizeAngleTruncated(marioAngle); (double xDist, double zDist) = MoreMath.GetComponentsFromVector(defactoSpeedQStep, marioAngleTruncated); double intendedNextPositionX = MoreMath.MaybeNegativeModulus(x + xDist, 65536); double intendedNextPositionZ = MoreMath.MaybeNegativeModulus(z + zDist, 65536); IntendedNextPositionMapObject.X = (float)intendedNextPositionX; IntendedNextPositionMapObject.Z = (float)intendedNextPositionZ; bool marioStationary = x == intendedNextPositionX && z == intendedNextPositionZ; double angleToIntendedNextPosition = MoreMath.AngleTo_AngleUnits(x, z, intendedNextPositionX, intendedNextPositionZ); IntendedNextPositionMapObject.Rotation = marioStationary ? (float)MoreMath.AngleUnitsToDegrees(marioAngle) : (float)MoreMath.AngleUnitsToDegrees(angleToIntendedNextPosition); IntendedNextPositionMapObject.Rotation = rot; // Update camera map object position CameraMapObject.X = cameraX; CameraMapObject.Y = cameraY; CameraMapObject.Z = cameraZ; CameraMapObject.Rotation = cameraRot; }