Example #1
0
    void Awake()
    {
        // Check PS Eye number
        try {
            int psEyeCount = PSEyeTexture.CLEyeGetCameraCount();
            switch (psEyeCount)
            {
            case 0:
                Debug.LogError("No PS Eye found");
                return;

            case 1:
                Debug.LogError("Only one PS Eye found");
                return;
            }
        } catch (Exception e) {
            Debug.LogError("Oops..., Failed at loading CLEyeMulticam.dll. Please relaunch Unity!");
            Debug.LogError(e.ToString());
            return;
        }

        // Make PS Eye texture
        var PsEyeTexture = new PSEyeTexture(PsEyeId, FrameRate, true);

        psEye_ = new NyARUnityPSEye(PsEyeTexture);

        // Marker system
        var config = new NyARMarkerSystemConfig(PsEyeTexture.Width, PsEyeTexture.Height);

        markerSystem_ = new NyARUnityMarkerSystem(config);

        // Load marker from texture
        var markerTexture = (Texture2D)(Resources.Load(MarkerName, typeof(Texture2D)));

        markerId_ = markerSystem_.addARMarker(markerTexture, 16, 25, 80);

        // Marker layer
        MarkerObject.layer = Layer;
        for (int i = 0; i < MarkerObject.transform.GetChildCount(); ++i)
        {
            MarkerObject.transform.GetChild(i).gameObject.layer = Layer;
        }

        // Set camera background
        Background.renderer.material.mainTexture = PsEyeTexture.Texture;
        Background.layer      = Layer;
        ARCamera.cullingMask &= ~(1 << HiddenLayer);
        markerSystem_.setARBackgroundTransform(Background.transform);
        markerSystem_.setARCameraProjection(ARCamera);
    }
Example #2
0
    void Awake()
    {
        WebCamDevice[] devices = WebCamTexture.devices;
        if (devices.Length <= 0)
        {
            Debug.LogError("No Webcam.");
            return;
        }

        WebCamTexture w = new WebCamTexture(320, 240, 15);

        _ss = NyARUnityWebCam.createInstance(w);
        NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(_ss.width, _ss.height);

        _ms = new NyARUnityMarkerSystem(config);
        mid = _ms.addARMarker(
            new MemoryStream(((TextAsset)Resources.Load("patt_hiro", typeof(TextAsset))).bytes),
            16, 25, 80);
        _bg_panel = GameObject.Find("Plane");
        _bg_panel.GetComponent <Renderer>().material.mainTexture = w;
        _ms.setARBackgroundTransform(_bg_panel.transform);
        _ms.setARCameraProjection(GetComponent <Camera>());
    }