本文整理汇总了C#中Mesh.DrawSubset方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.DrawSubset方法的具体用法?C# Mesh.DrawSubset怎么用?C# Mesh.DrawSubset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.DrawSubset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderMesh
private void RenderMesh(Mesh mesh)
{
for (int i = 0; i < mesh.NumberAttributes; ++i) {
mesh.DrawSubset(i);
}
}
示例2: RenderSoftBodyTextured
public void RenderSoftBodyTextured(SoftBody softBody)
{
if (!(softBody.UserObject is Array))
return;
object[] userObjArr = softBody.UserObject as object[];
FloatArray vertexBuffer = userObjArr[0] as FloatArray;
IntArray indexBuffer = userObjArr[1] as IntArray;
int vertexCount = (vertexBuffer.Count / 8);
if (vertexCount > 0)
{
int faceCount = indexBuffer.Count / 2;
bool index32 = vertexCount > 65536;
Mesh mesh = new Mesh(device, faceCount, vertexCount,
MeshFlags.SystemMemory | (index32 ? MeshFlags.Use32Bit : 0),
VertexFormat.Position | VertexFormat.Normal | VertexFormat.Texture1);
DataStream indices = mesh.LockIndexBuffer(LockFlags.Discard);
if (index32)
{
foreach (int i in indexBuffer)
indices.Write(i);
}
else
{
foreach (int i in indexBuffer)
indices.Write((short)i);
}
mesh.UnlockIndexBuffer();
DataStream verts = mesh.LockVertexBuffer(LockFlags.Discard);
foreach (float f in vertexBuffer)
verts.Write(f);
mesh.UnlockVertexBuffer();
mesh.ComputeNormals();
mesh.DrawSubset(0);
mesh.Dispose();
}
}
示例3: RenderStaticPlaneShape
void RenderStaticPlaneShape(Mesh mesh)
{
Cull cullMode = device.GetRenderState<Cull>(RenderState.CullMode);
device.SetRenderState(RenderState.CullMode, Cull.None);
planeShader.Begin();
Matrix matrix = device.GetTransform(TransformState.World);
planeShader.SetValue("World", matrix);
matrix = device.GetTransform(TransformState.View) * device.GetTransform(TransformState.Projection);
planeShader.SetValue("ViewProjection", matrix);
planeShader.BeginPass(0);
mesh.DrawSubset(0);
planeShader.EndPass();
planeShader.End();
device.SetRenderState(RenderState.CullMode, cullMode);
}
示例4: DrawMesh
private void DrawMesh(Mesh mesh, Vector3 loc, bool wireframe = false)
{
if (wireframe)
D3D.Device.SetRenderState(RenderState.FillMode, FillMode.Wireframe);
SetTarget(loc);
mesh.DrawSubset(0);
if (wireframe)
D3D.Device.SetRenderState(RenderState.FillMode, FillMode.Solid);
}
示例5: DrawMesh
/// <summary>
/// Draws the specified mesh using the supplied material and texture Arrays. Arrays should contain one element for each subset in the mesh (although not every must be filled), or be 'null' for no materials/textures.
/// </summary>
/// <param name="mesh">The Mesh to be drawn.</param>
/// <param name="materials"></param>
/// <param name="textures"></param>
/// <param name="transform">The Mmatrix used as the world transform before drawing the mesh. Pass 'null' for no change.</param>
public static void DrawMesh(Mesh mesh, Material[] materials, Texture[] textures, Matrix transform)
{
if (transform != null)
mesh.Device.Transform.World = transform;
if (materials != null && materials.Length > 0)
{
for (int i = 0; i < materials.Length; i++)
if (textures.Length > 3)
{
mesh.Device.Material = materials[i];
mesh.Device.SetTexture(0, textures[i]);
mesh.DrawSubset(i);
}
}
else
{
int numSubsets = mesh.GetAttributeTable().Length;
for (int i = 0; i < numSubsets; i++)
mesh.DrawSubset(i);
}
}
示例6: RenderMultiSphereShape
public void RenderMultiSphereShape(MultiSphereShape shape, Mesh mesh)
{
int count = shape.SphereCount;
for (int i = 0; i < count; i++)
mesh.DrawSubset(i);
}
示例7: DrawMesh
private void DrawMesh(Mesh mesh, Material[] meshmaterials, Texture[] meshtextures)
{
for (int i = 0; i < meshmaterials.Length; i++)
{
m_device.Material = meshmaterials[i];
m_device.SetTexture(0, meshtextures[i]);
mesh.DrawSubset(i);
}
}
示例8: RenderCapsuleShape
public void RenderCapsuleShape(Mesh mesh)
{
mesh.DrawSubset(0);
mesh.DrawSubset(1);
mesh.DrawSubset(2);
}
示例9: DrawMesh
private void DrawMesh(Mesh mesh, Material[] materials, Texture[] textures)
{
for (int i = 0; i < materials.Length; i++)
{
//commonObjects.D3DDevice.Material = materials[i];
mesh.DrawSubset(i);
}
}
示例10: render
public override void render(float elapsedTime)
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Pongo el fondo negro
d3dDevice.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
//Obtener valores de Modifiers
float vAngleX = (float)GuiController.Instance.Modifiers["angleX"];
float vAngleY = (float)GuiController.Instance.Modifiers["angleY"];
float vAngleZ = (float)GuiController.Instance.Modifiers["angleZ"];
//Rotar la luz en base los ángulos especificados
angleX += vAngleX;
angleY += vAngleY;
angleZ += vAngleZ;
//Posicionar la luz a una distancia y rotarla segun los parametros
Matrix LightRotationMatrix = Matrix.Identity;
LightRotationMatrix *= Matrix.Translation(lightDistance,0,0);
LightRotationMatrix *= Matrix.RotationYawPitchRoll(angleX, angleY,angleZ);
d3dDevice.Lights[0].Position = Vector3.TransformCoordinate(new Vector3(0,0,0),LightRotationMatrix );
lightVectorToCenter = d3dDevice.Lights[0].Position;
d3dDevice.Lights[0].Direction = -d3dDevice.Lights[0].Position;
d3dDevice.Lights[0].Direction.Normalize();
d3dDevice.Lights[0].Update();
//Poner el vertex buffer de la linea que muestra la direccion de la luz.
lightVectorVB[0].Position = lightVectorToCenter;
lightVectorVB[0].Color = Color.White.ToArgb();
lightVectorVB[1].Position = new Vector3(0,0,0);
lightVectorVB[1].Color = Color.Blue.ToArgb();
//Variar el color del material
material.Ambient = (Color)GuiController.Instance.Modifiers["Ambient"];
material.Diffuse = (Color)GuiController.Instance.Modifiers["Diffuse"];
material.Specular = (Color)GuiController.Instance.Modifiers["Specular"];
material.SpecularSharpness = (float)GuiController.Instance.Modifiers["SpecularSharpness"];
d3dDevice.Material = material;
switch ((string)GuiController.Instance.Modifiers["ShaderMode"] )
{
case "Gouraud":
d3dDevice.RenderState.ShadeMode = ShadeMode.Gouraud;
break;
case "Flat":
d3dDevice.RenderState.ShadeMode = ShadeMode.Flat;
break;
}
d3dDevice.RenderState.SpecularEnable = (bool)GuiController.Instance.Modifiers["SpecularEnabled"];
d3dDevice.RenderState.ColorVertex = true;
//Habilito o deshabilito el backface culling.
if ((bool)GuiController.Instance.Modifiers["BackFaceCull"])
{
d3dDevice.RenderState.CullMode = Cull.CounterClockwise;
}
else
{
d3dDevice.RenderState.CullMode = Cull.None;
}
//Selecciono el mesh y el vertex buffer del modelo.
switch ((string)GuiController.Instance.Modifiers["SelectedMesh"])
{
case "Teapot":
SelectedMesh = teapotMesh;
selectedNormalVB = teapotMeshNormalsVB;
break;
case "Face":
SelectedMesh = faceMesh;
selectedNormalVB = null;
break;
}
d3dDevice.RenderState.Lighting = true;
d3dDevice.Transform.World = Matrix.Identity;
//Renderizar malla
SelectedMesh.DrawSubset(0);
//Para dibujar el wireframe se desabilita la luz y se pone el fill mode en modo wireframe.
if ((bool)GuiController.Instance.Modifiers["Wireframe"])
{
d3dDevice.RenderState.FillMode = FillMode.WireFrame;
d3dDevice.RenderState.Lighting = false;
SelectedMesh.DrawSubset(0);
d3dDevice.RenderState.FillMode = FillMode.Solid;
d3dDevice.RenderState.Lighting = true;
}
d3dDevice.Transform.World = Matrix.Identity;
d3dDevice.RenderState.Lighting = false;
//.........这里部分代码省略.........
示例11: draw
public void draw(Device dev, Mesh box, Vector3 origin)
{
dev.Transform.World = Matrix.Translation(
origin + position + new Vector3(0.5f, 0.5f, 0.5f));
if (isAlpha)
{
//dev.RenderState.DiffuseMaterialSource = ColorSource.Material;
dev.RenderState.AlphaBlendEnable = true;
dev.RenderState.SourceBlend = Blend.SourceColor;
dev.RenderState.DestinationBlend = Blend.InvSourceAlpha;
}
else
{
dev.RenderState.AlphaBlendEnable = false;
}
dev.Material = this.mtrl;
box.DrawSubset(0);
}
示例12: drawBlock
public void drawBlock(Device dev, Mesh box, float angle)
{
if (isAlpha)
{
//dev.RenderState.DiffuseMaterialSource = ColorSource.Material;
dev.RenderState.AlphaBlendEnable = true;
dev.RenderState.SourceBlend = Blend.SourceColor;
dev.RenderState.DestinationBlend = Blend.InvSourceAlpha;
}
else
{
dev.RenderState.AlphaBlendEnable = false;
}
dev.Transform.World =
Matrix.Translation(position) * Matrix.RotationY(angle);
dev.Material = this.mtrl;
box.DrawSubset(0);
}