123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TeshMap : MonoBehaviour
- {
-
-
-
- public Transform mapPointA;
- public Transform mapPointB;
-
-
-
-
- public Transform player;
-
-
-
-
- public TestMapShow testMinMapShow;
-
-
-
- public TestMapShow testMaxMapShow;
- public UdpClient udpClient;
- public Vector2 mapSize;
- Vector3 oldPos;
-
-
-
- public float disZ;
- public float disX;
- float times;
-
-
-
- public List<Transform> listPoint;
- List<Vector3> listPointPos;
- private void Start()
- {
-
- Debug.Log(mapPointA.eulerAngles + " mapPointA " + mapPointA.localEulerAngles);
-
- disX = Mathf.Abs(mapPointB.localPosition.x - mapPointA.localPosition.x);
- disZ = Mathf.Abs(mapPointB.localPosition.z - mapPointA.localPosition.z);
- MapPoint();
- }
- private void LateUpdate()
- {
- if (oldPos != player.localPosition)
- {
- oldPos = player.localPosition;
- MapPosRot();
- }
- times += Time.deltaTime;
- if (times > 0.5f && API_SVR.IsSvrInitialized())
- {
- times = 0;
- Vector2 mapPos = MapPos();
- Vector3 pos = new Vector3(mapSize.x * mapPos.x, mapSize.y * mapPos.y, 0.0f);
- string Ts = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString();
- udpClient.SendIpToPointCloud(pos, Ts);
- }
- }
-
-
-
- private void MapPosRot()
- {
-
- float x = Mathf.Abs(oldPos.x - mapPointA.localPosition.x)/disX;
- float z = (Mathf.Abs(oldPos.z - mapPointA.localPosition.z))/disZ;
-
-
-
- SettingMapPosRot(z, x);
-
- }
- private Vector2 MapPos()
- {
- float x = Mathf.Abs(oldPos.x - mapPointA.localPosition.x) / disX;
- float z = (Mathf.Abs(oldPos.z - mapPointA.localPosition.z)) / disZ;
- Vector2 pos = new Vector2(z, x);
- return pos;
- }
- private void SettingMapPosRot( float z, float x)
- {
- testMaxMapShow.ShowPlayer(z, x, player.transform.localEulerAngles.y + 179);
- testMinMapShow.MapRot(z, x, player.transform.localEulerAngles.y - 80);
- }
-
-
-
- private void MapPoint()
- {
- if (listPoint.Count <= 0)
- return;
- listPointPos = new List<Vector3>();
- for (int i = 0; i < listPoint.Count; i++)
- {
- float x = Mathf.Abs(listPoint[i].localPosition.x - mapPointA.localPosition.x) / disX;
- float z = Mathf.Abs(listPoint[i].localPosition.z - mapPointA.localPosition.z) / disZ;
- Debug.Log(Mathf.Abs(listPoint[i].localPosition.z - mapPointA.localPosition.z) + " "+ disX);
- listPointPos.Add(new Vector3(z, x, 0));
- }
- testMaxMapShow.ShowPoint(listPointPos);
- testMinMapShow.LucencyMap();
- testMinMapShow.ShowPoint(listPointPos);
- testMinMapShow.LucencyMap();
- }
-
- }
|