本文整理汇总了C#中Material.Default方法的典型用法代码示例。如果您正苦于以下问题:C# Material.Default方法的具体用法?C# Material.Default怎么用?C# Material.Default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Material
的用法示例。
在下文中一共展示了Material.Default方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddModelMesh
/// <summary>
/// Adds a Mesh to the ModelObjects List
/// </summary>
protected virtual void AddModelMesh (Mesh mesh, ObjectAttributes attr)
{
//Add this to the list of all the meshes
if (AllMeshes == null)
AllMeshes = new RhinoList<Mesh> ();
AllMeshes.Add (mesh);
Material material = new Material ();
int materialIndex = -1;
switch (attr.MaterialSource) {
case (ObjectMaterialSource.MaterialFromLayer):
if (attr.LayerIndex >= 0 && attr.LayerIndex < ModelFile.Layers.Count)
materialIndex = ModelFile.Layers [attr.LayerIndex].RenderMaterialIndex;
break;
case (ObjectMaterialSource.MaterialFromObject):
materialIndex = attr.MaterialIndex;
break;
case (ObjectMaterialSource.MaterialFromParent):
materialIndex = attr.MaterialIndex;
break;
}
if (materialIndex < 0 || materialIndex >= ModelFile.Materials.Count) {
materialIndex = -1;
material.Default ();
} else {
material = ModelFile.Materials [materialIndex];
}
object[] displayMeshes = DisplayMesh.CreateWithMesh (mesh, attr, material, materialIndex);
if (displayMeshes != null) {
var modelMesh = new ModelMesh (displayMeshes, attr.ObjectId);
AddModelObject (modelMesh, attr);
}
}
示例2: AddModelObject
/// <summary>
/// Adds a ModelObject to the ModelObjects List
/// </summary>
protected virtual void AddModelObject (ModelObject obj, ObjectAttributes attr)
{
if (obj != null) {
Material material = new Material ();
int materialIndex = -1;
switch (attr.MaterialSource) {
case (ObjectMaterialSource.MaterialFromLayer):
if (attr.LayerIndex >= 0 && attr.LayerIndex < ModelFile.Layers.Count)
materialIndex = ModelFile.Layers [attr.LayerIndex].RenderMaterialIndex;
break;
case (ObjectMaterialSource.MaterialFromObject):
materialIndex = attr.MaterialIndex;
break;
case (ObjectMaterialSource.MaterialFromParent):
materialIndex = attr.MaterialIndex;
break;
}
if (materialIndex < 0 || materialIndex >= ModelFile.Materials.Count) {
materialIndex = -1;
material.Default ();
} else {
material = ModelFile.Materials [materialIndex];
}
obj.Material = material;
obj.LayerIndex = attr.LayerIndex;
obj.Visible = attr.Visible;
ModelObjectsDictionary.Add (obj.ObjectId, obj);
// If the object is not an instance object, add it to the ModelObjects list
if (attr.Mode != ObjectMode.InstanceDefinitionObject)
ModelObjects.Add (obj);
}
}