mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-22 16:21:47 -05:00
Use emitter shape from particle system
This commit is contained in:
parent
4e53fafb0a
commit
756ecc9cb1
2 changed files with 28 additions and 1 deletions
|
@ -17,5 +17,28 @@ namespace OpenTS2.Content.DBPF.Effects.Types
|
|||
return new BoundingBox(
|
||||
Vector3Serializer.Deserialize(reader), Vector3Serializer.Deserialize(reader));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// These bounding boxes usually represent cuboids, ellipsoids or toruses. They are represented by the two
|
||||
/// corners of the shape.
|
||||
///
|
||||
/// In Unity land shapes are usually represented by their center, scale and rotation from a unit cube, sphere.
|
||||
/// This function handles converting corners to the Unity style.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The center position of the box, its rotation and scale as a triple in that order.
|
||||
/// </returns>
|
||||
public readonly (Vector3, Quaternion, Vector3) GetCenterRotationAndScale()
|
||||
{
|
||||
var center = (LowerCorner + UpperCorner) / 2;
|
||||
|
||||
// TODO: figure out how to calculate rotation.
|
||||
var rotation = Quaternion.identity;
|
||||
|
||||
// TODO: this might be wrong.
|
||||
var scale = (UpperCorner - LowerCorner);
|
||||
|
||||
return (center, rotation, scale);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -77,8 +77,12 @@ namespace OpenTS2.Scenes
|
|||
var emission = system.emission;
|
||||
emission.rateOverTime = effect.Emission.RateCurve.ToUnityCurve();
|
||||
|
||||
// Set the emitter shape and drection.
|
||||
// Set the emitter shape and direction.
|
||||
var shape = system.shape;
|
||||
var (emitterPos, emitterRotation, emitterScale) = effect.Emission.EmitVolume.GetCenterRotationAndScale();
|
||||
shape.position = emitterPos;
|
||||
shape.rotation = emitterRotation.eulerAngles;
|
||||
shape.scale = emitterScale;
|
||||
if (effect.Emission.EmitTorusWidth > 0)
|
||||
{
|
||||
shape.shapeType = ParticleSystemShapeType.Donut;
|
||||
|
|
Loading…
Reference in a new issue