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 virtual void CustomStart(string servoName, MemoryBridge memoryBridge, LimbController limbController, int parentID) { this.servoName = servoName; gameObject.name = servoName; this.limbController = limbController; this.memoryBridge = memoryBridge; limitMin = memoryBridge.GetFloat(servoName + "minPos"); limitMax = memoryBridge.GetFloat(servoName + "maxPos"); // Debug.Log(limitMax); if (servoName.ToLower().Contains("base")) { Debug.Log("Let limb base"); limbControllerPart = RoboticLimb.LimbPart.Base; limbController.servoBase = this; } else if (servoName.ToLower().Contains("wrist")) { limbControllerPart = RoboticLimb.LimbPart.Wrist; } if (servoName.ToLower().Contains("reverse")) { invert = true; } hostPart = GetComponent <Part>(); hostPart.ServoAdded(this); lineRenderer = hostPart.lineRenderer; foreach (var part in hostPart.vessel.parts) { if (part.ID == parentID) { servoParent = part.servo; servoParent.SetChild(this); } } if (hostPart.name.ToLower().Contains("skip")) { DisableServo(true); Debug.Log(name + " disabled"); } }
public override void CustomStart(string servoName, MemoryBridge memoryBridge, LimbController limbController, int parentID) { base.CustomStart(servoName, memoryBridge, limbController, parentID); currentServoPos = memoryBridge.GetFloat(servoName + "servoPos"); kspStartAngle = currentServoPos; }
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(); }
void BuildCamera() { // rendTextHeight = cam.pixelHeight; // rendTextWidth = cam.pixelWidth; var newRig = Instantiate(Resources.Load("CamPrefab", typeof(GameObject))) as GameObject; cameraRig = newRig.transform; cameraRig.SetParent(memoryBridge.transform); meshRenderer = cameraRig.Find("Screen").GetComponent <MeshRenderer>(); rendTextHeight = (int)memoryBridge.GetFloat("rendTextHeight" + fileName + memoryBridge.cameraFeeds.Count); rendTextWidth = (int)memoryBridge.GetFloat("rendTextWidth" + fileName + memoryBridge.cameraFeeds.Count); feedByteCount = (int)memoryBridge.GetFloat("feedByteCount" + fileName + memoryBridge.cameraFeeds.Count); readTex = new Texture2D(rendTextWidth, rendTextHeight, TextureFormat.RGB24, false); tex = new Texture2D(rendTextWidth, rendTextHeight, TextureFormat.RGB24, false); texCopy = new Texture2D(rendTextWidth, rendTextHeight, TextureFormat.RGB24, false); Debug.Log("rendTextWidth " + rendTextWidth); rendText = new RenderTexture(rendTextWidth, rendTextHeight, 16, RenderTextureFormat.ARGB32); rendText.Create(); }
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); }