//メインループ処理 public void MainLoop() { //RealitySourceにデータが処理する。 if (!this._reality_source.isReady()) { return; } // 背景を書く try{ lock (this){ // 背景サーフェイスを直接描画 Surface dest_surface = this._device.GetBackBuffer(0, 0, BackBufferType.Mono); Rectangle src_dest_rect = new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); this._device.StretchRectangle((Surface)this._surface, src_dest_rect, dest_surface, src_dest_rect, TextureFilter.None); // 3Dオブジェクトの描画はここから this._device.BeginScene(); this._device.Clear(ClearFlags.ZBuffer, Color.DarkBlue, 1.0f, 0); //ターゲットリストを走査して、画面に内容を反映 NyARRealityTargetList tl = this._reality.refTargetList(); for (int i = tl.getLength() - 1; i >= 0; i--) { NyARRealityTarget t = tl.getItem(i); switch (t.getTargetType()) { case NyARRealityTarget.RT_KNOWN: //立方体を20mm上(マーカーの上)にずらしておく Matrix mat = new Matrix(); this._reality.getD3dModelViewMatrix(t.refTransformMatrix(), ref mat); Matrix transform_mat2 = Matrix.Translation(0, 0, 20.0f); transform_mat2 = transform_mat2 * mat; this._device.SetTransform(TransformType.World, transform_mat2); this._cube.draw(this._device); break; case NyARRealityTarget.RT_UNKNOWN: // break; } } // 描画はここまで this._device.EndScene(); // 実際のディスプレイに描画 this._device.Present(); } Thread.Sleep(1); // タスク実行権限を一旦渡す }catch (Exception e) { System.Console.WriteLine(e.StackTrace); } return; }
//メインループ処理 public void MainLoop() { //ARの計算 lock (this) { // 背景サーフェイスを直接描画 Surface dest_surface = this._device.GetBackBuffer(0, 0, BackBufferType.Mono); Rectangle src_dest_rect = new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); this._device.StretchRectangle((Surface)this._surface, src_dest_rect, dest_surface, src_dest_rect, TextureFilter.None); // 3Dオブジェクトの描画はここから this._device.BeginScene(); this._device.Clear(ClearFlags.ZBuffer, Color.DarkBlue, 1.0f, 0); //ターゲットリストを走査して、画面に内容を反映 NyARRealityTargetList tl = this._reality.refTargetList(); for (int i = tl.getLength() - 1; i >= 0; i--) { NyARRealityTarget t = tl.getItem(i); switch (t.getTargetType()) { case NyARRealityTarget.RT_KNOWN: //立方体を20mm上(マーカーの上)にずらしておく Matrix mat = new Matrix(); this._reality.getD3dModelViewMatrix(t.refTransformMatrix(), ref mat); Matrix transform_mat2 = Matrix.Translation(0, 0, 20.0f); transform_mat2 = transform_mat2 * mat; this._device.SetTransform(TransformType.World, transform_mat2); this._cube.draw(this._device); break; case NyARRealityTarget.RT_UNKNOWN: //NyARDoublePoint2d[] p = t.refTargetVertex(); //NyARGLDrawUtil.beginScreenCoordinateSystem(this._gl, SCREEN_X, SCREEN_Y, true); //NyARGLDrawUtil.endScreenCoordinateSystem(this._gl); break; } } // 描画はここまで this._device.EndScene(); // 実際のディスプレイに描画 this._device.Present(); } return; }
//メインループ処理 public void MainLoop() { //ARの計算 lock (this) { Device dev = this._d3dmgr.d3d_device; // 背景サーフェイスを直接描画 // 3Dオブジェクトの描画はここから dev.Clear(ClearFlags.ZBuffer, Color.DarkBlue, 1.0f, 0); dev.BeginScene(); this._back_ground.drawBackGround(this._d3dmgr.d3d_device); //ターゲットリストを走査して、画面に内容を反映 NyARRealityTargetList tl = this._reality.refTargetList(); for (int i = tl.getLength() - 1; i >= 0; i--) { NyARRealityTarget t = tl.getItem(i); switch (t.getTargetType()) { case NyARRealityTarget.RT_KNOWN: //立方体を20mm上(マーカーの上)にずらしておく Matrix mat = new Matrix(); this._reality.getD3dModelViewMatrix(t.refTransformMatrix(), ref mat); Matrix transform_mat2 = Matrix.Translation(0, 0, 20.0f); transform_mat2 = transform_mat2 * mat; dev.SetTransform(TransformType.World, transform_mat2); this._d3dcube.draw(dev); break; case NyARRealityTarget.RT_UNKNOWN: //NyARDoublePoint2d[] p = t.refTargetVertex(); //NyARGLDrawUtil.beginScreenCoordinateSystem(this._gl, SCREEN_X, SCREEN_Y, true); //NyARGLDrawUtil.endScreenCoordinateSystem(this._gl); break; } } // 描画はここまで dev.EndScene(); // 実際のディスプレイに描画 dev.Present(); } return; }