UrhoLens Primitives model color has no effect

raedbenzraedbenz USMember

Hello,
i am creating a model from scratch using primitives API using UrhoSharp 1.3 and applying the color has no effect, unless i use SetMaterial(Material.FromColor(Color.Green)).
In the below example i am expecting a red triangle but i get a gray one.

Node node = Scene.CreateChild(); node.SetScale(0.5f); StaticModel model = node.CreateComponent<StaticModel>(); model.Model = Triangle(); //model.SetMaterial(Material.FromColor(Color.Green))

private Model Triangle()
{
    PositionNormalColor[] vertexData =
    {
        new PositionNormalColor() {Color = Color.Red.ToUInt(), Position=new Vector3(-0.5f, 0.5f, 0.0f), Normal = new Vector3() },
        new PositionNormalColor() {Color = Color.Red.ToUInt(), Position=new Vector3(0.5f, 0.5f, 0.0f), Normal = new Vector3() },
        new PositionNormalColor() {Color = Color.Red.ToUInt(), Position=new Vector3(0.0f, -0.5f, 0.0f), Normal = new Vector3() },
    };

    uint numVertices = (uint)vertexData.Length;
    short[] indexData = { 0, 1, 2 };

    Model fromScratchModel = new Model();
    VertexBuffer vb = new VertexBuffer(Context, false);
    IndexBuffer ib = new IndexBuffer(Context, false);
    Geometry geom = new Geometry();

    vb.Shadowed = false;
    vb.SetSize(numVertices, ElementMask.Position | ElementMask.Normal | ElementMask.Color, false);
    vb.SetData(vertexData);

    ib.Shadowed = true;
    ib.SetSize(numVertices, false, false);
    ib.SetData(indexData);

    geom.SetVertexBuffer(0, vb);
    geom.IndexBuffer = ib;
    geom.SetDrawRange(PrimitiveType.TriangleList, 0, numVertices, true);

    fromScratchModel.NumGeometries = 1;
    fromScratchModel.SetGeometry(0, 0, geom);
    fromScratchModel.BoundingBox = new BoundingBox(0.0f, 0.5f);

    return fromScratchModel;
}
Sign In or Register to comment.