private static void SetDataToPath(int pathID) { DualQuaternion[] pathsCDH = Database.PathsDisplacementQuaternions[pathID]; DisplacementData[] movementPath = new DisplacementData[pathsCDH.Length]; float3[] spline = new float3[pathsCDH.Length]; for (int i = 0; i < pathsCDH.Length; i++) { float4 movementPoint = DisplacementMovement(pathsCDH[i]); float4 rotationPoint = DisplacementRotation(pathsCDH[i], movementPoint); spline[i] = new float3(movementPoint.x, movementPoint.y, movementPoint.z); movementPath[i] = new DisplacementData( spline[i], new quaternion(pathsCDH[i].Wt) //(rotationPoint.x, rotationPoint.y, rotationPoint.z) ); } // Conncet Traveler with Trajectory if (Database.ObjectMovementPath.ContainsKey(pathID)) { Database.ObjectMovementPath[pathID] = movementPath; } else { Database.MovementProgress.Add(pathID, 0); Database.ObjectMovementPath.Add(pathID, movementPath); } // Update LineRenderer LineRendererSystem.SetPolygonPoints(pathID, spline); }
protected override void OnUpdate() { if (!done) { //Debug.Log("OnUpdate"); EntityManager em = World.Active.GetOrCreateManager <EntityManager>(); for (int pth = 0; pth < _chunks.Length; pth++) // Paths { Transform pathTransform = _chunks.T[pth]; List <float3> pathPoints = new List <float3>(); foreach (Transform curveTrans in pathTransform) // Curves { if (curveTrans.tag == "Trajectory") { PosAndRotArrs cpsData = GetPointsPosAndRot(curveTrans); quaternion[] cpsRot = cpsData.rotArr; float3[] cpsPos = cpsData.posArr; // dummy test data: quaternion v0 = new quaternion(3f, 4f, 1f, 0f); quaternion v1 = new quaternion(2f, 2f, 0f, 0f); float3 p0 = new float3(0f, 0f, 0f); float3 p1 = new float3(.6f, .8f, .5f); float3 postumis = new float3(1, 2, -2); p0 += postumis; p1 += postumis; Transform p0T = curveTrans.GetChild(0); Transform p1T = curveTrans.GetChild(1); // changing transform to mock data p0T.position = p0; p1T.position = p1; p0T.rotation = v0; p1T.rotation = v1; // quaternion[] RFrames = GetRFrames(cpsRot[0], cpsRot[1]); // how should be // USE THIS ONE float4[] RFrames = GetRFrames(v0, v1); p0T.rotation = H.Float4ToQuat(RFrames[0]); p1T.rotation = H.Float4ToQuat(RFrames[1]); //quaternion[] RFrames = GetRFramesWithMatrix(q0, q1); // correct with mock data //quaternion[] RFramesX = GetRFramesOld(q0, q1); // correct with mock data // Debug.Log(RFrames[0]);s // Debug.Log(RFrames[1]); // Debug.Log(RFrames[2]); // GetPHCUrve(cpsPos[0], cpsRot[0], cpsPos[1], cpsRot[1], ref pathPoints); // SITAS GetPHCUrve(p0, RFrames[0], p1, RFrames[1], ref pathPoints); } } LineRendererSystem.SetPolygonPoints(_chunks.lrs[pth], pathPoints); done = true; } } }