Exemplo n.º 1
0
        private void DrawSubMeshForWireFrame(Figure fig, TSOFile tso, TSOSubMesh sub_mesh)
        {
            device.SetRenderState(RenderStates.FillMode, (int)FillMode.WireFrame);
            //device.RenderState.VertexBlend = (VertexBlend)(4 - 1);
            device.SetStreamSource(0, sub_mesh.vb, 0, 52);

            tso.SwitchShader(sub_mesh);
            effect.SetValue(handle_LocalBoneMats, fig.ClipBoneMatrices(sub_mesh));

            int npass = effect.Begin(0);

            for (int ipass = 0; ipass < npass; ipass++)
            {
                effect.BeginPass(ipass);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, sub_mesh.vertices.Length - 2);
                effect.EndPass();
            }
            effect.End();
        }
Exemplo n.º 2
0
        private void DrawSubMeshForWeightHeating(Figure fig, TSOSubMesh sub_mesh)
        {
            device.SetRenderState(RenderStates.FillMode, (int)FillMode.Solid);
            //device.RenderState.VertexBlend = (VertexBlend)(4 - 1);
            device.SetStreamSource(0, sub_mesh.vb, 0, 52);

            effect.Technique = "BoneCol";
            effect.SetValue("PenColor", new Vector4(1, 1, 1, 1));
            effect.SetValue(handle_LocalBoneMats, fig.ClipBoneMatrices(sub_mesh));
            effect.SetValue(handle_LocalBoneSels, ClipBoneSelections(sub_mesh, selected_node));

            int npass = effect.Begin(0);

            for (int ipass = 0; ipass < npass; ipass++)
            {
                effect.BeginPass(ipass);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, sub_mesh.vertices.Length - 2);
                effect.EndPass();
            }
            effect.End();
        }
Exemplo n.º 3
0
        void DrawFigure(Figure fig)
        {
            LightDirForced_variable.Set(fig.LightDirForced());
            foreach (TSOFile tso in fig.TSOFileList)
            {
            int current_spec = -1;

            foreach (TSOMesh mesh in tso.meshes)
                foreach (TSOSubMesh sub_mesh in mesh.sub_meshes)
                {
                    TSOSubScript scr = tso.sub_scripts[sub_mesh.spec];

                    if (sub_mesh.spec != current_spec)
                    {
                        current_spec = sub_mesh.spec;

                        cb_variable.SetConstantBuffer(scr.cb);

                        TSOTex shadeTex;
                        if (tso.texmap.TryGetValue(scr.shader.ShadeTexName, out shadeTex))
                            ShadeTex_texture_variable.SetResource(shadeTex.d3d_tex_view);

                        TSOTex colorTex;
                        if (tso.texmap.TryGetValue(scr.shader.ColorTexName, out colorTex))
                            ColorTex_texture_variable.SetResource(colorTex.d3d_tex_view);
                    }

                    int technique_idx = scr.shader.technique_idx;

                    var technique = effect.GetTechniqueByIndex(technique_idx);
                    if (!technique.IsValid)
                    {
                        string technique_name = scr.shader.technique_name;
                        Console.WriteLine("technique {0} is not valid", technique_name);
                        continue;
                    }

                    LocalBoneMats_variable.SetMatrix(fig.ClipBoneMatrices(sub_mesh));

                    if (!technique.GetPassByIndex(0).IsValid)
                    {
                        Console.WriteLine("pass #0 is not valid");
                        continue;
                    }

                    ctx.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
                    ctx.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(sub_mesh.vb, 52, 0));

                    for (int i = 0; i < technique.Description.PassCount; i++)
                    {
                        ctx.OutputMerger.SetBlendState(default_blend_state);
                        ctx.OutputMerger.SetDepthStencilState(default_depth_stencil_state);
                        ctx.Rasterizer.State = default_rasterizer_state;

                        technique.GetPassByIndex(i).Apply(ctx);
                        ctx.Draw(sub_mesh.vertices.Length, 0);
                    }
                }
            }
        }