public virtual void Draw(Effect effect, bool enable_lighting = false, DrawModes mode = DrawModes.Mesh | DrawModes.Outline)
{
//effect.LightingEnabled = false;
if (OutlineLocation > 0 && (mode & DrawModes.Outline) != 0)
{
effect.CurrentTechnique.Passes[0].Apply();
Device.SetVertexBuffer(OutlineBuffer);
Device.DrawPrimitives(PrimitiveType.LineList, 0, OutlineLocation / 2);
}
if ((IsIndexed && IndexCount == 0) || (!IsIndexed && VertexCount == 0) || ((mode & DrawModes.Mesh) == 0))
{
Device.SetVertexBuffer(null);
return;
}
if (enable_lighting)
{
/*effect.LightingEnabled = true;
effect.PreferPerPixelLighting = true;
effect.SpecularPower = 64;
effect.SpecularColor = Color.Black.ToVector3();
effect.CurrentTechnique.Passes[0].Apply();
effect.AmbientLightColor = Color.Gray.ToVector3();*/
}
if (effect != null)
effect.CurrentTechnique.Passes[0].Apply();
Device.SetVertexBuffer(VertexBuffer);
if (IsIndexed)
{
Device.Indices = IndexBuffer;
if (Is3D)
Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VertexCount, 0, Math.Min(1048575, IndexCount / 3));
else
Device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, VertexCount, 0, IndexCount / 2);
Device.Indices = null;
}
else
{
if (Is3D)
Device.DrawPrimitives(PrimitiveType.TriangleList, 0, VertexCount / 3);
else
Device.DrawPrimitives(PrimitiveType.LineList, 0, VertexCount / 2);
}
Device.SetVertexBuffer(null);
}