示例#1
0
    void Awake()
    {
        //setup unity webcam
        WebCamDevice[] devices = WebCamTexture.devices;
        if (devices.Length <= 0)
        {
            UnityEngine.Debug.LogError("No Webcam.");
            return;
        }
        WebCamTexture w = new WebCamTexture(640, 480, 30);

        //Make WebcamTexture wrapped Sensor.
        this._ss = NyARUnityWebCam.createInstance(w);
        //Make configulation by Sensor size.
        NyARNftSystemConfig config = new NyARNftSystemConfig(
            new MemoryStream(((TextAsset)Resources.Load("camera_para5", typeof(TextAsset))).bytes),
            this._ss.width, this._ss.height);

        this._ns = new NyARUnityNftSystem(config);
        //This line loads a marker from texture
        mid = this._ns.addNftTarget(new MemoryStream(((TextAsset)Resources.Load("infinitycat", typeof(TextAsset))).bytes), 160);

        //setup background
        this._bg_panel = GameObject.Find("Plane");
        this._bg_panel.GetComponent <Renderer>().material.mainTexture = w;
        this._ns.setARBackgroundTransform(this._bg_panel.transform);

        //setup camera projection
        this._ns.setARCameraProjection(this.GetComponent <Camera>());
        return;
    }
示例#2
0
            public override void setup(CaptureDevice i_cap)
            {
                Device d3d = this.size(SCREEN_WIDTH, SCREEN_HEIGHT);

                i_cap.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30.0f);
                INyARNftSystemConfig cf = new NyARNftSystemConfig(File.OpenRead(cparam_file), SCREEN_WIDTH, SCREEN_HEIGHT);

                d3d.RenderState.ZBufferEnable = true;
                d3d.RenderState.Lighting      = false;
                d3d.RenderState.CullMode      = Cull.CounterClockwise;
                this._ms = new NyARD3dNftSystem(cf);
                this._ss = new NyARDirectShowCamera(i_cap);
                this._rs = new NyARD3dRender(d3d, this._ms);
                this.mid = this._ms.addNftTarget(fset3file, 160);

                //set View mmatrix
                this._rs.loadARViewMatrix(d3d);
                //set Viewport matrix
                this._rs.loadARViewPort(d3d);
                //setD3dProjectionMatrix
                this._rs.loadARProjectionMatrix(d3d);
                this._ss.start();
            }