示例#1
0
        private void GLControl_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            if (start != FbxSDK.Time.Infinite())
            {
                curTime += oneFrame;
                if (curTime > stop)
                {
                    curTime = start;
                }
            }

            glControl.MakeCurrent();

            if (scene != null)
            {
                var selectedNode = nodeHierarchy.CurSelected;

                if (selectedNode != null)
                {
                    // Action to do when some node has been selected.
                }

                UpdateMeshInfos();
                UpdateBoneInfos();
            }

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            shader.Use();

            for (int i = 0; i < meshInfoList.Count; ++i)
            {
                GL.BindVertexArray(meshInfoList[i].vertexArray);

                Matrix4 mvp = meshInfoList[i].geometryToWorld * globalTrans * view * projection;

                shader.SetMatrix4Array("skinningTransforms", meshInfoList[i].boneTrasforms);

                shader.SetMatrix4("mvp", ref mvp);
                shader.SetColor("color", new Color4(1f, 1f, 1f, 1f));

                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                GL.DrawElements(BeginMode.Triangles, meshInfoList[i].polygonCount * 3, DrawElementsType.UnsignedInt, 0);

                mvp.M43 -= 0.001f;
                shader.SetMatrix4("mvp", ref mvp);
                shader.SetColor("color", new Color4(1f, 0f, 0f, 1f));
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                GL.DrawElements(BeginMode.Triangles, meshInfoList[i].polygonCount * 3, DrawElementsType.UnsignedInt, 0);
            }

            glControl.SwapBuffers();
        }
示例#2
0
        public void ShowScene(NodeHierarchy nodeHierarchy, FbxSDK.Scene scene)
        {
            this.scene         = scene;
            this.nodeHierarchy = nodeHierarchy;

            int animationCount = scene.GetAnimStackCount();

            for (int i = 0; i < animationCount; ++i)
            {
                var animStack = scene.GetAnimStack(i);
                animationList.Add(animStack);
            }

            oneFrame = new FbxSDK.Time(0, 0, 0, 1, scene.GetGlobalTimeMode());
            start    = stop = curTime = FbxSDK.Time.Infinite();

            if (animationList.Count > 0)
            {
                var timeSpan = scene.GetAnimTimelineTimeSpan(animationList[0]);
                start   = timeSpan.start;
                stop    = timeSpan.stop;
                curTime = start;
                scene.SetCurrentAnimStack(animationList[0]);

                for (int i = 0; i < animationList.Count; ++i)
                {
                    int    animationID     = i;
                    Button animationButton = new Button();
                    animationButton.Content = animationList[i].GetName();
                    animationButton.Click  += (a, b) =>
                    {
                        var span = scene.GetAnimTimelineTimeSpan(animationList[animationID]);
                        scene.SetCurrentAnimStack(animationList[animationID]);
                        start   = span.start;
                        stop    = span.stop;
                        curTime = start;
                    };
                    panel.Children.Add(animationButton);
                }
            }

            int poseCount = scene.GetPoseCount();

            for (int i = 0; i < poseCount; ++i)
            {
                poseList.Add(scene.GetPose(0));
            }

            if (poseList.Count > 0)
            {
                Button deselectPoseButton = new Button();
                deselectPoseButton.Content = "Deselect Pose";
                deselectPoseButton.Click  += (a, b) =>
                {
                    curPose = null;
                };
                panel.Children.Add(deselectPoseButton);

                for (int i = 0; i < poseCount; ++i)
                {
                    int    poseID     = i;
                    Button poseButton = new Button();
                    poseButton.Content = "Select Pose " + i;
                    poseButton.Click  += (a, b) =>
                    {
                        curPose = poseList[poseID];
                    };
                    panel.Children.Add(poseButton);
                }
            }
        }