Preparation for release. Comments, fixes, README

This commit is contained in:
2025-03-17 14:32:54 +01:00
parent 8a6679dff6
commit 7b127b345b
13 changed files with 839 additions and 476 deletions

View File

@@ -1,41 +1,50 @@
using UnityEngine;
namespace PSXSplash.RuntimeCode
namespace SplashEdit.RuntimeCode
{
public class PSXObjectExporter : MonoBehaviour
{
public PSXBPP BitDepth;
public bool MeshIsStatic = true;
public PSXBPP BitDepth = PSXBPP.TEX_8BIT; // Defines the bit depth of the texture (e.g., 4BPP, 8BPP)
public bool MeshIsStatic = true; // Determines if the mesh is static, affecting how it's processed. Non-static meshes don't export correctly as of now.
[HideInInspector]
public PSXTexture2D Texture;
public PSXTexture2D Texture; // Stores the converted PlayStation-style texture
[HideInInspector]
public PSXMesh Mesh;
public PSXMesh Mesh; // Stores the converted PlayStation-style mesh
/// <summary>
/// Converts the object's material texture into a PlayStation-compatible texture.
/// </summary>
public void CreatePSXTexture2D()
{
Renderer renderer = GetComponent<Renderer>();
if (renderer != null && renderer.sharedMaterial != null && renderer.sharedMaterial.mainTexture is Texture2D texture)
{
Texture = PSXTexture2D.CreateFromTexture2D(texture, BitDepth);
Texture.OriginalTexture = texture;
Texture.OriginalTexture = texture; // Stores reference to the original texture
}
}
/// <summary>
/// Converts the object's mesh into a PlayStation-compatible mesh.
/// </summary>
public void CreatePSXMesh()
{
MeshFilter meshFilter = gameObject.GetComponent<MeshFilter>();
if (meshFilter != null)
{
if(MeshIsStatic) {
if (MeshIsStatic)
{
// Static meshes take object transformation into account
Mesh = PSXMesh.CreateFromUnityMesh(meshFilter.sharedMesh, Texture.Width, Texture.Height, transform);
}
else {
else
{
// Dynamic meshes do not consider object transformation
Mesh = PSXMesh.CreateFromUnityMesh(meshFilter.sharedMesh, Texture.Width, Texture.Height);
}
}
}
}
}