/
StaticMeshColliderShapeDesc.cs
64 lines (54 loc) · 1.9 KB
/
StaticMeshColliderShapeDesc.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using Xenko.Core;
using Xenko.Core.Mathematics;
using Xenko.Core.Serialization.Contents;
using Xenko.Graphics;
using Xenko.Rendering;
namespace Xenko.Physics
{
[ContentSerializer(typeof(DataContentSerializer<StaticMeshColliderShapeDesc>))]
[DataContract("StaticMeshColliderShapeDesc")]
[Display(500, "Static Mesh")]
public class StaticMeshColliderShapeDesc : IInlineColliderShapeDesc
{
/// <userdoc>
/// Model asset from which the engine will derive the collider shape.
/// </userdoc>
[DataMember(10)]
public Model Model;
/// <userdoc>
/// The local offset of the collider shape.
/// </userdoc>
[DataMember(20)]
public Vector3 LocalOffset;
/// <userdoc>
/// The local rotation of the collider shape.
/// </userdoc>
[DataMember(30)]
public Quaternion LocalRotation = Quaternion.Identity;
/// <userdoc>
/// The scaling of the collider shape.
/// </userdoc>
[DataMember(40)]
public Vector3 Scaling = Vector3.One;
public bool Match(object obj)
{
if (obj is StaticMeshColliderShapeDesc other)
{
return other.Model == Model
&& other.LocalOffset == LocalOffset
&& other.LocalRotation == LocalRotation
&& other.Scaling == Scaling;
}
return false;
}
public ColliderShape NewShapeFromDesc()
{
if(Model == null)
return null;
return StaticMeshColliderShape.FromModel(Model, LocalOffset, LocalRotation, Scaling);
}
}
}