public void RenderSur(SharpDX.Direct3D9.Device device, List <ModelViewForm.MeshGroup> meshgroups) { var colors = new SharpDX.Color[] { new SharpDX.Color(180, 180, 180, 50), new SharpDX.Color(180, 148, 62, 50), new SharpDX.Color(114, 124, 206, 50), new SharpDX.Color(96, 168, 98, 50), new SharpDX.Color(193, 92, 165, 50), new SharpDX.Color(203, 90, 76, 50) }; device.SetTexture(0, null); device.SetTransform(TransformState.World, SharpDX.Matrix.Identity); device.SetTextureStageState(0, TextureStage.ColorOperation, TextureOperation.SelectArg2); device.SetTextureStageState(0, TextureStage.ColorArg2, TextureArgument.TFactor); device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.SelectArg2); device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.TFactor); Dictionary <uint, SharpDX.Matrix> meshgrouptransforms = new Dictionary <uint, SharpDX.Matrix>(); foreach (var m in meshgroups) { var k = Utilities.FLModelCRC(m.Name); if (meshgrouptransforms.ContainsKey(k)) { continue; } else { meshgrouptransforms[k] = m.Transform; } } int c = 0; foreach (var m in Meshes) { if (meshgrouptransforms.ContainsKey(m.MeshId)) { device.SetTransform(TransformState.World, meshgrouptransforms[m.MeshId]); } else { device.SetTransform(TransformState.World, SharpDX.Matrix.Identity); } List <SharpDX.Vector3> tmpVertices = new List <SharpDX.Vector3>(); List <int> tmpTri = new List <int>(); foreach (var ss in m.SurfaceSections) { foreach (var vert in ss.Vertices) { tmpVertices.Add(new SharpDX.Vector3(vert.X, vert.Y, vert.Z)); } foreach (var tg in ss.TriangleGroups) { foreach (var tri in tg.Triangles) { foreach (var i in tri.Indices) { tmpTri.Add(i.VertexId); System.Diagnostics.Debug.Assert(i.VertexId < tmpVertices.Count); } } } } var color = colors[c % colors.Length]; device.SetRenderState(RenderState.TextureFactor, color.ToRgba()); device.DrawIndexedUserPrimitives(SharpDX.Direct3D9.PrimitiveType.TriangleList, 0, tmpVertices.Count, tmpTri.Count / 3, tmpTri.ToArray(), SharpDX.Direct3D9.Format.Index32, tmpVertices.ToArray()); c++; } }