Ejemplo n.º 1
0
        /// <summary>
        /// 指定シーンフレームに進みます。
        /// </summary>
        public void FrameMoveDerived()
        {
            if (OpenNiEnabled && NiSimpleTracker.IsTracking())
            {
                OpenNiSolve();
            }
            if (MotionEnabled)
            {
                return;
            }

            if (solver.Solved)
            {
                return;
            }

            Figure fig;

            if (TryGetFigure(out fig))
            {
                if (current_effector_path == "|W_Hips")
                {
                    solver.SolveRootNode(fig.Tmo, current_effector_path);
                }
                else
                {
                    solver.Solve(fig.Tmo, current_effector_path, solver.Target);
                }
                fig.UpdateBoneMatricesWithoutTMOFrame();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// シーンをレンダリングします。
        /// </summary>
        public void RenderDerived()
        {
            if (OpenNiEnabled)
            {
                if (NiSimpleTracker.IsTracking())
                {
                    Vector4 color = new Vector4(1, 0, 0, 0.5f);
                    foreach (XnSkeletonJointPosition xnp in ni_joint_ary)
                    {
                        Vector3 p1  = ToWorldPosition(xnp.position);
                        Vector3 pos = p1 - ni_model_translation;
                        DrawMesh(sphere, Matrix.Translation(pos), color);
                    }
                }

                {
                    GraphicsStream gs = surface.LockRectangle(LockFlags.None);
                    NiSimpleTracker.DrawDepthMap();
                    IntPtr ptr = NiSimpleTracker.GetDepthBuf();
                    int    len = camw * camh * 4;
                    Marshal.Copy(ptr, surface_buf, 0, len);
                    Marshal.Copy(surface_buf, 0, gs.InternalData, len);
                    surface.UnlockRectangle();
                }

                Rectangle src_rect = new Rectangle(0, 0, camw, camh);

                //カメラ画像の転写矩形を作成
                Viewport  vp        = device.Viewport;
                Rectangle view_rect = new Rectangle(vp.X + vp.Width - vp.Width / 4, vp.Y, vp.Width / 4, vp.Height / 4);

                {
                    //背景描画
                    Surface dest_surface = device.GetBackBuffer(0, 0, BackBufferType.Mono);
                    device.StretchRectangle(surface, src_rect, dest_surface, view_rect, TextureFilter.None);
                }
            }
            if (MotionEnabled)
            {
                return;
            }

            DrawEffector();
            DrawTarget();
            DrawGrid();
        }