private void DrawLine(Player player, Vector2 screen) { Vector3 w2s = Camera.main.WorldToScreenPoint(player.PlayerBones.RootJoint.position); if (w2s.z < 0.01f) { return; } var distance = (float)Math.Floor(Vector3.Distance(player.Transform.position, CGameWorld.MainCamera.transform.position)); Print.DrawLine(screen, new Vector2(w2s.x, Screen.height - w2s.y), 2f, Settings.CPlayer.linesColor); }
private static void ConnectBones(Dictionary <EHumanBones, Vector3> bones, EHumanBones start, EHumanBones stop) { if (!bones.ContainsKey(start) || !bones.ContainsKey(stop)) { return; } D.vectorA = bones[start]; if (D.vectorA.z < 0.01f) { return; } D.vectorB = bones[stop]; if (D.vectorB.z < 0.01f) { return; } Print.DrawLine(D.vectorA, D.vectorB, 1f, Settings.CPlayer.skeletonColor); }
private void DrawBoxes(Player player) { D.boneList = player.PlayerBody.SkeletonRootJoint.Bones.Values.ToList(); if (D.boneList.Count == 0) { return; } D.vectorA = D.boneList[0].position; D.vectorB = D.vectorA; D.boneList.RemoveAt(0); D.vectorC = Vector3.zero; for (int i = 0; i < D.boneList.Count; i++) { Transform bone = D.boneList[i]; if (bone == null || !neededBones.Contains((EHumanBones)i)) { continue; } D.vectorC = bone.position; if (D.vectorA.x > D.vectorC.x) { D.vectorA.x = D.vectorC.x; } if (D.vectorA.y > D.vectorC.y) { D.vectorA.y = D.vectorC.y; } if (D.vectorA.z > D.vectorC.z) { D.vectorA.z = D.vectorC.z; } if (D.vectorB.x < D.vectorC.x) { D.vectorB.x = D.vectorC.x; } if (D.vectorB.y < D.vectorC.y) { D.vectorB.y = D.vectorC.y; } if (D.vectorB.z < D.vectorC.z) { D.vectorB.z = D.vectorC.z; } } D.bounds = new Vector3[8] { //Lower parts new Vector3(D.vectorA.x, D.vectorA.y, D.vectorA.z), //LB new Vector3(D.vectorB.x, D.vectorA.y, D.vectorA.z), //RB new Vector3(D.vectorA.x, D.vectorA.y, D.vectorB.z), //LF new Vector3(D.vectorB.x, D.vectorA.y, D.vectorB.z), //RF //Upper parts new Vector3(D.vectorA.x, D.vectorB.y, D.vectorA.z), //LB new Vector3(D.vectorB.x, D.vectorB.y, D.vectorA.z), //RB new Vector3(D.vectorA.x, D.vectorB.y, D.vectorB.z), //LF new Vector3(D.vectorB.x, D.vectorB.y, D.vectorB.z), //RF }; D.w2sl = new Vector3[8]; for (int i = 0; i < 8; i++) { D.w2sl[i] = CGameWorld.MainCamera.WorldToScreenPoint(D.bounds[i]); D.w2sl[i].y = NamelessScreen.screenHeight - D.w2sl[i].y; } if (Settings.CPlayer.bDraw2DBox) { //Draw2DBox D.vectorA = D.w2sl[0]; D.vectorB = D.vectorA; for (int i = 1; i < 8; i++) { if (D.w2sl[i].z < 0.01f) { continue; } if (D.vectorA.x > D.w2sl[i].x) { D.vectorA.x = D.w2sl[i].x; } if (D.vectorA.y > D.w2sl[i].y) { D.vectorA.y = D.w2sl[i].y; } if (D.vectorB.x < D.w2sl[i].x) { D.vectorB.x = D.w2sl[i].x; } if (D.vectorB.y < D.w2sl[i].y) { D.vectorB.y = D.w2sl[i].y; } } D.box2D = new Vector2[4] { new Vector3(D.vectorA.x, D.vectorA.y), new Vector3(D.vectorB.x, D.vectorA.y), new Vector3(D.vectorA.x, D.vectorB.y), new Vector3(D.vectorB.x, D.vectorB.y) }; Print.DrawLine(D.box2D[0], D.box2D[1], 2f, Settings.CPlayer.BoxColor); Print.DrawLine(D.box2D[0], D.box2D[2], 2f, Settings.CPlayer.BoxColor); Print.DrawLine(D.box2D[2], D.box2D[3], 2f, Settings.CPlayer.BoxColor); Print.DrawLine(D.box2D[3], D.box2D[1], 2f, Settings.CPlayer.BoxColor); } }