本文整理汇总了C#中Vessel.SetRotation方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.SetRotation方法的具体用法?C# Vessel.SetRotation怎么用?C# Vessel.SetRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.SetRotation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: placeVesselForDock
private void placeVesselForDock(Vessel placeVessel, Part placePort, Vessel targetVessel, Part targetPort, float distanceFactor)
{
//print("st3");
ModuleDockingNode placeDockingNode = placePort.Modules.OfType<ModuleDockingNode>().FirstOrDefault();
//print("st4");
ModuleDockingNode targetDockingNode = targetPort.Modules.OfType<ModuleDockingNode>().FirstOrDefault();
//print("st5");
//print("0 " + placeDockingNode.controlTransform.position);
//print("p9 " + targetDockingNode.controlTransform.rotation);
//print("r9 " + placeVessel.vesselTransform.rotation);
//rotate vessel
//placeDockingNode.MakeReferenceTransform();
QuaternionD placeVesselRotation = targetDockingNode.controlTransform.rotation * Quaternion.Euler(180f, (float)rand.Next(0, 360), 0);
placeVessel.SetRotation(placeVesselRotation);
//
placeVessel.SetRotation(placeDockingNode.controlTransform.rotation * Quaternion.Euler(0, (float)rand.Next(0, 360), 0));
//print("ae " + placeVessel.vesselTransform.rotation);
//print("as " + placeVesselRotation);
//print("aw " + Quaternion.FromToRotation(placeVessel.vesselTransform.up, -placeDockingNode.controlTransform.up).eulerAngles.ToString());
//print("as " + placeDockRotation.eulerAngles.ToString());
//Vector3.Cross
//QuaternionD placeVesselRotation = placeDockRotation - (placeDockingNod.controlTransform.rotation -
//print("aa" + placeDockingNode.nodeTransform.forward.normalized);
//print("aa" + placeDockingNode.nodeTransform.forward.normalized);
//print(Vector3.Angle(Vector3.Cross(placeDockingNode.nodeTransform.forward.normalized, placeVessel.vesselTransform.up.normalized),Vector3.Cross(placeVessel.vesselTransform.forward.normalized, placeVessel.vesselTransform.up.normalized)));
//print(Vector3.Angle(Vector3.Cross(targetDockingNode.nodeTransform.forward.normalized, placeVessel.vesselTransform.up.normalized), Vector3.Cross(placeVessel.vesselTransform.forward.normalized, placeVessel.vesselTransform.up.normalized)));
float anglePlaceDock = angleNormal(placeDockingNode.nodeTransform.forward.normalized, placeVessel.vesselTransform.forward.normalized, placeVessel.vesselTransform.up.normalized);
float angleTargetDock = angleNormal(-targetDockingNode.nodeTransform.forward.normalized, placeVessel.vesselTransform.forward.normalized, placeVessel.vesselTransform.up.normalized);
//print(anglePlaceDock - angleTargetDock);
//print(anglePlaceDock);
//print(angleTargetDock);
placeVessel.SetRotation(placeVessel.vesselTransform.rotation * Quaternion.Euler(0, (anglePlaceDock - angleTargetDock), 0));
//print("p1 " + placeVessel.ReferenceTransform.position);
//print("p1 " + placeVessel.ReferenceTransform.rotation);
//print("r1 " + placeVessel.vesselTransform.rotation);
//position vessel
/*print("1 " + targetDockingNode.controlTransform.position);
print("1.3 " + targetDockingNode.controlTransform.up.normalized);*/
//print((placeDockingNode.controlTransform.up.normalized - placeDockingNode.controlTransform.position));
Vector3d placePortLocation = targetDockingNode.nodeTransform.position + (targetDockingNode.nodeTransform.forward.normalized * distanceFactor);
//Vector3d placePortLocation = targetDockingNode.controlTransform.position + (targetDockingNode.controlTransform.up.normalized * distanceFactor);
/*print("2 " + placePortLocation);
print("3 " + (placePort.transform.position - placeVessel.ReferenceTransform.position));
print("4 " + (placePort.transform.position - placeVessel.ReferenceTransform.position));*/
//print("12 " + placeVessel.ReferenceTransform.position);
Vector3d placeVesselPosition = placePortLocation + (placeVessel.vesselTransform.position - placeDockingNode.nodeTransform.position);
//Vector3d placeVesselPosition = placePortLocation + (placeVessel.ReferenceTransform.position - placeDockingNode.nodeTransform.position);
//Vector3d placeVesselPosition = placePortLocation + (placeVessel.ReferenceTransform.position - placeDockingNodecontrolTransform.position);
//print("4 " + placeVesselPosition);
//Vector3d FlightVesselPosition = new Vector3d((placeVesselPosition - targetVessel.mainBody.transform.position).x, (placeVesselPosition - targetVessel.mainBody.transform.position).z, (placeVesselPosition - targetVessel.mainBody.transform.position).y);
//print((FlightGlobals.ActiveVessel.orbit.pos - FlightVesselPosition));
placeVessel.SetPosition(placeVesselPosition);
//print("q " + placeVessel.vesselTransform.position);
//print("w " +placeVessel.ReferenceTransform.position);
//print(placeVessel.vesselTransform.position);
}
示例2: MoveAlignLight
public static void MoveAlignLight(Vessel fromVessel, Transform fromTransform, Vessel toVessel, Transform toTransform)
{
toVessel.SetRotation(toVessel.transform.rotation);
fromVessel.SetRotation(Quaternion.FromToRotation(fromTransform.forward, -toTransform.forward) * fromVessel.transform.rotation);
fromVessel.SetPosition(fromVessel.transform.position - (fromTransform.position - toTransform.position), true);
}
示例3: FromInFlightVessel
private ConfigNode FromInFlightVessel(Vessel VesselToSave)
{
//This code is taken from InflightShipSave by Claw, using the CC-BY-NC-SA license.
//This code thus is licensed under the same license, despite the GPLv3 license covering original KCT code
//See https://github.com/ClawKSP/InflightShipSave
string ShipName = VesselToSave.vesselName;
// Debug.LogWarning("Saving: " + ShipName);
ShipConstruct ConstructToSave = new ShipConstruct(ShipName, "", VesselToSave.parts[0]);
Quaternion OriginalRotation = VesselToSave.vesselTransform.rotation;
Vector3 OriginalPosition = VesselToSave.vesselTransform.position;
VesselToSave.SetRotation(new Quaternion(0, 0, 0, 1));
Vector3 ShipSize = ShipConstruction.CalculateCraftSize(ConstructToSave);
VesselToSave.SetPosition(new Vector3(0, ShipSize.y + 2, 0));
ConfigNode CN = new ConfigNode("ShipConstruct");
CN = ConstructToSave.SaveShip();
SanitizeShipNode(CN);
VesselToSave.SetRotation(OriginalRotation);
VesselToSave.SetPosition(OriginalPosition);
//End of Claw's code. Thanks Claw!
return CN;
}
示例4: wait_for_launched_vessel
IEnumerator<YieldInstruction> wait_for_launched_vessel(Vessel vsl)
{
if(vessel.LandedOrSplashed)
{
var pos = vsl.transform.position;
var rot = vsl.transform.rotation;
while(vsl.packed)
{
rot = vsl.transform.rotation;
pos = vsl.transform.position;
vsl.GoOffRails();
if(!vsl.packed) break;
yield return null;
}
vsl.SetPosition(pos);
vsl.SetRotation(rot);
}
else
{
var dpos = vsl.orbit.pos-vessel.orbit.pos;
vsl.orbitDriver.SetOrbitMode(OrbitDriver.UpdateMode.UPDATE);
while(vsl.packed)
{
vsl.orbit.pos = vessel.orbit.pos+dpos;
vsl.GoOffRails();
if(!vsl.packed) break;
yield return null;
}
vsl.orbitDriver.SetOrbitMode(OrbitDriver.UpdateMode.TRACK_Phys);
}
}
示例5: PackedRotation
private void PackedRotation(Vessel vessel)
{
if (vessel.situation != Vessel.Situations.LANDED || vessel.situation != Vessel.Situations.SPLASHED)
vessel.SetRotation(Quaternion.FromToRotation(data.direction[vessel.id.ToString()], data.reference[vessel.id.ToString()].GetTransform().position - vessel.transform.position) * data.rotation[vessel.id.ToString()]);
}
示例6: PackedSpin
private void PackedSpin(Vessel vessel)
{
if(vessel.situation != Vessel.Situations.LANDED || vessel.situation != Vessel.Situations.SPLASHED)
vessel.SetRotation(Quaternion.AngleAxis(data.momentum[vessel.id.ToString()].magnitude * TimeWarp.CurrentRate, vessel.ReferenceTransform.rotation * data.momentum[vessel.id.ToString()]) * vessel.transform.rotation);
}
示例7: OnVesselGoOffRails
private void OnVesselGoOffRails(Vessel vessel)
{
if (vessel.situation != Vessel.Situations.LANDED || vessel.situation != Vessel.Situations.SPLASHED)
{
if (vessel.ActionGroups[KSPActionGroup.SAS] && vessel.IsControllable) //vessel.Autopilot.Enabled does not work at this point!
{
//Reset locked heading
vessel.Autopilot.SAS.lockedHeading = vessel.ReferenceTransform.rotation;
//Set relative rotation if there is a reference
if (data.reference[vessel.id.ToString()] != null)
{
vessel.SetRotation(Quaternion.FromToRotation(data.direction[vessel.id.ToString()], data.reference[vessel.id.ToString()].GetTransform().position - vessel.transform.position) * data.rotation[vessel.id.ToString()]);
}
}
else
{
Vector3 av = data.momentum[vessel.id.ToString()];
Vector3 COM = vessel.findWorldCenterOfMass();
Quaternion rotation;
rotation = vessel.ReferenceTransform.rotation;
//Applying force on every part
foreach (Part p in vessel.parts)
{
try
{
if (p.rigidbody == null) continue;
p.rigidbody.AddTorque(rotation * av, ForceMode.VelocityChange);
p.rigidbody.AddForce(Vector3.Cross(rotation * av, (p.rigidbody.position - COM)), ForceMode.VelocityChange);
}
catch (NullReferenceException nre)
{
Debug.Log("[PR] NullReferenceException in OnVesselGoOffRails: " + nre.Message);
}
}
}
}
}