A material for a ModelMesh. This defines visual characteristics of the mesh.
Ejemplo n.º 1
0
 public ModelPart(Primitive primitive, int offset, int count, ModelMaterial material)
 {
     this.primitive = primitive;
     this.offset    = offset;
     this.count     = count;
     this.material  = material;
 }
Ejemplo n.º 2
0
        public void Draw(Program program, ref Matrix4d world, SetWorldMatrixCallback setWorldMatrix, IModelMaterialBinder materialBinder)
        {
            ModelMaterial material = null;

            foreach (ModelMesh mesh in meshes)
            {
                if (setWorldMatrix != null)
                {
                    Matrix4d meshWorld;

                    if (mesh.bone != null)
                    {
                        mesh.bone.GetWorldTransform(out meshWorld);
                        world.Multiply(ref meshWorld, out meshWorld);
                        setWorldMatrix.Invoke(ref meshWorld);
                    }
                }

                foreach (ModelPart part in mesh.parts)
                {
                    if (part.Material != null && part.Material != material && materialBinder != null)
                    {
                        material = part.Material;
                        materialBinder.BindMaterial(part.Material);
                    }

                    program.Draw(part.Primitive, part.Count, elementBuffer, elementType, part.Offset);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>Finish a part of the current mesh of the model.</summary>
        /// <param name="primitive"></param>
        /// <param name="material"></param>
        /// <returns></returns>
        public ModelPart FinishPart(Primitive primitive, ModelMaterial material)
        {
            int myFirstIndex = firstIndex;

            if (meshes.Count == 0)
            {
                FinishMesh(null);
            }
            ModelPart part = new ModelPart(primitive, myFirstIndex * 4, indexCount - myFirstIndex, material);

            firstIndex = indexCount;
            meshes[meshes.Count - 1].Parts.Add(part);
            return(part);
        }
Ejemplo n.º 4
0
 public void BindMaterial(ModelMaterial material)
 {
     AmbientLight = material.AmbientColor;
     DiffuseColor = new Vector4d(material.DiffuseColor, material.Opacity);
     DiffuseMap   = material.DiffuseTexture;
 }
 public ProceduralParameters SetMaterial(ModelMaterial value)
 {
     Material = value; return this;
 }
Ejemplo n.º 6
0
 public ProceduralParameters SetMaterial(ModelMaterial value)
 {
     Material = value; return(this);
 }
Ejemplo n.º 7
0
 public void BindMaterial(ModelMaterial material)
 {
     AmbientLight = material.AmbientColor;
     DiffuseColor = new Vector4d(material.DiffuseColor, material.Opacity);
     DiffuseMap = material.DiffuseTexture;
 }