Inheritance: MonoBehaviour
Esempio n. 1
0
        public override IEnumerator RunJob()
        {
            Debug.Log("*************************** CoroutineJobFreeMap ***************************");

            BaseMapper mapper = host as BaseMapper;

            if (mapper.pcr.ContainsKey(id))
            {
                int mapId = mapper.pcr[id].mapId;

                Task <int> t0 = Task.Run(() =>
                {
                    return(Immersal.Core.FreeMap(mapId));
                });

                while (!t0.IsCompleted)
                {
                    yield return(null);
                }

                PointCloudRenderer p = mapper.pcr[id];
                p.ClearCloud();
                mapper.pcr.Remove(id);
            }
        }
Esempio n. 2
0
    void Update()
    {
        ////Debug.Log("button clicked");
        frame++;
        ////joints.UpdateJoints();

        if (frame == 300)
        {
            //stop recording; play
            ResearchMode.StartPreviewEvent();
            PointCloudRenderer.toggleView();
            //joints.toggleRecording();
        }
    }
Esempio n. 3
0
        protected override void DrawInspector(PointCloudRenderer obj)
        {
            DrawProtectedProperties(obj);

            // Use existing SerializedProperty property to remember foldout state
            nodeTreeLoader.isExpanded = EditorGUILayout.Foldout(nodeTreeLoader.isExpanded, "Culling Settings");
            if (nodeTreeLoader.isExpanded)
            {
                EditorGUILayout.PropertyField(nodeTreeLoader);
                EditorGUILayout.PropertyField(cullCamera);
                EditorGUILayout.PropertyField(cullMode);
                EditorGUILayout.PropertyField(pointLimit);
                EditorGUILayout.PropertyField(minProjection);
                EditorGUILayout.PropertyField(rebuildSteps);
            }
        }
Esempio n. 4
0
        protected void DrawProtectedProperties(PointCloudRenderer obj)
        {
            EditorGUILayout.PropertyField(Colorize);
            EditorGUILayout.PropertyField(Render);

            // Use existing SerializedProperty property to remember foldout state
            Render.isExpanded = EditorGUILayout.Foldout(Render.isExpanded, "Settings");
            if (Render.isExpanded)
            {
                EditorGUI.indentLevel++;
                if (obj.Render == PointCloudRenderer.RenderType.Points)
                {
                    EditorGUILayout.PropertyField(ConstantSize);
                    if (obj.ConstantSize)
                    {
                        EditorGUILayout.PropertyField(PixelSize);
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(AbsoluteSize);
                        EditorGUILayout.PropertyField(MinPixelSize);
                    }
                }
                else if (obj.Render == PointCloudRenderer.RenderType.Solid)
                {
                    EditorGUILayout.PropertyField(SolidRender);
                    DrawRemoveHiddenCascadesContent();
                    DrawSmoothNormalsCascadesContent();
                    DrawFovReprojectionContent(obj.SolidFovReprojection);
                    DrawTemporalSmoothingContent(obj.TemporalSmoothing);

                    // Use existing SerializedProperty property to remember foldout state
                    SolidRender.isExpanded = EditorGUILayout.Foldout(SolidRender.isExpanded, "Debug");
                    if (SolidRender.isExpanded)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(DebugSolidBlitLevel, Styles.DebugSolidBlitLevelContent);
                        EditorGUILayout.PropertyField(SolidRemoveHidden, Styles.DebugSolidRemoveHiddenContent);
                        EditorGUILayout.PropertyField(DebugSolidPullPush, Styles.DebugSolidPullPushContent);
                        EditorGUILayout.PropertyField(DebugSolidFixedLevel, Styles.DebugSolidFixedLevelContent);
                        EditorGUILayout.PropertyField(DebugSolidPullParam, Styles.DebugSolidPullParamContent);
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel--;
            }
        }
        private void DrawNormalsContent(PointCloudRenderer editedObject)
        {
            var lineCount = 2;

            if (editedObject.CalculateNormals && editedObject.SmoothNormals)
            {
                lineCount += 4;
            }

            var rect        = CreateBox(lineCount);
            var indentLevel = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            EditorGUI.PropertyField(rect, CalculateNormals, Styles.CalculateNormalsContent);

            if (editedObject.CalculateNormals)
            {
                rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(rect, SmoothNormals, Styles.SmoothNormalsContent);

                if (editedObject.SmoothNormals)
                {
                    rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    EditorGUI.LabelField(rect, "Cascades (Smooth Normals)", EditorStyles.boldLabel);

                    rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    EditorGUI.PropertyField(rect, DebugShowSmoothNormalsCascades, Styles.CascadeShowPreviewContent);

                    rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    EditorGUI.PropertyField(rect, SmoothNormalsCascadeOffset, Styles.CascadeOffsetContent);

                    rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    EditorGUI.PropertyField(rect, SmoothNormalsCascadeSize, Styles.CascadeSizeContent);
                }
            }
            else
            {
                rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.LabelField(rect, "(required for lighting)");
            }

            EditorGUI.indentLevel = indentLevel;
        }
Esempio n. 6
0
        public OpenGlEngine()
        {
            Load   += OnLoad;
            Paint  += OnPaint;
            Resize += OnResize;

            _dispatcherTimer.Tick    += ThreadIdle;
            _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 13);

            Context.VSync = Vsync;
            _realCamera   = new Camera {
                Pan = 40, Yaw = -40, Z = 300, X = 0, Y = 0, Roll = 0
            };

            _objectRenderer     = new ObjectNormalRenderer();
            _gridRenderer       = new GridRenderer();
            _pointCloudRenderer = new PointCloudRenderer();

            _dispatcherTimer.Start();
        }
