本文整理匯總了C#中MinerWars.AppCode.Game.Entities.MyEntity.GetMaterial方法的典型用法代碼示例。如果您正苦於以下問題:C# MyEntity.GetMaterial方法的具體用法?C# MyEntity.GetMaterial怎麽用?C# MyEntity.GetMaterial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MinerWars.AppCode.Game.Entities.MyEntity
的用法示例。
在下文中一共展示了MyEntity.GetMaterial方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CollectRenderElements
public static void CollectRenderElements(List<MyRenderElement> renderElements, List<MyRenderElement> transparentRenderElements, MyEntity entity, MyModel model, bool collectTransparentElements)
{
// MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("LoadInDraw");
if (model.LoadState == LoadState.Unloaded)
{
//model.LoadInDraw(LoadingMode.Background);
model.LoadInDraw(LoadingMode.Immediate);
return;
}
if (model.LoadState == LoadState.Loading)
return;
// MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
var drawMatrix = entity.GetWorldMatrixForDraw();
int meshCount = model.GetMeshList().Count;
for (int i = 0; i < meshCount; i++)
{
MyMesh mesh = model.GetMeshList()[i];
// MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Add render element");
//if (mesh.Materials[entity.MaterialIndex].DrawTechnique == MyMeshDrawTechnique.DECAL ||
// mesh.Materials[entity.MaterialIndex].DrawTechnique == MyMeshDrawTechnique.HOLO)
// continue;
MyMeshMaterial material = entity.GetMaterial(mesh);
bool createElement = true;
if (createElement)
{
MyRenderElement renderElement;
AllocateRenderElement(out renderElement);
//renderElement.DebugName = entity.Name;
renderElement.Entity = entity;
renderElement.VertexBuffer = model.VertexBuffer;
renderElement.IndexBuffer = model.IndexBuffer;
renderElement.VertexCount = model.GetVerticesCount();
renderElement.VertexDeclaration = model.GetVertexDeclaration();
renderElement.VertexStride = model.GetVertexStride();
renderElement.IndexStart = mesh.IndexStart;
renderElement.TriCount = mesh.TriCount;
//renderElement.UseChannels = model.UseChannels;
//renderElement.MaskTexture = model.MaskTexture;
renderElement.WorldMatrixForDraw = drawMatrix;
renderElement.WorldMatrix = entity.WorldMatrix;
renderElement.Material = material;
renderElement.DrawTechnique = material.DrawTechnique;
renderElement.VoxelBatch = null;
Debug.Assert(renderElement.VertexBuffer != null, "Vertex buffer cannot be null!");
Debug.Assert(renderElement.IndexBuffer != null, "Index buffer cannot be null!");
if (material.DrawTechnique == MyMeshDrawTechnique.HOLO)
{
if (collectTransparentElements)
transparentRenderElements.Add(renderElement);
}
else
{
renderElements.Add(renderElement);
}
}
//MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
}
}