本文整理汇总了C#中global.GetTransform方法的典型用法代码示例。如果您正苦于以下问题:C# global.GetTransform方法的具体用法?C# global.GetTransform怎么用?C# global.GetTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类global
的用法示例。
在下文中一共展示了global.GetTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: updateState
public void updateState(global::Vessel vessel)
{
_rootRotation = new Quaternion(vessel.GetTransform().rotation);
}
示例2: update
public void update(global::Vessel vessel)
{
centerOfMass = new Vector3(vessel.findWorldCenterOfMass());
mass = 0;
torque = new Vector3(0, 0, 0);
momentumOfInertia = new Vector3(0, 0, 0);
angularMomentum = new Vector3(0, 0, 0);
foreach(Part p in vessel.parts)
{
if (p.physicalSignificance != Part.PhysicalSignificance.NONE)
{
double partMass = p.mass + p.GetResourceMass();
mass += partMass;
}
if (p is CommandPod)
{
torque = torque + Vector3.one * Math.Abs(((CommandPod)p).rotPower);
}
foreach (PartModule pm in p.Modules)
{
if (!pm.isEnabled) continue;
if (pm is ModuleReactionWheel)
{
ModuleReactionWheel rw = (ModuleReactionWheel)pm;
if (rw.wheelState == ModuleReactionWheel.WheelState.Active)
{
torque = torque + new Vector3(rw.PitchTorque, rw.RollTorque, rw.YawTorque);
}
}
}
}
var inertiaTensor = new Matrix3x3();
foreach (Part p in vessel.parts)
{
if (p.Rigidbody == null) continue;
Vector3d principalMoments = p.Rigidbody.inertiaTensor;
UnityEngine.Quaternion princAxesRot = UnityEngine.Quaternion.Inverse(vessel.GetTransform().rotation) * p.transform.rotation * p.Rigidbody.inertiaTensorRotation;
UnityEngine.Quaternion invPrincAxesRot = UnityEngine.Quaternion.Inverse(princAxesRot);
for (int i = 0; i < 3; i++)
{
Vector3d iHat = Vector3d.zero;
iHat[i] = 1;
for (int j = 0; j < 3; j++)
{
Vector3d jHat = Vector3d.zero;
jHat[j] = 1;
inertiaTensor[i, j] += Vector3d.Dot(iHat, princAxesRot * Vector3d.Scale(principalMoments, invPrincAxesRot * jHat));
}
}
double partMass = p.mass + p.GetResourceMass();
UnityEngine.Vector3 partPosition = vessel.GetTransform().InverseTransformDirection(p.Rigidbody.worldCenterOfMass - centerOfMass.unity);
for (int i = 0; i < 3; i++)
{
inertiaTensor[i, i] += partMass * partPosition.sqrMagnitude;
for (int j = 0; j < 3; j++)
{
inertiaTensor[i, j] += -partMass * partPosition[i] * partPosition[j];
}
}
}
momentumOfInertia = new Vector3(inertiaTensor[0, 0], inertiaTensor[2, 2], inertiaTensor[1, 1]);
Vector3 angularVelocity = new Quaternion(vessel.GetTransform().rotation).inverse * new Vector3(vessel.rigidbody.angularVelocity);
angularMomentum = inertiaTensor * angularVelocity;
angularMomentum = new Vector3(angularMomentum.x, angularMomentum.z, angularMomentum.y);
}