Exemplo n.º 1
0
        public UIInput(UIHelper.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;
        }
Exemplo n.º 2
0
        // Init is called on startup.
        public override void Init()
        {
            if (_canvasRenderMode == CanvasRenderMode.Screen)
            {
                UIHelper.CanvasWidthInit  = Width / 100f;
                UIHelper.CanvasHeightInit = Height / 100f;
            }
            else
            {
                UIHelper.CanvasHeightInit = 16;
                UIHelper.CanvasWidthInit  = 9;
            }

            _canvasHeight = UIHelper.CanvasHeightInit;
            _canvasWidth  = UIHelper.CanvasWidthInit;

            _uiInput = new List <UIInput>();

            _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 float2(middle.x, middle.y);
                float2 circleCanvasPosCache = new float2(0, 0);

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

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

                UIInput input = new UIInput(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);
        }