public void HandleData(Vector2 vet, HumanPoseType hpt) { HumanPoseNode hpn = stateManager.FindHumanPoseByType(hpt); Vector2 Mouse; Mouse.x = Mathf.Clamp((vet.x - (Screen.width / 2)) / Screen.width * 2, -1, 1); Mouse.y = Mathf.Clamp(-(vet.y - (Screen.height / 2)) / Screen.height * 2, -1, 1); screenInp = Mouse; screenInp.x = (screenInp.x + 1) * 0.5f; screenInp.y = (-screenInp.y + 1) * 0.5f; screenInp.x *= Screen.width; screenInp.y *= Screen.height; Control(hpn); var c1 = new Color(1, 1, 0, trial_alpha); var c2 = new Color(1, 0, 0, trial_alpha); hpn.HP_Trail.startColor = c1; hpn.HP_Trail.endColor = c2; hpn.HP_Trail.startWidth = 0.8f; hpn.HP_Trail.endWidth = 0.8f; if (trial_alpha > 0) { trial_alpha -= Time.deltaTime; } }
public void Control(HumanPoseNode hpn) { start = screenInp; var a = Camera.main.ScreenToWorldPoint(new Vector3(start.x, start.y, 10)); var b = Camera.main.ScreenToWorldPoint(new Vector3(end.x, end.y, 10)); if (Vector3.Distance(a, b) > 0.5f) { lineTimer = 0.25f; AddTrailPosition(hpn); hpn.HP_LinePart++; } end = screenInp; trial_alpha = 0.75f; // if (trial_alpha > 0.5) { for (var p = 0; p < 8; p++) { for (var i = 0; i < raycastCount; i++) { if (Vector3.Distance(hpn.HP_TrailPositions[p], hpn.HP_TrailPositions[p + 1]) < 0.5f) { continue; } Ray ray = Camera.main.ScreenPointToRay(Vector3.Lerp(Camera.main.WorldToScreenPoint(hpn.HP_TrailPositions[p]), Camera.main.WorldToScreenPoint(hpn.HP_TrailPositions[p + 1]), i * 1.0f / raycastCount * 1.0f)); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, (1 << 10))) { BlowObject(hit); } } } } //lineTimer -= Time.deltaTime; //if (lineTimer <= 0.0) //{ // AddTrailPosition(hpn); // lineTimer = 0.01f; //} // if (fire_up && started) started = false; SendTrailPosition(hpn); }
void SendTrailPosition(HumanPoseNode hpn) { var index = 0; foreach (Vector3 v in hpn.HP_TrailPositions) { hpn.HP_Trail.SetPosition(index, v); index++; } }
private void FirstInit(HumanPoseNode hpn, LineRenderer lrender) { trial_alpha = 1.0f; start = screenInp; end = screenInp; hpn.HP_LinePart = 0; hpn.HP_Trail = lrender; AddTrailPosition(hpn); started = true; }
public void AddTrailPosition(HumanPoseNode hpn) { if (hpn.HP_LinePart > 9) { for (int i = 0; i <= 8; i++) { hpn.HP_TrailPositions[i] = hpn.HP_TrailPositions[i + 1]; hpn.HP_TrailPositions[9] = Camera.main.ScreenToWorldPoint(new Vector3(start.x, start.y, 10)); } } else { for (int ii = hpn.HP_LinePart; ii <= 9; ii++) { hpn.HP_TrailPositions[ii] = Camera.main.ScreenToWorldPoint(new Vector3(start.x, start.y, 10)); } } }