// Start is called before the first frame update
    void Awake()
    {
        generator = GetComponent <AnnotationGenerator>();
        if (!generator)
        {
            Debug.LogError("NO GENERATOR ?!?!?!?!?!?");
        }

        switch (settingsSelected)
        {
        case Type.Excluding:
            AddAnnotationObjects(ExcludeObjects());
            break;

        case Type.Including:
            AddAnnotationObjects(IncludeObjects());
            break;

        default:
            break;
        }
        selectedObjects.Clear(); //Resets anyway when quits

        enabled = false;
    }
Esempio n. 2
0
 /// <summary>
 /// Start will execute when the annotation generator property is already initialized.
 /// </summary>
 public void Initialize(AnnotationGenerator generator)
 {
     if (!generator)
     {
         Debug.LogError("There was no reference to the annotation generator");
     }
     Generator = generator;
     Start();
     Log("Initialized");
 }
Esempio n. 3
0
 public void Initialize(AnnotationGenerator generator)
 {
     if (cameraObject)
     {
         if (cameraObject.TryGetComponent(out Camera _) && cameraObject.TryGetComponent(out AnnotationCamera _))
         {
             GameObject newCamera = Instantiate(cameraObject, generator.transform);
             Camera = newCamera.GetComponent <AnnotationCamera>();
         }
         else
         {
             Debug.LogError("Given camera does not match the requirements");
         }
     }
Esempio n. 4
0
    public void Initialize(AnnotationGenerator generator)
    {
        this.generator = generator;

        AnnotationCamera outputCamera = generator.OutputCamera;
        //Instantiate segmentation camera
        GameObject segmentationGameObject = Instantiate(outputCamera.gameObject, gameObject.transform);

        segmentationGameObject.name = "SegmentationCam";
        segmentationGameObject.transform.position = outputCamera.transform.position;
        segmentationGameObject.transform.rotation = outputCamera.transform.rotation;

        Camera = segmentationGameObject.GetComponent <AnnotationCamera>();
        Camera.Component.clearFlags      = CameraClearFlags.SolidColor;
        Camera.Component.backgroundColor = Color.clear;
        Camera.Component.renderingPath   = RenderingPath.Forward;
        Camera.Component.allowMSAA       = false;

        RenderTextureDescriptor descriptor = outputCamera.Component.targetTexture.descriptor; //Dimensions

        descriptor.bindMS              = false;
        descriptor.msaaSamples         = 1;
        Camera.Component.targetTexture = new RenderTexture(descriptor); //Create new texture  using dimensions of output
        Camera.Component.targetTexture.antiAliasing = 1;

        Camera.Component.SetReplacementShader(segmentationShader, "");


        //Instantiate shader settings

        float width  = Camera.Component.targetTexture.width;
        float height = Camera.Component.targetTexture.height;

        threadGroupsX = Mathf.CeilToInt(width / 16);
        threadGroupsY = Mathf.CeilToInt(height / 16);

        pixelCountsVisibility = new ComputeBuffer(threadGroupsX * threadGroupsY, sizeof(uint)); //number of threads inside the shader

        int kernelHandle = pixelCountComputeShader.FindKernel("CSMain");

        pixelCountComputeShader.SetBuffer(kernelHandle, "countsVisibility", pixelCountsVisibility);
    }