Skip to content

Commit

Permalink
More accurate camera data (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
petfriendamy committed Oct 16, 2024
1 parent 2edea6b commit e6cf116
Show file tree
Hide file tree
Showing 10 changed files with 260 additions and 146 deletions.
1 change: 1 addition & 0 deletions src/HexParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace FF7Scarlet
public static class HexParser
{
public const ushort NULL_OFFSET_16_BIT = 0xFFFF;
public const short NULL_OFFSET_16_BIT_SIGNED = -1;
public const uint NULL_OFFSET_32_BIT = 0xFFFFFFFF;
public static CultureInfo CultureInfo { get; } = new CultureInfo("en-US");

Expand Down
8 changes: 4 additions & 4 deletions src/Point3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
public class Point3D
{
public ushort X { get; }
public ushort Y { get; }
public ushort Z { get; }
public short X { get; }
public short Y { get; }
public short Z { get; }

public Point3D(ushort x, ushort y, ushort z)
public Point3D(short x, short y, short z)
{
X = x;
Y = y;
Expand Down
25 changes: 12 additions & 13 deletions src/SceneEditor/CameraPlacementData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class CameraPlacementData
{
public const int POSITION_COUNT = 3, BLOCK_SIZE = 48;
public const int POSITION_COUNT = 4, BLOCK_SIZE = 48;
private readonly Point3D[]
cameraPositions = new Point3D[POSITION_COUNT],
cameraDirections = new Point3D[POSITION_COUNT];
Expand All @@ -20,29 +20,29 @@ public CameraPlacementData()
{
for (int i = 0; i < POSITION_COUNT; ++i)
{
CameraPositions[i] = new Point3D(HexParser.NULL_OFFSET_16_BIT, HexParser.NULL_OFFSET_16_BIT,
HexParser.NULL_OFFSET_16_BIT);
CameraDirections[i] = new Point3D(HexParser.NULL_OFFSET_16_BIT, HexParser.NULL_OFFSET_16_BIT,
HexParser.NULL_OFFSET_16_BIT);
CameraPositions[i] = new Point3D(HexParser.NULL_OFFSET_16_BIT_SIGNED, HexParser.NULL_OFFSET_16_BIT_SIGNED,
HexParser.NULL_OFFSET_16_BIT_SIGNED);
CameraDirections[i] = new Point3D(HexParser.NULL_OFFSET_16_BIT_SIGNED, HexParser.NULL_OFFSET_16_BIT_SIGNED,
HexParser.NULL_OFFSET_16_BIT_SIGNED);
}
}

public CameraPlacementData(byte[] data)
{
ushort x, y, z;
short x, y, z;
using (var ms = new MemoryStream(data, false))
using (var reader = new BinaryReader(ms))
{
for (int i = 0; i < POSITION_COUNT; ++i)
{
x = reader.ReadUInt16();
y = reader.ReadUInt16();
z = reader.ReadUInt16();
x = reader.ReadInt16();
y = reader.ReadInt16();
z = reader.ReadInt16();
CameraPositions[i] = new Point3D(x, y, z);

x = reader.ReadUInt16();
y = reader.ReadUInt16();
z = reader.ReadUInt16();
x = reader.ReadInt16();
y = reader.ReadInt16();
z = reader.ReadInt16();
CameraDirections[i] = new Point3D(x, y, z);
}
}
Expand All @@ -64,7 +64,6 @@ public byte[] GetRawData()
writer.Write(CameraDirections[i].Y);
writer.Write(CameraDirections[i].Z);
}
writer.Write(HexParser.GetNullBlock(12)); //padding
}
return data;
}
Expand Down
239 changes: 138 additions & 101 deletions src/SceneEditor/Controls/CameraPositionControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e6cf116

Please sign in to comment.