本文整理汇总了C#中Vessel.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.SetPosition方法的具体用法?C# Vessel.SetPosition怎么用?C# Vessel.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.SetPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
}
示例4: 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;
}
示例5: LaunchShip
public void LaunchShip()
{
ShipConstruct vehicle = new ShipConstruct();
if (!vehicle.LoadShip(m_VehicleConfig)) return;
Game fsc = FlightDriver.FlightStateCache;
VesselCrewManifest vesselCrew = new VesselCrewManifest();
Bounds aabb = GetAABB(vehicle);
if (aabb.min == null) Application.Quit();
launchData = m_ConstructionPort.PlaceShip(vehicle, aabb);
ShipConstruction.AssembleForLaunch(vehicle, "BANAAN", null, fsc, vesselCrew);
m_Vessel = FlightGlobals.Vessels[FlightGlobals.Vessels.Count - 1];
FlightGlobals.ForceSetActiveVessel(m_Vessel);
Vector3 offset = m_Vessel.transform.position - launchData.position;
craftOffset = launchData.InverseTransformDirection(offset);
m_Vessel.SetPosition(craftOffset, true);
Staging.beginFlight();
FlightGlobals.overrideOrbit = true;
m_ConstructionPort.StartCoroutine(CaptureCraft());
}