Skip to content

Commit

Permalink
Merge branch 'release/0.10.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
paralleltree committed Oct 22, 2019
2 parents caaf1a1 + 432b578 commit a81e48e
Show file tree
Hide file tree
Showing 80 changed files with 4,294 additions and 344 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
#*.RTF diff=astextplain
*.vmd filter=lfs diff=lfs merge=lfs -text
*.json filter=lfs diff=lfs merge=lfs -text
*.pmm filter=lfs diff=lfs merge=lfs -text
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ Or download an archive from [Releases](https://github.com/paralleltree/Scallion/

## Usage

This library supports only MMD Motion File for now.

```csharp
// using Scallion.DomainModels;
var motion = new Motion().Load(@"path\to\motion.vmd");
// motion.Bones...
// motion.Morphs...
var project = new Project().Load(@"path\to\project.pmm");
// project.Camera...
// project.Models...
```

## Contributing
Expand Down
74 changes: 74 additions & 0 deletions Scallion.Tests/ConverterTests/Project/CameraTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using NUnit.Framework;
using System.Numerics;
using Scallion.Tests.Internal;

namespace Scallion.Tests.ConverterTests.Project
{
internal class CameraTest
{
private object[] cameraViewPositionTestSource = new[]
{
new object[] { new Vector3(0, 10, 5), 45, new Vector3(90, 0, 0), new Vector3(0, 55, 5), new Vector3(0, 5, -55) },
new object[] { new Vector3(5, 10, -5), 45, new Vector3(45, 135, -90), new Vector3(27.5f, 41.8198f, 17.5f), new Vector3(7.07f, 7.07f, -52.07f) },
new object[] { new Vector3(5, 5, 5), 25, new Vector3(45, 90, 135), new Vector3(22.677f, 22.677f, 5), new Vector3(-3.5355f, 3.5355f, -32.071f) },
new object[] { new Vector3(5, 5, 10), -25, new Vector3(30, 90, 135), new Vector3(-16.65f, -7.5f, 10), new Vector3(-8.365f, 5.7769f, 18.1698f) },
new object[] { new Vector3(-10, 10, 20), 45, new Vector3(-90, 180, 270), new Vector3(-10, -35, 20), new Vector3(20, -10, -35) },
new object[] { new Vector3(0, 10, 0), 45, new Vector3(0, 90, 0), new Vector3(45, 10, 0), new Vector3(0, 10, -45) },
new object[] { new Vector3(0, 10, 0), 45, new Vector3(0, 0, 90), new Vector3(0, 10, -45), new Vector3(-10, 0, -45) },
};
[Test]
[TestCaseSource("cameraViewPositionTestSource")]
public void ModelViewPositionTest(Vector3 centerPos, float dist, Vector3 ang, Vector3 worldPos, Vector3 localPos)
{
var raw = new Raw.Components.Project.Camera()
{
CurrentStatus = new Raw.Components.Project.CurrentCameraState()
{
CenterPosition = centerPos,
Rotation = ang.ToRad(),
OffsetPosition = localPos
},
InitialKeyFrame = new Raw.Components.Project.CameraKeyFrame()
{
Interpolation = new Raw.Components.Project.CameraInterpolationImpl(),
Value = new Raw.Components.Project.CameraState()
},
KeyFrames = new List<Raw.Components.Project.CameraKeyFrame>()
};
var conv = new Scallion.Internal.Converters.Project.CameraConverter(true);
var dest = conv.Convert(raw);
Assert.AreEqual(dist, dest.CurrentStatus.Distance, 0.005f);
localPos.AssertEquals(conv.ConvertBack(dest).CurrentStatus.OffsetPosition, 0.005f);
}

[Test]
public void CameraViewPositionTest()
{
var raw = new Raw.Components.Project.Camera()
{
CurrentStatus = new Raw.Components.Project.CurrentCameraState()
{
CenterPosition = new Vector3(0, 10, 0),
Rotation = new Vector3(0, 0, 0).ToRad(),
OffsetPosition = new Vector3(0, 0, -30)
},
InitialKeyFrame = new Raw.Components.Project.CameraKeyFrame()
{
Interpolation = new Raw.Components.Project.CameraInterpolationImpl(),
Value = new Raw.Components.Project.CameraState()
},
KeyFrames = new List<Raw.Components.Project.CameraKeyFrame>()
};
var conv = new Scallion.Internal.Converters.Project.CameraConverter(false);
var dest = conv.Convert(raw);
Assert.AreEqual(30, dest.CurrentStatus.Distance);
Assert.AreEqual(raw.CurrentStatus.OffsetPosition, conv.ConvertBack(dest).CurrentStatus.OffsetPosition);
}
}
}
11 changes: 10 additions & 1 deletion Scallion.Tests/Internal/HelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public static void AssertPropertyValuesAreEquals(this object actual, object expe
object expectedValue = property.GetValue(expected, null);
object actualValue = property.GetValue(actual, null);

if (actualValue is ICollection)
if (actualValue == null)
Assert.Null(expectedValue);
else if (actualValue is ICollection)
// Comparison for elements contained in the list
property.AssertListsAreEquals((ICollection)actualValue, (ICollection)expectedValue);
else if (!actualValue.GetType().IsValueType && !actualValue.GetType().Namespace.StartsWith("System"))
Expand Down Expand Up @@ -73,6 +75,13 @@ private static void AssertListsAreEquals(this PropertyInfo property, ICollection
actual.Current.AssertPropertyValuesAreEquals(expected.Current);
}
}

public static void AssertEquals(this System.Numerics.Vector3 expected, System.Numerics.Vector3 actual, float delta)
{
Assert.AreEqual(expected.X, actual.X, delta);
Assert.AreEqual(expected.Y, actual.Y, delta);
Assert.AreEqual(expected.Z, actual.Z, delta);
}
}

