Skip to content
Open
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
10 changes: 10 additions & 0 deletions LanternExtractor/EQ/Wld/DataTypes/ParticleMovement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace LanternExtractor.EQ.Wld.DataTypes
{
public enum ParticleMovement
{
Sphere = 1,
Plane = 2,
Stream = 3,
None = 4
}
}
58 changes: 52 additions & 6 deletions LanternExtractor/EQ/Wld/Exporters/ParticleSystemWriter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LanternExtractor.EQ.Wld.Fragments;
using LanternExtractor.EQ.Wld.Helpers;
using System.IO;
using System.Linq;
using LanternExtractor.EQ.Wld.Fragments;

namespace LanternExtractor.EQ.Wld.Exporters
{
Expand All @@ -8,16 +9,61 @@ public class ParticleSystemWriter : TextAssetWriter
public ParticleSystemWriter()
{
_export.AppendLine(LanternStrings.ExportHeaderTitle + "Particle System");
_export.AppendLine(LanternStrings.ExportHeaderFormat +
"Sprite, SpriteAnimationDelayMs, Movement, Flags, SimultaneousParticles, SpawnRadius, SpawnAngle, SpawnLifespan, SpawnVelocity," +
"SpawnNormalX, SpawnNormalY, SpawnNormalZ, SpawnRate, SpawnScale, ColorR, ColorG, ColorB, ColorX");
}

public override void AddFragmentData(WldFragment data)
{
if (!(data is ParticleCloud))
ParticleCloud particle = data as ParticleCloud;

if (particle == null)
{
return;
}

_export.AppendLine(FragmentNameCleaner.CleanName(data));
_export.Append(GetSpriteString(particle.ParticleSprite.BitmapInfoReference.BitmapInfo));
_export.Append(',');
_export.Append(particle.ParticleSprite.BitmapInfoReference.BitmapInfo.AnimationDelayMs);
_export.Append(',');
_export.Append(particle.ParticleMovement.ToString());
_export.Append(',');
_export.Append(particle.Flags.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SimultaneousParticles.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnRadius.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnAngle.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnLifespan.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnVelocity.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnNormal.x.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnNormal.y.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnNormal.z.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnRate.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.SpawnScale.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.Color.R.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.Color.G.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.Color.B.ToString(_numberFormat));
_export.Append(',');
_export.Append(particle.Color.A.ToString(_numberFormat));
}

private string GetSpriteString(BitmapInfo bitmapInfo)
{
var filenames = bitmapInfo.BitmapNames.Select(b => Path.ChangeExtension(b.Filename, null));
return string.Join(':', filenames);
}
}
}
}
62 changes: 38 additions & 24 deletions LanternExtractor/EQ/Wld/Fragments/ParticleCloud.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,64 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using GlmSharp;
using LanternExtractor.EQ.Wld.DataTypes;
using LanternExtractor.Infrastructure.Logger;

