Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/010 Templates/pssg.bt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct NODE {
case "SHADERINPUT":
case "TEXTUREIMAGEBLOCKDATA":
case "TRANSFORM":
case "SHADERPROGRAMCODEBLOCK":
char data[end - FTell()] <bgcolor=cRed>;
break;
default:
Expand Down
18 changes: 18 additions & 0 deletions src/EgoEngineLibrary/Formats/Pssg/RenderDataSourceReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public Vector3 GetNormal(uint index)
return ReadVector3(data);
case "half4": // just read Vec3, pretty sure 4th item is just 1.0
return ReadVectorHalf3(data);
case "hend3n":
return ReadHend3N(data);
default:
throw new NotImplementedException($"Support for {attribute.Name} data type {attribute.DataType} is not implemented.");
}
Expand Down Expand Up @@ -410,5 +412,21 @@ static unsafe Half Int16BitsToHalf(short value)
{
return *(Half*)&value;
}

private static Vector3 ReadHend3N(ReadOnlySpan<byte> data)
{
var i = BinaryPrimitives.ReadUInt32BigEndian(data);
var y = i >> 11;
var z = i >> 22;

// use shift to sign extend
var vec = new Vector3
{
X = (((int)(i & 0x7FF)) << 21 >> 21) / (float)0x3FF,
Y = (((int)(y & 0x7FF)) << 21 >> 21) / (float)0x3FF,
Z = (((int)(z & 0x3FF)) << 22 >> 22) / (float)0x1FF
};
return vec;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PssgShaderProgramCode : PssgElement
new PssgSchemaAttribute("codeType", PssgAttributeType.String),
new PssgSchemaAttribute("profileType", PssgAttributeType.Int),
new PssgSchemaAttribute("profile", PssgAttributeType.Int),
new PssgSchemaAttribute("codeEntry", PssgAttributeType.Int),
new PssgSchemaAttribute("codeEntry", PssgAttributeType.String),
new PssgSchemaAttribute("parameterCount", PssgAttributeType.Int),
new PssgSchemaAttribute("streamCount", PssgAttributeType.Int),
}
Expand Down Expand Up @@ -41,9 +41,9 @@ public uint Profile
set => AddAttribute(Schema.Attributes[3].Name, value);
}

public byte CodeEntry
public string CodeEntry
{
get => GetAttributeValue<byte>(Schema.Attributes[4].Name);
get => GetAttributeValue<string>(Schema.Attributes[4].Name);
set => AddAttribute(Schema.Attributes[4].Name, value);
}

Expand Down
6 changes: 2 additions & 4 deletions src/EgoEngineLibrary/Graphics/Pssg/PssgBinaryReader.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System.Numerics;
using System.Text;
using EgoEngineLibrary.Collections;
using EgoEngineLibrary.Conversion;
using EgoEngineLibrary.IO;

namespace EgoEngineLibrary.Graphics.Pssg
{
public class PssgBinaryReader : EndianBinaryReader
{
public OrderedSet<PssgSchemaElement> ElementTable { get; set; }
public OrderedSet<PssgSchemaAttribute> AttributeTable { get; set; }
public List<PssgSchemaElement> ElementTable { get; set; }
public List<PssgSchemaAttribute> AttributeTable { get; set; }
internal bool UseDataElementCheck { get; set; }

public PssgBinaryReader(EndianBitConverter bitConvertor, Stream stream, bool leaveOpen)
Expand Down
4 changes: 2 additions & 2 deletions src/EgoEngineLibrary/Graphics/Pssg/PssgFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public static PssgFile ReadPssg(Stream fileStream, PssgFileType fileType)
}
}

file._elementTable = reader.ElementTable;
file._attributeTable = reader.AttributeTable;
file._elementTable = new OrderedSet<PssgSchemaElement>(reader.ElementTable);
file._attributeTable = new OrderedSet<PssgSchemaAttribute>(reader.AttributeTable);
}

return file;
Expand Down
7 changes: 7 additions & 0 deletions src/EgoPssgEditor/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
<Application.Styles>
<FluentTheme DensityStyle="Compact" />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
<Style Selector="DataGridCell">
<Setter Property="FontSize" Value="14"></Setter>
<Setter Property="MinHeight" Value="26"></Setter>
</Style>
<Style Selector="TabItem">
<Setter Property="FontSize" Value="20"></Setter>
</Style>
<!-- See https://github.com/AvaloniaUI/Avalonia/issues/20530 -->
<Style Selector="TreeViewItem /template/ StackPanel > Border > Grid">
<Setter Property="HorizontalAlignment" Value="Left"></Setter>
Expand Down
6 changes: 3 additions & 3 deletions src/EgoPssgEditor/EgoPssgEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<AssemblyName>Ego PSSG Editor</AssemblyName>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<PublishTrimmed>true</PublishTrimmed>
<PublishSelfContained>true</PublishSelfContained>
</PropertyGroup>

<PropertyGroup>
<ApplicationIcon>Assets\Ryder25.ico</ApplicationIcon>
<Copyright>Copyright © Petar Tasev 2010 - 2024</Copyright>
<Authors>Petar Tasev</Authors>
<Company>Petar Tasev</Company>
<Description>Opens Ego Engine pssg files</Description>
<Version>12.1.1</Version>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EgoPssgEditor/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<DataGrid x:Name="attributesDataGrid"
ItemsSource="{Binding ElementName=tvMain, Path=((vm:PssgElementViewModel)SelectedItem).Attributes}"
AutoGenerateColumns="False" CanUserSortColumns="False"
HeadersVisibility="All" RowHeight="20" FontSize="14"
HeadersVisibility="All"
CellPointerPressed="AttributesDataGrid_OnCellPointerPressed">
<DataGrid.Styles>
<Style Selector="DataGridRow" x:DataType="vm:PssgAttributeViewModel">
Expand Down