Esempio n. 7
0
        public override IEnumerator RunJob()
        {
            Debug.Log("*************************** CoroutineJobFreeMap ***************************");

            if (pcr.ContainsKey(id))
            {
                int handle = pcr[id].handle;

                Task <int> t0 = Task.Run(() =>
                {
                    return(Immersal.Core.FreeMap(handle));
                });

                while (!t0.IsCompleted)
                {
                    yield return(null);
                }

                PointCloudRenderer p = pcr[id];
                p.ClearCloud();
                pcr.Remove(id);
            }
        }
Esempio n. 8
0
        public override IEnumerator RunJob()
        {
            Debug.Log("*************************** CoroutineJobLoadMap ***************************");

            BaseMapper    mapper = host as BaseMapper;
            SDKMapRequest r      = new SDKMapRequest();

            r.token = mapper.token;
            r.id    = this.id;

            string jsonString2 = JsonUtility.ToJson(r);

            using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, mapper.server, Endpoint.LOAD_MAP), jsonString2))
            {
                request.method          = UnityWebRequest.kHttpVerbPOST;
                request.useHttpContinue = false;
                request.SetRequestHeader("Content-Type", "application/json");
                request.SetRequestHeader("Accept", "application/json");
                yield return(request.SendWebRequest());

                //Debug.Log("Response code: " + request.responseCode);

                if (request.isNetworkError || request.isHttpError)
                {
                    Debug.LogError(request.error);
                }
                else if (request.responseCode == (long)HttpStatusCode.OK)
                {
                    SDKMapResult result = JsonUtility.FromJson <SDKMapResult>(request.downloadHandler.text);
                    if (result.error == "none")
                    {
                        byte[] mapData = Convert.FromBase64String(result.b64);
                        Debug.Log("Load map " + this.id + " (" + mapData.Length + " bytes) (" + MD5(mapData) + "/" + result.md5_al + ")");

                        uint      countMax     = 16 * 1024;
                        Vector3[] vector3Array = new Vector3[countMax];

                        Task <int> t0 = Task.Run(() =>
                        {
                            return(Immersal.Core.LoadMap(mapData));
                        });

                        while (!t0.IsCompleted)
                        {
                            yield return(null);
                        }

                        int mapId = t0.Result;

                        Debug.Log("mapId " + mapId);

                        Task <int> t1 = Task.Run(() =>
                        {
                            return(Immersal.Core.GetPointCloud(mapId, vector3Array));
                        });

                        while (!t1.IsCompleted)
                        {
                            yield return(null);
                        }

                        int num = t1.Result;

                        Debug.Log("map points: " + num);

                        PointCloudRenderer renderer = go.AddComponent <PointCloudRenderer>();
                        renderer.CreateCloud(vector3Array, num);
                        renderer.mapId = mapId;
                        if (!mapper.pcr.ContainsKey(id))
                        {
                            mapper.pcr.Add(id, renderer);
                        }

                        mapper.stats.locFail = 0;
                        mapper.stats.locSucc = 0;

                        VisualizeManager.loadJobs.Remove(mapId);
                    }
                }
            }
        }
        protected void DrawProtectedProperties(PointCloudRenderer obj)
        {
            EditorGUILayout.PropertyField(Colorize);
            EditorGUILayout.PropertyField(Render);
            EditorGUILayout.PropertyField(Mask);

            // Use existing SerializedProperty property to remember foldout state
            Render.isExpanded = EditorGUILayout.Foldout(Render.isExpanded, "Rendering Settings");
            if (Render.isExpanded)
            {
                EditorGUI.indentLevel++;

                switch (obj.RenderMode)
                {
                case PointCloudRenderer.RenderType.Points:
                case PointCloudRenderer.RenderType.Cones:
                {
                    DrawShadowsContent((obj.Mask & PointCloudRenderer.RenderMask.Shadowcaster) != 0);
                    EditorGUILayout.PropertyField(ConstantSize);
                    if (obj.ConstantSize)
                    {
                        EditorGUILayout.PropertyField(PixelSize);
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(AbsoluteSize);
                        EditorGUILayout.PropertyField(MinPixelSize);
                    }
                    break;
                }

                case PointCloudRenderer.RenderType.Solid:
                {
                    DrawLightingContent();
                    EditorGUILayout.PropertyField(HprMode, Styles.HprModeContent);
                    DrawShadowsContent((obj.Mask & PointCloudRenderer.RenderMask.Shadowcaster) != 0);
                    DrawRemoveHiddenContent();
                    DrawNormalsContent(obj);
                    DrawFovReprojectionContent(obj.SolidFovReprojection);
                    DrawTemporalSmoothingContent(obj.TemporalSmoothing);

                    // Use existing SerializedProperty property to remember foldout state
                    DebugSolidBlitLevel.isExpanded = EditorGUILayout.Foldout(DebugSolidBlitLevel.isExpanded, "Debug");
                    if (DebugSolidBlitLevel.isExpanded)
                    {
                        EditorGUI.indentLevel++;
                        DrawForcedFillContent();
                        EditorGUILayout.PropertyField(DebugBlendSky, Styles.DebugBlendSkyContent);
                        EditorGUILayout.PropertyField(DebugSolidBlitLevel, Styles.DebugSolidBlitLevelContent);
                        EditorGUILayout.PropertyField(SolidRemoveHidden, Styles.DebugSolidRemoveHiddenContent);
                        EditorGUILayout.PropertyField(DebugSolidPullPush, Styles.DebugSolidPullPushContent);
                        EditorGUILayout.PropertyField(DebugSolidFixedLevel, Styles.DebugSolidFixedLevelContent);
                        EditorGUILayout.PropertyField(DebugSolidPullParam, Styles.DebugSolidPullParamContent);
                        EditorGUI.indentLevel--;
                    }

                    break;
                }
                }
                EditorGUI.indentLevel--;
            }
        }
 protected virtual void DrawInspector(PointCloudRenderer obj)
 {
     DrawProtectedProperties(obj);
 }
 void Start()
 {
     pointCloudRenderer = GetComponent <PointCloudRenderer>();
 }