[TestFixture]
Expand Down
23 changes: 23 additions & 0 deletions Scallion.Tests/Internal/NumericsExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Numerics;

namespace Scallion.Tests.Internal
{
internal static class NumericsExtensions
{
public static Vector3 ToRad(this Vector3 deg)
{
return new Vector3((float)Math.PI * deg.X / 180, (float)Math.PI * deg.Y / 180, (float)Math.PI * deg.Z / 180);
}

public static Vector3 ToDeg(this Vector3 rad)
{
return new Vector3(rad.X * 180 / (float)Math.PI, rad.Y * 180 / (float)Math.PI, rad.Z * 180 / (float)Math.PI);
}
}
}
2 changes: 1 addition & 1 deletion Scallion.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[assembly: ComVisible(false)]
[assembly: Guid("2b69216b-f367-46a9-8d9b-56b16771019c")]

[assembly: AssemblyVersion("0.9.1.0")]
[assembly: AssemblyVersion("0.10.0.0")]
3 changes: 0 additions & 3 deletions Scallion.Tests/Resources/Binaries/Motion_Bone_1.vmd

This file was deleted.

3 changes: 0 additions & 3 deletions Scallion.Tests/Resources/Binaries/Motion_Camera_1.vmd

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions Scallion.Tests/Resources/Fixtures/Raw/Motion_Bone_1.json

This file was deleted.

3 changes: 0 additions & 3 deletions Scallion.Tests/Resources/Fixtures/Raw/Motion_Camera_1.json

This file was deleted.

28 changes: 7 additions & 21 deletions Scallion.Tests/Scallion.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConverterTests\Project\CameraTest.cs" />
<Compile Include="Internal\HelperExtensions.cs" />
<Compile Include="Internal\NumericsExtensions.cs" />
<Compile Include="UnitTests\Core\MoSerializerTest.cs" />
<Compile Include="UnitTests\DomainModels\MotionTest.cs" />
<Compile Include="UnitTests\IOTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTests\Raw\MotionTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Scallion\Scallion.csproj">
Expand All @@ -77,24 +77,10 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\Binaries\Motion_Bone_1.vmd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\Binaries\Motion_Camera_1.vmd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\Fixtures\DomainModels\Motion_Bone_1.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\Fixtures\DomainModels\Motion_Camera_1.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\Fixtures\Raw\Motion_Bone_1.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\Fixtures\Raw\Motion_Camera_1.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="UnitTests\DomainModels\" />
<Folder Include="UnitTests\Raw\" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
26 changes: 0 additions & 26 deletions Scallion.Tests/UnitTests/DomainModels/MotionTest.cs

This file was deleted.

69 changes: 0 additions & 69 deletions Scallion.Tests/UnitTests/IOTest.cs

This file was deleted.

26 changes: 0 additions & 26 deletions Scallion.Tests/UnitTests/Raw/MotionTest.cs

This file was deleted.

Loading

0 comments on commit a81e48e

Please sign in to comment.