public void ReadServerAPI() { // memoryBridge.CoMD = memoryBridge.GetVector3("CoMD" + memoryBridge.fileName); memoryBridge.CurrentCOM = memoryBridge.GetVector3("CurrentCOM" + memoryBridge.fileName); memoryBridge.LocalCOM = memoryBridge.GetVector3("LocalCOM" + memoryBridge.fileName); memoryBridge.Acceleration = memoryBridge.GetVector3("Acceleration" + memoryBridge.fileName); memoryBridge.obt_velocity = memoryBridge.GetVector3("obt_velocity" + memoryBridge.fileName); memoryBridge.srf_velocity = memoryBridge.GetVector3("srf_velocity" + memoryBridge.fileName); memoryBridge.altitude = memoryBridge.GetFloat("altitude" + memoryBridge.fileName); memoryBridge.heightFromTerrain = memoryBridge.GetFloat("heightFromTerrain" + memoryBridge.fileName); memoryBridge.horizontalSrfSpeed = memoryBridge.GetFloat("horizontalSrfSpeed" + memoryBridge.fileName); memoryBridge.latitude = memoryBridge.GetFloat("latitude" + memoryBridge.fileName); memoryBridge.longitude = memoryBridge.GetFloat("longitude" + memoryBridge.fileName); memoryBridge.mach = memoryBridge.GetFloat("mach" + memoryBridge.fileName); memoryBridge.srfSpeed = memoryBridge.GetFloat("srfSpeed" + memoryBridge.fileName); memoryBridge.terrainAltitude = memoryBridge.GetFloat("terrainAltitude" + memoryBridge.fileName); memoryBridge.verticalSpeed = memoryBridge.GetFloat("verticalSpeed" + memoryBridge.fileName); memoryBridge.currentStage = memoryBridge.GetFloat("currentStage" + memoryBridge.fileName); memoryBridge.geeForce_immediate = memoryBridge.GetFloat("geeForce_immediate" + memoryBridge.fileName); memoryBridge.heightFromSurface = memoryBridge.GetFloat("heightFromSurface" + memoryBridge.fileName); memoryBridge.obt_speed = memoryBridge.GetFloat("obt_speed" + memoryBridge.fileName); memoryBridge.directSunlight = memoryBridge.GetBool("directSunlight" + memoryBridge.fileName); memoryBridge.Landed = memoryBridge.GetBool("Landed" + memoryBridge.fileName); memoryBridge.loaded = memoryBridge.GetBool("loaded" + memoryBridge.fileName); memoryBridge.Splashed = memoryBridge.GetBool("Splashed" + memoryBridge.fileName); }
public void CheckClearance() { if (IKactive)//& legMode == LegMode.Translate) { //limbMirror.contactPoint.position = limbMirror.servoWrist.transform.TransformPoint(memoryBridge.GetVector3(limbMirror.servoWrist.servoName + "CollisionPoint")); // limbIK.contactPoint.position = limbIK.servoWrist.transform.TransformPoint(memoryBridge.GetVector3(limbMirror.servoWrist.servoName + "CollisionPoint")); } torque = memoryBridge.GetVector3(limbMirror.servoWrist.servoName + "torque"); velocity = torque.magnitude; explosionPotential = memoryBridge.GetFloat(limbMirror.servoWrist.servoName + "explosionPotential"); gExplodeChance = memoryBridge.GetFloat(limbMirror.servoWrist.servoName + "gExplodeChance"); footActive = memoryBridge.GetBool(limbMirror.servoWrist.servoName + "active"); hasExploded = memoryBridge.GetBool(limbMirror.servoWrist.servoName + "exploded"); if (hasExploded) { CamUI.SetCamText(name + " has exploded"); Debug.LogError("Exploded Leg : " + name + " Velocity : " + velocity + " Mode : " + limbIK.gaitSequenceMode.ToString() + " Percent : " + CalculateStridePercent()); } rawClearance = memoryBridge.GetFloat(limbMirror.servoWrist.servoName + "KSPFootClearance"); //if(limbMirror.limbEnd == null) //{ // Debug.Log("end point null"); //} var contactPointOffSet = limbMirror.servoWrist.transform.position.y - limbMirror.trueLimbEnd.position.y; footClearance = rawClearance - contactPointOffSet; if (footClearance < .03f) { footClearance = 0; } groundContact = memoryBridge.GetBool(limbMirror.servoWrist.servoName + "GroundContact"); //if (!collisionPoint) //{ // collisionPoint = new GameObject("CollisionPoint").transform; // // DebugVector.DrawVector(collisionPoint, DebugVector.Direction.all, .5f, .1f, Color.red, Color.white, Color.blue); //} //collisionPoint.position = limbMirror.servoWrist.transform.TransformPoint(memoryBridge.GetVector3(limbMirror.servoWrist.servoName + "CollisionPoint")); // limbMirror. //if(limbIK) //if (!groundContact) // ground.position = limbMirror.servoWrist.transform.position - new Vector3(0, rawClearance, 0); var localPoint = limbMirror.limbEnd.localPosition - new Vector3(0, .4f, 0); ground.position = limbMirror.servoWrist.transform.TransformPoint(localPoint) - new Vector3(0, rawClearance, 0); }
public void CustomUpdate() { limbMirror.MirrorServos(); //hot fix //if (clearance > 3) // clearance = 0; var clearance = memoryBridge.GetFloat(limbMirror.servoWrist.servoName + "KSPFootClearance"); if (limbIK.gait) { ground.position = limbMirror.servoWrist.transform.position - new Vector3(0, clearance, 0); Debug.Log(name + " ground contact : " + memoryBridge.GetBool(limbMirror.servoWrist.servoName + "GroundContact")); var baseOffset = baseTarget.position.y - limbMirror.servoBase.transform.position.y; var globalPoint = limbIK.transform.TransformPoint(limbIK.gaitStartPos); globalPoint.y = ground.position.y; if (limbIK.legMode == RoboticLimbIK.LegMode.Translate) { globalPoint.y -= baseOffset; } limbIK.gait.localPosition = limbIK.transform.InverseTransformPoint(globalPoint); // var tempPos = limbIK.gaitStartPos; // tempPos.y = ground.position.y - baseOffset;//ground.position.y - baseOffset; //// limbIK.gait.position = tempPos;//limbMirror.limbEnd.position;// - new Vector3(0, clearance, 0); //limbIK.gait.localPosition = tempPos; var tempEuler = limbIK.gait.eulerAngles;// = Vector3.zero; tempEuler.x = 0; // tempEuler.y = vesselControl.mirrorVessel.vesselOffset.eulerAngles.y; limbIK.gait.eulerAngles = tempEuler; limbIK.RunGait(); if (debugClearance) { Debug.Log(Time.frameCount); Debug.Log("clearance " + clearance); // Debug.Log("mirror " + (float)Math.Round(limbMirror.limbEnd.transform.position.y, 2)); // Debug.Log("gait " + limbIK.gait.position.y); } } // if (!IKactive) if (IKactive) { limbIK.RunIK(); } limbIK.SetServos(); }