Esempio n. 12
0
 protected override void DrawInspector(PointCloudRenderer obj)
 {
     EditorGUILayout.PropertyField(RenderCamera);
     DrawProtectedProperties(obj);
 }
Esempio n. 13
0
		public override IEnumerator RunJob()
		{
			Debug.Log("*************************** CoroutineJobLoadMap ***************************");
			SDKMapRequest r = new SDKMapRequest();
			r.token = this.token;
			r.id = this.id;

			string jsonString2 = JsonUtility.ToJson(r);
			using (UnityWebRequest request = UnityWebRequest.Put(string.Format(URL_FORMAT, this.server, "3"), jsonString2))
			{
				request.method = UnityWebRequest.kHttpVerbPOST;
				request.useHttpContinue = false;
				request.SetRequestHeader("Content-Type", "application/json");
				request.SetRequestHeader("Accept", "application/json");
				yield return request.SendWebRequest();

				//Debug.Log("Response code: " + request.responseCode);

				if (request.isNetworkError || request.isHttpError)
				{
					Debug.Log(request.error);
				}
				else if (request.responseCode == (long)HttpStatusCode.OK)
				{
					SDKMapResult result = JsonUtility.FromJson<SDKMapResult>(request.downloadHandler.text);
					if (result.error == "none")
					{

						byte[] mapData = Convert.FromBase64String(result.b64);
						Debug.Log("Load map " + this.id + " (" + mapData.Length + " bytes)");

						uint countMax = 16*1024;
						Vector3[] vector3Array = new Vector3[countMax];

                        Task<int> t0 = Task.Run(() =>
                        {
                            return Immersal.Core.LoadMap(mapData);
                        });
                         
                        while (!t0.IsCompleted)
                        {
                            yield return null;
                        }

                        int handle = t0.Result;

                        Debug.Log("handle " + handle);

                        Task<int> t1 = Task.Run(() =>
                        {
                            return Immersal.Core.GetPointCloud(handle, vector3Array);
                        });

                        while (!t1.IsCompleted)
                        {
                            yield return null;
                        }

                        int num = t1.Result;

						Debug.Log("map points: " + num);

						PointCloudRenderer renderer = go.AddComponent<PointCloudRenderer>();
						renderer.CreateCloud(vector3Array, num);
						renderer.handle = handle;
						pcr.Add(id, renderer);

                        stats.locFail = 0;
						stats.locSucc = 0;
					}
				}
			}

		}
Esempio n. 14
0
 protected virtual void DrawInspector(PointCloudRenderer obj)
 {
     EditorGUILayout.PropertyField(PointCloudData);
     DrawProtectedProperties(obj);
 }
Esempio n. 15
0
        protected void DrawProtectedProperties(PointCloudRenderer obj)
        {
            if (!Application.isPlaying)
            {
                EditorGUILayout.HelpBox("Only preview is currently displayed. Enter play mode to see actual output.",
                                        MessageType.Info);
            }

            EditorGUILayout.PropertyField(Colorize);
            EditorGUILayout.PropertyField(Render);
            EditorGUILayout.PropertyField(Mask);

            // Use existing SerializedProperty property to remember foldout state
            Render.isExpanded = EditorGUILayout.Foldout(Render.isExpanded, "Rendering Settings");
            if (Render.isExpanded)
            {
                EditorGUI.indentLevel++;
                DrawShadowsContent((obj.Mask & PointCloudRenderer.RenderMask.Shadows) != 0);

                switch (obj.RenderMode)
                {
                case PointCloudRenderer.RenderType.Points:
                case PointCloudRenderer.RenderType.Cones:
                {
                    EditorGUILayout.PropertyField(ConstantSize);
                    if (obj.ConstantSize)
                    {
                        EditorGUILayout.PropertyField(PixelSize);
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(AbsoluteSize);
                        EditorGUILayout.PropertyField(MinPixelSize);
                    }
                    // EditorGUILayout.PropertyField(PartialPointLighting, Styles.PartialPointLightingContent);
                    break;
                }

                case PointCloudRenderer.RenderType.Solid:
                {
                    DrawRemoveHiddenCascadesContent();
                    DrawNormalsContent(obj);
                    DrawFovReprojectionContent(obj.SolidFovReprojection);
                    DrawTemporalSmoothingContent(obj.TemporalSmoothing);

                    // Use existing SerializedProperty property to remember foldout state
                    DebugSolidBlitLevel.isExpanded = EditorGUILayout.Foldout(DebugSolidBlitLevel.isExpanded, "Debug");
                    if (DebugSolidBlitLevel.isExpanded)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(DebugUseLinearDepth, Styles.DebugUseLinearDepthContent);
                        EditorGUILayout.PropertyField(DebugForceFill, Styles.DebugForceFillContent);
                        EditorGUILayout.PropertyField(DebugFillThreshold, Styles.DebugFillThresholdContent);
                        EditorGUILayout.PropertyField(DebugBlendSky, Styles.DebugBlendSkyContent);
                        EditorGUILayout.PropertyField(DebugSolidBlitLevel, Styles.DebugSolidBlitLevelContent);
                        EditorGUILayout.PropertyField(SolidRemoveHidden, Styles.DebugSolidRemoveHiddenContent);
                        EditorGUILayout.PropertyField(DebugSolidPullPush, Styles.DebugSolidPullPushContent);
                        EditorGUILayout.PropertyField(DebugSolidFixedLevel, Styles.DebugSolidFixedLevelContent);
                        EditorGUILayout.PropertyField(DebugSolidPullParam, Styles.DebugSolidPullParamContent);
                        EditorGUI.indentLevel--;
                    }

                    break;
                }
                }
                EditorGUI.indentLevel--;
            }
        }