namespace LanternExtractor.EQ.Wld.Fragments
{
/// <summary>
/// ParticleCloud (0x34)
/// Internal name: None
/// Internal name: _PCD
/// Defines a particle system. Can be referenced from a skeleton bone.
/// </summary>
public class ParticleCloud : WldFragment
{
private ParticleSprite _particleSprite;
public ParticleMovement ParticleMovement { get; private set; }
public int Flags { get; private set; }
public int SimultaneousParticles { get; private set; }
public float SpawnRadius { get; private set; }
public float SpawnAngle { get; private set; }
public int SpawnLifespan { get; private set; }
public float SpawnVelocity { get; private set; }
public vec3 SpawnNormal { get; private set; }
public int SpawnRate { get; private set; }
public float SpawnScale { get; private set; }
public Color Color { get; private set; }
public ParticleSprite ParticleSprite;

public override void Initialize(int index, int size, byte[] data, List<WldFragment> fragments,
Dictionary<int, string> stringHash,
bool isNewWldFormat, ILogger logger)
{
base.Initialize(index, size, data, fragments, stringHash, isNewWldFormat, logger);
Name = stringHash[-Reader.ReadInt32()];

//File.WriteAllBytes("ParticleClouds/" + Name, data);

int flags = Reader.ReadInt32(); // always 4
int value_04 = Reader.ReadInt32(); // always 4
int value_08 = Reader.ReadInt32(); // always 3
int value_12 = Reader.ReadInt32(); // Values are 1, 3, or 4
byte value_16 = Reader.ReadByte();
byte value_17 = Reader.ReadByte();
byte value_18 = Reader.ReadByte();
byte value_19 = Reader.ReadByte();
int value_20 = Reader.ReadInt32(); // 200, 30, particle count?
ParticleMovement = (ParticleMovement)Reader.ReadInt32(); // Values are 1, 3, or 4
Flags = Reader.ReadInt32();
SimultaneousParticles = Reader.ReadInt32(); // 200, 30, particle count?
int value_24 = Reader.ReadInt32(); // always 0
int value_28 = Reader.ReadInt32(); // always 0
int value_32 = Reader.ReadInt32(); // always 0
int value_36 = Reader.ReadInt32(); // always 0
int value_40 = Reader.ReadInt32(); // always 0
float value_44 = Reader.ReadSingle(); // confirmed float
float value_48 = Reader.ReadSingle(); // looks like a float
int value_52 = Reader.ReadInt32(); // looks like an int. numbers like 1000, 100, 750, 500, 1600, 2500.
float value_56 = Reader.ReadSingle(); // looks like a float. low numbers. 4, 5, 8, 10, 0
float value_60 = Reader.ReadSingle(); // float 0 or 1
float value_64 = Reader.ReadSingle(); // float 0 or -1
float value_68 = Reader.ReadSingle(); // float 0 or -1
int value_72 = Reader.ReadInt32(); // probably int 13, 15, 20, 600, 83? or bytes
float value_76 = Reader.ReadSingle(); // confirmed float 0.4, 0.5, 1.5, 0.1
float value_80 = Reader.ReadSingle(); // float 0.4, 1.9
_particleSprite = fragments[Reader.ReadInt32() - 1] as ParticleSprite;
SpawnRadius = Reader.ReadSingle(); // confirmed float
SpawnAngle = Reader.ReadSingle(); // looks like a float
SpawnLifespan = Reader.ReadInt32(); // looks like an int. numbers like 1000, 100, 750, 500, 1600, 2500.
SpawnVelocity = Reader.ReadSingle(); // looks like a float. low numbers. 4, 5, 8, 10, 0
SpawnNormal = new vec3(Reader.ReadSingle(), Reader.ReadSingle(), Reader.ReadSingle());
SpawnRate = Reader.ReadInt32(); // probably int 13, 15, 20, 600, 83? or bytes
SpawnScale = Reader.ReadSingle(); // confirmed float 0.4, 0.5, 1.5, 0.1
var colorBytes = BitConverter.GetBytes(Reader.ReadInt32());
Color = new Color
(
colorBytes[2],
colorBytes[1],
colorBytes[0],
colorBytes[3]
);
ParticleSprite = fragments[Reader.ReadInt32() - 1] as ParticleSprite;
}
}
}
}
8 changes: 4 additions & 4 deletions LanternExtractor/EQ/Wld/Fragments/ParticleSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace LanternExtractor.EQ.Wld.Fragments
/// </summary>
public class ParticleSprite : WldFragment
{
private BitmapInfoReference _bitmapReference;
public BitmapInfoReference BitmapInfoReference { get; private set; }

public override void Initialize(int index, int size, byte[] data, List<WldFragment> fragments, Dictionary<int, string> stringHash,
bool isNewWldFormat, ILogger logger)
{
Expand All @@ -20,7 +20,7 @@ public override void Initialize(int index, int size, byte[] data, List<WldFragme
int value_04 = Reader.ReadInt32(); // flags? always 0
int fragmentRef = Reader.ReadInt32();
int value_12 = Reader.ReadInt32(); // always the same value. unlikely a float, or bytes. Not color.
_bitmapReference = fragments[fragmentRef - 1] as BitmapInfoReference;
BitmapInfoReference = fragments[fragmentRef - 1] as BitmapInfoReference;
}
}
}
}