Exemple #1
0
        /// <summary>
        /// Applies the pose received from a CloudSLAM server to unity
        /// a given Unity transform. The pose will be transformed from
        /// CloudSLAM's coordinate system to Unity's coordinate system.
        /// </summary>
        /// <param name="cloudSLAMPoseMatrix4x4">The pose as received from
        /// a CloudSLAM server (i.e. an array of 16 floats that make
        /// up a 4x4 TRS matrix).</param>
        /// <param name="t">The transform to which the pose should be applied.</param>
        public static void ApplyPoseToUnityTransform(float[] cloudSLAMPoseMatrix4x4, Transform t)
        {
            CloudSLAMCoordiantes.CloudSLAMPoseToUnityPose(cloudSLAMPoseMatrix4x4, ref poseMatrix);

            t.position = poseMatrix.MultiplyPoint3x4(Vector3.zero);
            t.LookAt(poseMatrix.MultiplyPoint3x4(CloudSLAMCoordiantes.Forward), poseMatrix.MultiplyVector(CloudSLAMCoordiantes.Up));
        }
        public IEnumerator LoadMap(string serverAddress)
        {
            UnityWebRequest www = BuildGetMapRequest(serverAddress);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                Debug.Log(www.downloadHandler.text);
                storage = JsonConvert.DeserializeObject <MapStorage>(www.downloadHandler.text);
                if (storage != null)
                {
                    var scaleV = new Vector3(MapPointScale, MapPointScale, MapPointScale);
                    mapPoints = storage.mapPoints.Values
                                .Select(p => Matrix4x4.TRS(CloudSLAMCoordiantes.CloudSlamPositionToUnity(p[0], p[1], p[2]), Quaternion.identity, scaleV))
                                .ToArray();
                    for (int i = 0; i < Mathf.Ceil(mapPoints.Count() / 1000); ++i)
                    {
                        mapPointBatches.Add(mapPoints.Skip(i * 1000).Take(1000).ToArray());
                    }
                }
            }
        }
 void Update()
 {
     if (!poseBufferHandle.Equals(IntPtr.Zero))
     {
         Marshal.Copy(poseBufferHandle, poseBuffer, 0, 16);
         CloudSLAMCoordiantes.ApplyPoseToUnityTransform(poseBuffer, unityCamera.transform);
     }
 }
        protected void PlaceInScene(PointOfInterest poi, GameObject parent)
        {
            var actor = CreateActor(poi);

            if (actor == null)
            {
                return;
            }
            if (parent != null)
            {
                actor.transform.SetParent(parent.transform);
            }
            actor.GetComponentsInChildren <Renderer>().ToList().ForEach(r => r.receiveShadows = false);
            CloudSLAMCoordiantes.ApplyPoseToUnityTransform(poi.Position, poi.Rotation, poi.LocalScale, actor.transform);
        }