mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-23 00:31:47 -05:00
Store other scenegraph info needed to render full scenes
This commit is contained in:
parent
8fd0c1d0e0
commit
9fb3468998
3 changed files with 30 additions and 16 deletions
|
@ -13,8 +13,10 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph.Block
|
|||
|
||||
public ObjectReference[] References { get; }
|
||||
|
||||
public CompositionTreeNodeBlock(PersistTypeInfo typeInfo, ObjectReference[] references) =>
|
||||
(TypeInfo, References) = (typeInfo, references);
|
||||
public ObjectGraphNodeBlock Graph { get; }
|
||||
|
||||
public CompositionTreeNodeBlock(PersistTypeInfo typeInfo, ObjectReference[] references, ObjectGraphNodeBlock graph) =>
|
||||
(TypeInfo, References, Graph) = (typeInfo, references, graph);
|
||||
|
||||
public static CompositionTreeNodeBlock Deserialize(IoBuffer reader)
|
||||
{
|
||||
|
@ -27,7 +29,7 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph.Block
|
|||
references[i] = ObjectReference.Deserialize(reader);
|
||||
}
|
||||
|
||||
return new CompositionTreeNodeBlock(typeInfo, references);
|
||||
return new CompositionTreeNodeBlock(typeInfo, references, graph);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using OpenTS2.Files.Utils;
|
||||
using UnityEngine;
|
||||
using OpenTS2.Files.Utils;
|
||||
|
||||
namespace OpenTS2.Files.Formats.DBPF.Scenegraph.Block
|
||||
{
|
||||
|
@ -15,8 +13,21 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph.Block
|
|||
|
||||
public string ResourceName { get; }
|
||||
|
||||
public ResourceNodeBlock(PersistTypeInfo blockTypeInfo, string resourceName) : base(blockTypeInfo) =>
|
||||
(ResourceName) = (resourceName);
|
||||
/// <summary>
|
||||
/// Where this resource is stored, if the reference is missing (index of -1) then the current ResourceCollection
|
||||
/// has the resource. If this is set, it could be an external reference.
|
||||
/// </summary>
|
||||
public ObjectReference ResourceLocation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// May be null and graph set depending on the resource node.
|
||||
/// </summary>
|
||||
public CompositionTreeNodeBlock Tree { get; }
|
||||
|
||||
public ObjectGraphNodeBlock Graph { get; }
|
||||
|
||||
public ResourceNodeBlock(PersistTypeInfo blockTypeInfo, string resourceName, ObjectReference resourceLocation, CompositionTreeNodeBlock tree, ObjectGraphNodeBlock graph) : base(blockTypeInfo) =>
|
||||
(ResourceName, ResourceLocation, Tree, Graph) = (resourceName, resourceLocation, tree, graph);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
@ -31,23 +42,26 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph.Block
|
|||
var hasTreeNode = reader.ReadByte() != 0;
|
||||
|
||||
string resourceName;
|
||||
CompositionTreeNodeBlock tree = null;
|
||||
ObjectGraphNodeBlock graph = null;
|
||||
if (hasTreeNode)
|
||||
{
|
||||
var resource = ScenegraphResource.Deserialize(reader);
|
||||
var compositionTree = CompositionTreeNodeBlock.Deserialize(reader);
|
||||
|
||||
resourceName = resource.ResourceName;
|
||||
tree = compositionTree;
|
||||
}
|
||||
else
|
||||
{
|
||||
var graph = ObjectGraphNodeBlock.Deserialize(reader);
|
||||
graph = ObjectGraphNodeBlock.Deserialize(reader);
|
||||
resourceName = graph.Tag;
|
||||
}
|
||||
|
||||
var reference = ObjectReference.Deserialize(reader);
|
||||
var resourceLocation = ObjectReference.Deserialize(reader);
|
||||
var skinType = reader.ReadUInt32();
|
||||
|
||||
return new ResourceNodeBlock(blockTypeInfo, resourceName);
|
||||
return new ResourceNodeBlock(blockTypeInfo, resourceName, resourceLocation, tree, graph);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph
|
|||
public struct ObjectReference
|
||||
{
|
||||
public int Index;
|
||||
public bool IsInternalReference;
|
||||
|
||||
public static ObjectReference Deserialize(IoBuffer reader)
|
||||
{
|
||||
|
@ -17,12 +18,9 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph
|
|||
return new ObjectReference() { Index = -1 };
|
||||
}
|
||||
|
||||
// This internally changes the reference between cIGZPersistSerializableReferent when the value is 0 or
|
||||
// cIGZPersistResource2 when the value is anything else. We don't care about that yet but we might in the
|
||||
// future.
|
||||
var referenceType = reader.ReadByte();
|
||||
var isInternal = reader.ReadByte() == 0;
|
||||
var index = reader.ReadInt32();
|
||||
return new ObjectReference() { Index = index };
|
||||
return new ObjectReference() { Index = index, IsInternalReference = isInternal };
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue