예제 #1
0
        public UserInterfaceInput(UserInterfaceHelper.AnnotationKind annotationKind, float3 pos, float2 size, string segRes, float probability)
        {
            Position          = pos;
            Size              = size;
            AffectedTriangles = new List <int>();
            SegmentationClass = segRes;
            Probability       = probability;
            IsVisible         = false;
            AnnotationKind    = annotationKind;

            CircleCanvasPos      = new float2();
            CircleCanvasPosCache = new float2();
            AnnotationCanvasPos  = new float2();

            Identifier = -1;
        }
예제 #2
0
        // Init is called on startup.
        public override void Init()
        {
            if (_canvasRenderMode == CanvasRenderMode.Screen)
            {
                UserInterfaceHelper.CanvasWidthInit  = Width / 100f;
                UserInterfaceHelper.CanvasHeightInit = Height / 100f;
            }
            else
            {
                UserInterfaceHelper.CanvasHeightInit = 16;
                UserInterfaceHelper.CanvasWidthInit  = 9;
            }

            _canvasHeight = UserInterfaceHelper.CanvasHeightInit;
            _canvasWidth  = UserInterfaceHelper.CanvasWidthInit;

            _uiInput = new List <UserInterfaceInput>();

            _initWidth  = Width;
            _initHeight = Height;

            //_scene = BuildScene();
            _scene = AssetStorage.Get <SceneContainer>("Monkey.fus");

            var monkey = _scene.Children[0].GetComponent <Mesh>();

            // Check if rnd was injected (render tests inject a seeded random)
            if (rnd == null)
            {
                rnd = new Random();
            }

            var numberOfTriangles = monkey.Triangles.Length / 3;

            //Create dummy positions on model
            for (int i = 0; i < NumberOfAnnotations; i++)
            {
                int triangleNumber = rnd.Next(1, numberOfTriangles);
                int triIndex       = (triangleNumber - 1) * 3;

                float3 triVert0 = monkey.Vertices[monkey.Triangles[triIndex]];
                float3 triVert1 = monkey.Vertices[monkey.Triangles[triIndex + 1]];
                float3 triVert2 = monkey.Vertices[monkey.Triangles[triIndex + 2]];

                float3 middle = (triVert0 + triVert1 + triVert2) / 3;

                float2 circleCanvasPos      = new(middle.x, middle.y);
                float2 circleCanvasPosCache = new(0, 0);

                float prob = (float)rnd.NextDouble();
                prob = (float)System.Math.Round(prob, 3);
                string dummyClass = UserInterfaceHelper.DummySegmentationClasses[rnd.Next(0, UserInterfaceHelper.DummySegmentationClasses.Count - 1)];

                UserInterfaceHelper.AnnotationKind annotationKind = (UserInterfaceHelper.AnnotationKind)rnd.Next(0, Enum.GetNames(typeof(UserInterfaceHelper.AnnotationKind)).Length);

                UserInterfaceInput input = new(annotationKind, middle, new float2(0.65f, 0.65f), dummyClass, prob)
                {
                    Identifier           = i,
                    CircleCanvasPos      = circleCanvasPos,
                    CircleCanvasPosCache = circleCanvasPosCache
                };

                input.AffectedTriangles.Add(triIndex);
                _uiInput.Add(input);
            }

            _gui = CreateGui();


            // Create the interaction handler
            _sih = new SceneInteractionHandler(_gui);

            //Create a scene picker for performing visibility tests
            _scenePicker = new ScenePicker(_scene);

            // Set the clear color for the back buffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(0.1f, 0.1f, 0.1f, 1);

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRendererForward(_scene);
            _guiRenderer   = new SceneRendererForward(_gui);
        }