forked from jeff-1amstudios/OpenC1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCActor.cs
56 lines (50 loc) · 1.75 KB
/
CActor.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
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StillDesign.PhysX;
namespace OpenC1
{
class CActor
{
public string Name { get; private set; }
public string ModelName { get; set; }
public CModel Model { get; set; }
public string MaterialName { get; set; }
public CMaterial Material { get; set; }
public Matrix Matrix, ParentMatrix;
public CActor Parent;
internal List<CActor> Children { get; set; }
public BoundingBox BoundingBox;
public byte[] Flags;
public bool IsWheel;
public StillDesign.PhysX.Actor PhysXActor { get; private set; }
public bool IsAnimated;
public CActor()
{
Children = new List<CActor>();
}
public void SetName(string name)
{
Name = name;
IsWheel = (name.StartsWith("FLPIVOT") || name.StartsWith("FRPIVOT") || name.StartsWith("RLWHEEL") || name.StartsWith("RRWHEEL")
|| name.StartsWith("MLWHEEL") || name.StartsWith("MRWHEEL"));
}
internal void AttachToPhysX(Actor instance)
{
// if this CActor is attached to a PhysX object, reduce the Matrix to a scale,
// as the position/orienation will come from PhysX
PhysXActor = instance;
Vector3 scaleout, transout;
Quaternion b;
Matrix.Decompose(out scaleout, out b, out transout);
Matrix = Matrix.CreateScale(scaleout);
}
public Matrix GetDynamicMatrix()
{
if (PhysXActor == null) return Matrix;
return Matrix * PhysXActor.GlobalPose;
}
}
}