Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 向上导出漫反射颜色,而不是顶点颜色,你上面发布的工作(非常感谢btw)。但我想最好的选择是下载另一个3D建模程序,它允许我添加顶点颜色(因为我在sketchup上找不到它)@Delta,没问题,很高兴它能工作:)我喜欢sketchup,但不久你可能需要更强_C#_3d_Xna_Hlsl_Sketchup - Fatal编程技术网

C# 向上导出漫反射颜色,而不是顶点颜色,你上面发布的工作(非常感谢btw)。但我想最好的选择是下载另一个3D建模程序,它允许我添加顶点颜色(因为我在sketchup上找不到它)@Delta,没问题,很高兴它能工作:)我喜欢sketchup,但不久你可能需要更强

C# 向上导出漫反射颜色,而不是顶点颜色,你上面发布的工作(非常感谢btw)。但我想最好的选择是下载另一个3D建模程序,它允许我添加顶点颜色(因为我在sketchup上找不到它)@Delta,没问题,很高兴它能工作:)我喜欢sketchup,但不久你可能需要更强,c#,3d,xna,hlsl,sketchup,C#,3d,Xna,Hlsl,Sketchup,向上导出漫反射颜色,而不是顶点颜色,你上面发布的工作(非常感谢btw)。但我想最好的选择是下载另一个3D建模程序,它允许我添加顶点颜色(因为我在sketchup上找不到它)@Delta,没问题,很高兴它能工作:)我喜欢sketchup,但不久你可能需要更强大的东西。请记住,在将来,如果您想使用着色器,但不需要特定模型的顶点颜色,您可以使用白色填充管道,因此,当您在着色器中乘以它时(通过漫反射和任何您希望支持的其他方式)它不会对最终颜色产生影响,并且不再需要另一个着色器排列(这是我使用着色器所做的


向上导出漫反射颜色,而不是顶点颜色,你上面发布的工作(非常感谢btw)。但我想最好的选择是下载另一个3D建模程序,它允许我添加顶点颜色(因为我在sketchup上找不到它)@Delta,没问题,很高兴它能工作:)我喜欢sketchup,但不久你可能需要更强大的东西。请记住,在将来,如果您想使用着色器,但不需要特定模型的顶点颜色,您可以使用白色填充管道,因此,当您在着色器中乘以它时(通过漫反射和任何您希望支持的其他方式)它不会对最终颜色产生影响,并且不再需要另一个着色器排列(这是我使用着色器所做的)
float4x4 World;
float4x4 View;
float4x4 Projection;

struct AppToVertex
{
    float4 Position : POSITION0;
    float4 Color    : COLOR0;
};

struct VertexToPixel
{
    float4 Position : POSITION0;
    float4 Color    : COLOR0;
};

VertexToPixel ColoredVS(AppToVertex input)
{
    VertexToPixel output = (VertexToPixel)0;

    float4 iTransformed = mul(input.Position, World);
    float4 iView = mul(iTransformed, View);
    float4 iProjection = mul(iView, Projection);

    output.Position = iProjection;
    output.Color = input.Color;

    return output;
}

float4 ColoredPS(VertexToPixel input) : COLOR
{
    return input.Color;
}

technique Colored
{
    pass Pass0
    {
        VertexShader = compile vs_2_0 ColoredVS();
        PixelShader = compile ps_2_0 ColoredPS();
    }
}
template Mesh {
<3D82AB44-62DA-11cf-AB39-0020AF71E433>
DWORD nVertices;
array Vector vertices[nVertices];
DWORD nFaces;
array MeshFace faces[nFaces];
[...]
}

template MeshVertexColors {
<1630B821-7842-11cf-8F52-0040333594A3>
DWORD nVertexColors;
array IndexedColor vertexColors[nVertexColors];
}
 template MeshMaterialList {
<F6F23F42-7686-11cf-8F52-0040333594A3>
DWORD nMaterials;
DWORD nFaceIndexes;
array DWORD faceIndexes[nFaceIndexes];
[Material]
}
[ContentProcessor(DisplayName = "Processor to make sure we have vertex colours in all models")]
public class Character_Model_Processor : ModelProcessor
{
    public override ModelContent Process(NodeContent input, ContentProcessorContext context)
    {
        foreach(NodeContent c in input.Children)
        {
            if(c is MeshContent)
            {
                foreach(GeometryContent g in (c as MeshContent).Geometry)
                {
                    //Stop here and check out the VertexContent object (g.Vertices) and the Channels member of it to see how
                    //vertex data is stored in the DOM, and what you can do with it.
                    System.Diagnostics.Debugger.Launch();

                    AddVertexColorChannel(g.Vertices);
                }
            }
        }

        ModelContent model = base.Process(input, context);

        return model;
    }

    private void AddVertexColorChannel(VertexContent content)
    {
        if(content.Channels.Contains(VertexChannelNames.Color(0)) == false)
        {
            List<Microsoft.Xna.Framework.Color> VertexColors = new List<Microsoft.Xna.Framework.Color>();

            for (int i = 0; i < content.VertexCount; i++)
            {
                VertexColors.Add(Color.Purple);
            }

            content.Channels.Add(VertexChannelNames.Color(0), VertexColors);
        }
    }
}