本文整理汇总了C#中Device.DrawPrimitives方法的典型用法代码示例。如果您正苦于以下问题:C# Device.DrawPrimitives方法的具体用法?C# Device.DrawPrimitives怎么用?C# Device.DrawPrimitives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device.DrawPrimitives方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var form = new Form1();
var panel = form.SplitContainer.Panel1;
var device = new Device(new Direct3D(), 0, DeviceType.Hardware, panel.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters()
{
BackBufferWidth = panel.ClientSize.Width,
BackBufferHeight = panel.ClientSize.Height
});
var vertices = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
vertices.Lock(0, 0, LockFlags.None).WriteRange(new[] {
new Vertex() { Color = Color.Red.ToArgb(), Position = new Vector4(400.0f, 100.0f, 0.5f, 1.0f) },
new Vertex() { Color = Color.Blue.ToArgb(), Position = new Vector4(650.0f, 500.0f, 0.5f, 1.0f) },
new Vertex() { Color = Color.Green.ToArgb(), Position = new Vector4(150.0f, 500.0f, 0.5f, 1.0f) }
});
vertices.Unlock();
var vertices2 = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
vertices2.Lock(0, 0, LockFlags.None).WriteRange(new[] {
new Vertex() { Color = Color.Red.ToArgb(), Position = new Vector4(300.0f, 100.0f, 0.5f, 1.0f) },
new Vertex() { Color = Color.Blue.ToArgb(), Position = new Vector4(550.0f, 500.0f, 0.5f, 1.0f) },
new Vertex() { Color = Color.Green.ToArgb(), Position = new Vector4(050.0f, 500.0f, 0.5f, 1.0f) }
});
vertices2.Unlock();
var vertexElems = new[] {
new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.PositionTransformed, 0),
new VertexElement(0, 16, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
VertexElement.VertexDeclarationEnd
};
var vertexDecl = new VertexDeclaration(device, vertexElems);
MessagePump.Run(form, () =>
{
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
device.BeginScene();
device.SetStreamSource(0, vertices, 0, 20);
device.VertexDeclaration = vertexDecl;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
device.SetStreamSource(0, vertices2, 0, 20);
device.VertexDeclaration = vertexDecl;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
device.EndScene();
device.Present();
});
foreach (var item in ObjectTable.Objects)
item.Dispose();
}
示例2: Poke
public void Poke( DateTime timestamp, Device world )
{
var vb = new VertexBuffer( typeof( CustomVertex.PositionColored ), 6, world, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default );
var vertices = new CustomVertex.PositionColored[6];
int i = 0;
vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
vertices[i++].Position = new Vector3( 100, 200, 1 );
vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
vertices[i++].Position = new Vector3( 0, 100, 1 );
vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
vertices[i++].Position = new Vector3( 200, 100, 1 );
vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
vertices[i++].Position = new Vector3( 200, 300, 1 );
vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
vertices[i++].Position = new Vector3( 0, 300, 1 );
vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
vertices[i++].Position = new Vector3( 0, 100, 1 );
vb.SetData( vertices, 0, LockFlags.None );
world.SetStreamSource( 1, vb, 0 );
world.DrawPrimitives( PrimitiveType.TriangleFan, 0, 6 );
}
示例3: RenderAxis
public void RenderAxis(Device d3dDevice)
{
d3dDevice.RenderState.Lighting = false;
d3dDevice.SetStreamSource(0, m_CoordinateAxis, 0);
d3dDevice.VertexFormat = CustomVertex.PositionColored.Format;
d3dDevice.DrawPrimitives(PrimitiveType.LineList, 0, 3);
d3dDevice.RenderState.Lighting = true;
}
示例4: draw
public void draw(Vector3 cameraRotation, Device device)
{
device.SetTexture(0, particleTexture);
device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
device.TextureState[0].AlphaArgument0 = TextureArgument.Current;
device.TextureState[0].AlphaArgument1 = TextureArgument.Diffuse;
device.TextureState[0].AlphaArgument2 = TextureArgument.TextureColor;
device.TextureState[0].ColorArgument0 = TextureArgument.Current;
device.TextureState[0].ColorArgument1 = TextureArgument.Diffuse;
device.TextureState[0].ColorArgument2 = TextureArgument.TextureColor;
device.TextureState[0].ColorOperation = TextureOperation.Modulate;
Material material = device.Material;
Color diffuse = material.Diffuse;
material.Diffuse = fade;
material.Emissive = Color.White;
device.Material = material;
foreach (ParticleData particle in particleList)
{
device.Transform.World =
Matrix.RotationYawPitchRoll(cameraRotation.X, cameraRotation.Y, cameraRotation.Z) *
Matrix.Translation(particle.location);
VertexBuffer buffer = new VertexBuffer(typeof(CustomVertex.PositionNormalTextured), 4, device, 0, CustomVertex.PositionNormalTextured.Format, Pool.Default);
CustomVertex.PositionNormalTextured[] vertices = (CustomVertex.PositionNormalTextured[])buffer.Lock(0, 0);
float particleRadius = particle.size / 2;
vertices[0] = new CustomVertex.PositionNormalTextured(new Vector3(-particleRadius, -particleRadius, 0f), new Vector3(0, 1, 0), 0, 1); // bottom right
vertices[1] = new CustomVertex.PositionNormalTextured(new Vector3(-particleRadius, particleRadius, 0f), new Vector3(0, 1, 0), 0, 0); // top right
vertices[2] = new CustomVertex.PositionNormalTextured(new Vector3(particleRadius, -particleRadius, 0f), new Vector3(0, 1, 0), 1, 1); // bottom left
vertices[3] = new CustomVertex.PositionNormalTextured(new Vector3(particleRadius, particleRadius, 0), new Vector3(0, 1, 0), 1, 0); // top left
buffer.Unlock();
device.VertexFormat = CustomVertex.PositionNormalTextured.Format;
device.SetStreamSource(0, buffer, 0);
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
}
示例5: RenderHorizontalLines
private static void RenderHorizontalLines(Device dev, VertexBuffer vertex, int count)
{
dev.SetStreamSource(0, vertex, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineList, 0, count);
}
示例6: render
public void render(ref Device device, ref Microsoft.DirectX.Direct3D.Font directxFont)
{
// Render the module names and outlines
if( moduleManager != null )
moduleManager.render(ref device, ref directxFont);
// Render the functions
if (vertexBufferFunctions != null)
{
device.SetStreamSource(0, vertexBufferFunctions, 0);
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.DrawPrimitives(PrimitiveType.PointList, 0, vertexFunctionsCount);
}
// Render the function links
if (vertexBufferLinks != null && vertexLinksCount > 0)
{
device.SetStreamSource(0, vertexBufferLinks, 0);
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.DrawPrimitives(PrimitiveType.LineList, 0, vertexLinksCount/2);
}
}
示例7: DrawBox
/*
private void DrawBox(float yaw, float pitch, float roll, float x, float y, float z)
{
angle += 0.01f;
device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verts.Length, 0, indices.Length / 3);
}
*/
/// <summary>
/// render 3D objects
/// </summary>
/// <param name="d3d"></param>
/// <param name="dx"></param>
private void render3D(Device dx)
{
if ((initialised_3D) && (selected_display == MonoSLAM.DISPLAY_AUGMENTED_REALITY))
{
if ((test.enable_mapping) && (!test.calibrating))
{
// Set the position of the camera
Vector3D camera_position = null;
SceneLibrary.Quaternion camera_orientation = null;
test.getCameraPositionOrientation(ref camera_position, ref camera_orientation);
dx.Transform.View = QuaternionToMatrixLookAt(camera_position, camera_orientation);
/*
Microsoft.DirectX.Quaternion q_orientation =
new Microsoft.DirectX.Quaternion((float)camera_orientation.GetX(),
(float)camera_orientation.GetY(),
(float)camera_orientation.GetZ(),
(float)camera_orientation.GetR());
Matrix _matrixRotation = Matrix.RotationQuaternion(q_orientation);
float yaw = 0, pitch = 0, roll = 0;
camera_orientation.GetZYXEuler(ref pitch, ref yaw, ref roll);
dx.Transform.View = QuaternionToMatrixLookAt(camera_position, camera_orientation) *
Matrix.RotationYawPitchRoll(0,0,(float)(roll));
*/
//dx.Material = InitMaterial(Color.White);
dx.Clear(ClearFlags.ZBuffer, Color.FromArgb(255, 0, 0, 0), 1.0f, 0);
//dx.Clear(ClearFlags.Target | ClearFlags.ZBuffer,Color.FromArgb(255, 0, 0, 0), 1.0f, 0);
//dx.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Transparent, 1.0f, 0);
if (background_image == null)
background_image = new D3D_background(dx, background_bitmap);
else
background_image.update(dx, background_bitmap);
background_image.Draw();
/*
dx.BeginScene();
dx.Transform.World = Matrix.Identity;
ScaleMatrices(dx, 1000, 0.1f, 0.1f);
dx.VertexFormat = Vertex.FVF_Flags;
dx.SetStreamSource(0, lineVertexBuffer, 0);
//dx.SetTexture(0, texture);
dx.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
dx.DrawPrimitives(PrimitiveType.TriangleStrip, 4, 2);
dx.EndScene();
// this try/catch prevents an error if the scene is being rendered
// whilst the window is being closed
try
{
dx.Present();
}
catch
{
}
dx.BeginScene();
dx.Transform.World = Matrix.Identity;
ScaleMatrices(dx, 0.1f, 1000, 0.1f);
dx.VertexFormat = Vertex.FVF_Flags;
dx.SetStreamSource(0, lineVertexBuffer, 0);
//dx.SetTexture(0, texture);
dx.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
dx.DrawPrimitives(PrimitiveType.TriangleStrip, 4, 2);
dx.EndScene();
// this try/catch prevents an error if the scene is being rendered
//.........这里部分代码省略.........
示例8: drawPostProcess
/// <summary>
/// Se toma todo lo dibujado antes, que se guardo en una textura, y se le aplica un shader para borronear la imagen
/// </summary>
private void drawPostProcess(Device d3dDevice, float elapsedTime)
{
//Arrancamos la escena
d3dDevice.BeginScene();
//Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes
d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format;
d3dDevice.SetStreamSource(0, screenQuadVB, 0);
effect.Technique = "AlarmaTechnique";
//Cargamos parametros en el shader de Post-Procesado
effect.SetValue("render_target2D", renderTarget2D);
effect.SetValue("textura_alarma", alarmTexture.D3dTexture);
effect.SetValue("alarmaScaleFactor", intVaivenAlarm.update());
//Limiamos la pantalla y ejecutamos el render del shader
d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
effect.Begin(FX.None);
effect.BeginPass(0);
d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
effect.EndPass();
effect.End();
//Terminamos el renderizado de la escena
d3dDevice.EndScene();
}
示例9: RenderPhase2
private static void RenderPhase2(Device dev) // yt7pwr
{
try
{
int x, y;
for (int i = 0, j = 0; i < phase_num_pts; i++, j += 8) // fill point array
{
x = (int)(current_display_data[i * 2] * panadapter_H * 0.5 * 500);
y = (int)(current_display_data[i * 2 + 1] * panadapter_H * 0.5 * 500);
Panadapter_verts[i].Color = data_line_color.ToArgb();
Panadapter_verts[i].Position.X = panadapter_W * 0.5f + x;
Panadapter_verts[i].Position.Y = panadapter_H * 0.5f + y;
}
Panadapter_vb.Lock(0, 0, LockFlags.None).WriteRange(Panadapter_verts, 0, phase_num_pts);
Panadapter_vb.Unlock();
dev.SetStreamSource(0, Panadapter_vb, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineStrip, 0, phase_num_pts - 1);
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}
示例10: Render
/// <summary>
/// Draw the polygon
/// </summary>
/// <param name="device">The device to draw on</param>
public virtual void Render(Device device)
{
// Get the vertices we will draw
List<Vector2> vertices = Vertices;
// Ensure we have at least a triangle
if (vertices.Count < 3)
return;
if (verticesV == null)
{
verticesV = new VertexBuffer(typeof(CustomVertex.PositionColored), // Type
vertices.Count, // How many
device, // What device
0, // No special usage
CustomVertex.PositionColored.Format,
Pool.Managed);
}
GraphicsStream gs = verticesV.Lock(0, 0, 0); // Lock the background vertex list
int clr = color.ToArgb();
foreach (Vector2 v in vertices)
{
gs.Write(new CustomVertex.PositionColored(v.X, v.Y, 0, clr));
}
verticesV.Unlock();
device.SetStreamSource(0, verticesV, 0);
device.VertexFormat = CustomVertex.PositionColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleFan, 0, vertices.Count - 2);
}
示例11: DrawScene
public int DrawScene(Device d3dDev, Texture texture)
{
if (vertexBuffer == null)
return E_FAIL;
// get the difference in time
int currentTime = GetTickCount();
double difference = time - currentTime ;
// figure out the rotation of the plane
float x = (float) (-Math.Cos(difference / 2000.0));
float y = (float) (Math.Cos(difference / 2000.0));
float z = (float) (Math.Sin(difference / 2000.0));
// update the two rotating vertices with the new position
vertices[0].Position = new Vector3(x, y, z);
vertices[3].Position = new Vector3(-x, -y, -z);
// Adjust the color so the blue is always on the bottom.
// As the corner approaches the bottom, get rid of all the other
// colors besides blue
int mask0 = (int) (255 * (( y + 1.0) / 2.0));
int mask3 = (int) (255 * (( -y + 1.0 ) / 2.0));
vertices[0].Color = unchecked((int) 0xff0000ff | (mask0 << 16) | (mask0 << 8));
vertices[3].Color = unchecked((int) 0xff0000ff | (mask3 << 16) | (mask3 << 8));
try
{
// write the new vertex information into the buffer
vertexBuffer.SetData(vertices, 0, LockFlags.None);
// clear the scene so we don't have any articats left
d3dDev.Clear(ClearFlags.Target, 0x00ffffff, 1.0f, 0);
d3dDev.BeginScene();
d3dDev.SetTexture(0, texture);
d3dDev.SetTextureStageState(0, TextureStageStates.AlphaOperation, (int)TextureOperation.Modulate);
d3dDev.SetTextureStageState(0, TextureStageStates.AlphaArgument1, (int)TextureArgument.TextureColor);
d3dDev.SetTextureStageState(0, TextureStageStates.AlphaArgument2, (int)TextureArgument.Diffuse);
d3dDev.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
d3dDev.SetStreamSource(0, vertexBuffer, 0);
d3dDev.VertexFormat = CustomVertex.PositionColoredTextured.Format;
d3dDev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
d3dDev.SetTexture(0, null);
d3dDev.EndScene();
}
catch(DirectXException e)
{
return e.ErrorCode;
}
catch
{
return E_FAIL;
}
return 0;
}
示例12: RenderScopeLine
public static void RenderScopeLine(Device dev, int count, bool monitor)
{
try
{
Mode new_mode = MainForm.OpModeVFOA;
if (Audio.channel == 6)
new_mode = MainForm.OpModeVFOB;
switch (new_mode)
{
case Mode.RTTY:
{
////////////// mark ////////////////////
for (int i = 0; i < count * 2; i++)
{
ScopeLine_verts[i] = new Vertex();
ScopeLine_verts[i].Color = data_line_color.ToArgb();
ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data_mark[i], 0.0f, 0.0f);
ScopeLine_verts[i + 1] = new Vertex();
ScopeLine_verts[i + 1].Color = data_line_color.ToArgb();
ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data_mark[i + 1], 0.0f, 0.0f);
i++;
}
if (monitor)
{
ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
ScopeLine_vb_monitor.Unlock();
dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
}
else
{
ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
ScopeLine_vb.Unlock();
dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
}
////////////// space ///////////////////
for (int i = 0; i < count * 2; i++)
{
ScopeLine_verts[i] = new Vertex();
ScopeLine_verts[i].Color = data_line_color.ToArgb();
ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data_space[i], 0.0f, 0.0f);
ScopeLine_verts[i + 1] = new Vertex();
ScopeLine_verts[i + 1].Color = data_line_color.ToArgb();
ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data_space[i + 1], 0.0f, 0.0f);
i++;
}
if (monitor)
{
ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
ScopeLine_vb_monitor.Unlock();
dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
}
else
{
ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
ScopeLine_vb.Unlock();
dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
}
}
break;
default:
{
for (int i = 0; i < count * 2; i++)
{
ScopeLine_verts[i] = new Vertex();
ScopeLine_verts[i].Color = data_line_color.ToArgb();// Color.Wheat.ToArgb();
ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data[i], 0.0f, 0.0f);
ScopeLine_verts[i + 1] = new Vertex();
ScopeLine_verts[i + 1].Color = data_line_color.ToArgb(); // Color.Wheat.ToArgb();
ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data[i + 1], 0.0f, 0.0f);
i++;
}
if (monitor)
{
ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
ScopeLine_vb_monitor.Unlock();
dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
}
else
{
ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
ScopeLine_vb.Unlock();
dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
}
}
break;
//.........这里部分代码省略.........
示例13: render
public override void render(Device dx_device)
{
dx_device.SetStreamSource(0, m_VB, 0);
dx_device.VertexFormat = m_VB.Description.VertexFormat;
dx_device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_nPrimitives);
}
示例14: Render
/// <summary>Renders the quads with this style.</summary>
/// <param name="device">D3D Device</param>
/// <param name="quads">Quads to render</param>
public void Render(Device device, List<Quad> quads)
{
if (quads.Count == 0)
return;
// Add vertices to the buffer
GraphicsStream gb =
m_vb.Lock(0, 6 * quads.Count * CustomVertex.TransformedColoredTextured.StrideSize, LockFlags.Discard);
Quad q;
for (int i = 0; i < quads.Count;i++ )
{
q = (Quad)quads[i].Clone();
q.X -= 0.5f;
q.Y -= 0.5f;
gb.Write(q.Vertices);
}
m_vb.Unlock();
// Set render states
device.SetRenderState(RenderStates.Lighting, false);
device.SetRenderState(RenderStates.ZBufferWriteEnable, false);
device.SetRenderState(RenderStates.ZEnable, false);
device.SetRenderState(RenderStates.AlphaBlendEnable, true);
device.SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha);
device.SetRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha);
device.SetStreamSource(0, m_vb, 0, CustomVertex.TransformedColoredTextured.StrideSize);
device.SetTexture(0, m_texture);
device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2 * quads.Count);
}
示例15: Render
public void Render(Device device)
{
if (Geometry.Clr != -1)
{
device.RenderState.Lighting = true;
Microsoft.DirectX.Direct3D.Material mt = new Microsoft.DirectX.Direct3D.Material();
mt.AmbientColor = ColorValue.FromArgb(Geometry.Clr);
mt.DiffuseColor = ColorValue.FromArgb(Geometry.Clr);
device.RenderState.DiffuseMaterialSource = ColorSource.Material;
device.Material = mt;
device.RenderState.AmbientColor = Geometry.Clr;
}
device.VertexFormat = vFormat;
device.SetStreamSource(0, vBuffer, 0);
if (matIBuffers != null)
{
for (int mat = 0; mat < MaterialIndices.Length; mat++)
{
Microsoft.DirectX.Direct3D.Material oMat = device.Material;
if (MaterialIndices[mat].Material.Texture == null)
{
Microsoft.DirectX.Direct3D.Material material = new Microsoft.DirectX.Direct3D.Material();
material.AmbientColor = ColorValue.FromColor(System.Drawing.Color.FromArgb(MaterialIndices[mat].Material.Ambient.A,
MaterialIndices[mat].Material.Ambient.R,
MaterialIndices[mat].Material.Ambient.G,
MaterialIndices[mat].Material.Ambient.B));
material.DiffuseColor = ColorValue.FromColor(System.Drawing.Color.FromArgb(MaterialIndices[mat].Material.Diffuse.A,
MaterialIndices[mat].Material.Diffuse.R,
MaterialIndices[mat].Material.Diffuse.G,
MaterialIndices[mat].Material.Diffuse.B));
device.Material = material;
}
else
device.SetTexture(0, MaterialIndices[mat].Material.Texture);
device.Indices = matIBuffers[mat];
device.DrawIndexedPrimitives(Geometry.PrimType, 0, 0, Geometry.Vertices.Length, 0, MaterialIndices[mat].PrimCount);
device.Material = oMat;
}
}
else if (iBuffer != null)
{
device.Indices = iBuffer;
device.DrawIndexedPrimitives(Geometry.PrimType, 0, 0, Geometry.Vertices.Length, 0, numPrimitives);
}
else
{
device.Indices = null;
device.DrawPrimitives(Geometry.PrimType, 0, numPrimitives);
}
}