-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Internal Skin Param (#52)
* Add support for Internal Skin Param * Simplify casting of block type * Write osage block external name to skp instead of internal name * Set internal skp name to ExternalName of osgBlock on creation * Fix mistake regarding Tail of OsageInternalCollisionParameter
- Loading branch information
1 parent
3202172
commit f0e5ebc
Showing
5 changed files
with
453 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
MikuMikuLibrary/Objects/Extra/Parameters/OsageInternalCollisionParameter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using MikuMikuLibrary.IO.Common; | ||
|
||
namespace MikuMikuLibrary.Objects.Extra.Parameters; | ||
|
||
public enum OsageInternalCollisionType : int | ||
{ | ||
End = 0, | ||
Sphere = 1, | ||
Cylinder = 2, | ||
Plane = 3, | ||
Ellipse = 4 | ||
} | ||
|
||
public class OsageInternalCollisionParameter | ||
{ | ||
public OsageInternalCollisionType CollisionType { get; set; } | ||
public uint Head { get; set; } | ||
public uint Tail { get; set; } | ||
public float CollisionRadius { get; set; } | ||
public Vector3 HeadPosition { get; set; } | ||
public Vector3 TailPosition { get; set; } | ||
|
||
internal void Read(EndianBinaryReader reader) | ||
{ | ||
CollisionType = (OsageInternalCollisionType)reader.ReadInt32(); | ||
Head = reader.ReadUInt32(); | ||
Tail = reader.ReadUInt32(); | ||
CollisionRadius = reader.ReadSingle(); | ||
HeadPosition = reader.ReadVector3(); | ||
TailPosition = reader.ReadVector3(); | ||
} | ||
|
||
internal void Write(EndianBinaryWriter writer) | ||
{ | ||
writer.Write((int)CollisionType); | ||
writer.Write(Head); | ||
writer.Write(Tail); | ||
writer.Write(CollisionRadius); | ||
writer.Write(HeadPosition); | ||
writer.Write(TailPosition); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
MikuMikuLibrary/Objects/Extra/Parameters/OsageInternalSkinParameter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using MikuMikuLibrary.IO; | ||
using MikuMikuLibrary.IO.Common; | ||
using MikuMikuLibrary.Parameters; | ||
|
||
namespace MikuMikuLibrary.Objects.Extra.Parameters; | ||
|
||
|
||
[TypeConverter(typeof(ExpandableObjectConverter))] | ||
public class OsageInternalSkinParameter | ||
{ | ||
public string Name { get; set; } | ||
public float Force { get; set; } | ||
public float ForceGain { get; set; } | ||
public float AirResistance { get; set; } | ||
public float RotationY { get; set; } | ||
public float RotationZ { get; set; } | ||
public float HingeY { get; set; } | ||
public float HingeZ { get; set; } | ||
public float CollisionRadius { get; set; } | ||
public float Friction { get; set; } | ||
public float WindAffection { get; set; } | ||
public List<OsageInternalCollisionParameter> Collisions { get; } | ||
|
||
internal void Read(EndianBinaryReader reader) | ||
{ | ||
long start = reader.Position; | ||
reader.SkipNulls(4); // Truthfully, i don't know if this is inertial_cancel or just a reserved field. it seems to always be 0 though so i won't read it. | ||
// Besides, if i did read and write it, and someone wrote it as anything but 0, then it would from that point on be falsely read as FT, which wouldn't be good. | ||
|
||
Force = reader.ReadSingle(); | ||
ForceGain = reader.ReadSingle(); | ||
AirResistance = reader.ReadSingle(); | ||
RotationY = reader.ReadSingle(); | ||
RotationZ = reader.ReadSingle(); | ||
HingeY = reader.ReadSingle(); | ||
HingeZ = reader.ReadSingle(); | ||
Name = reader.ReadStringOffset(StringBinaryFormat.NullTerminated); | ||
|
||
reader.ReadOffset(() => | ||
{ | ||
while (true) | ||
{ | ||
OsageInternalCollisionParameter collisionParameter = new OsageInternalCollisionParameter(); | ||
collisionParameter.Read(reader); | ||
if (collisionParameter.CollisionType == OsageInternalCollisionType.End) | ||
{ | ||
break; | ||
} | ||
Collisions.Add(collisionParameter); | ||
|
||
}; | ||
}); | ||
|
||
CollisionRadius = reader.ReadSingle(); | ||
Friction = reader.ReadSingle(); | ||
WindAffection = reader.ReadSingle(); | ||
} | ||
|
||
internal void Write(EndianBinaryWriter writer) | ||
{ | ||
writer.WriteNulls(4); | ||
writer.Write(Force); | ||
writer.Write(ForceGain); | ||
writer.Write(AirResistance); | ||
writer.Write(RotationY); | ||
writer.Write(RotationZ); | ||
writer.Write(HingeY); | ||
writer.Write(HingeZ); | ||
writer.WriteStringOffset(Name); | ||
writer.WriteOffset(16, AlignmentMode.Left, () => | ||
{ | ||
foreach (var coll in Collisions) | ||
{ | ||
coll.Write(writer); | ||
} | ||
|
||
new OsageInternalCollisionParameter() { CollisionType = OsageInternalCollisionType.End }.Write(writer); // please suggest a better way to handle this | ||
}); | ||
writer.Write(CollisionRadius); | ||
writer.Write(Friction); | ||
writer.Write(WindAffection); | ||
} | ||
|
||
public OsageInternalSkinParameter() | ||
{ | ||
Collisions = new List<OsageInternalCollisionParameter>(); | ||
} | ||
} |
Oops, something went wrong.