'Declaration Public Class Mesh Inherits Entity Implements IEntity, IFace, IFaceSelectable, devDept.Eyeshot.ISelectableItem
public class Mesh : Entity, IEntity, IFace, IFaceSelectable, devDept.Eyeshot.ISelectableItem
Mesh entity. Depending on the types of vertices and triangles can assume different configurations, see table below:
Triangles type / Vertices type | devDept.Geometry.Point3D | devDept.Geometry.PointRGB |
devDept.Geometry.IndexTriangle | Plain1 | MulticolorPlain |
devDept.Geometry.SmoothTriangle | Smooth1 | MulticolorSmooth |
devDept.Geometry.ColorTriangle | ColorPlain | |
devDept.Geometry.ColorSmoothTriangle | ColorSmooth | |
devDept.Geometry.RichTriangle | RichPlain | |
devDept.Geometry.RichSmoothTriangle | RichSmooth |
'Declaration Public Class Mesh Inherits Entity Implements IEntity, IFace, IFaceSelectable, devDept.Eyeshot.ISelectableItem
public class Mesh : Entity, IEntity, IFace, IFaceSelectable, devDept.Eyeshot.ISelectableItem
using System; using System.Collections.Generic; using System.Drawing; using devDept.Eyeshot; using devDept.Eyeshot.Entities; using devDept.Geometry; namespace MeshSamples { internal class Mesh { private static int rows = 8; private static int cols = 8; private static double scale = 4; public static void Plain(ViewportLayout viewportLayout) { List<Point3D> vertices = new List<Point3D>(rows * cols); Mesh surface = new Mesh(); surface.NormalAveragingMode = Mesh.normalAveragingType.Averaged; for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i / 5.0 - 2; double y = -j / 5.0 - 2; double f = 0; double den = Math.Sqrt(x * x + y * y); if (den != 0) f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den; vertices.Add(new Point3D(x, y, f)); } List<IndexTriangle> triangles = new List<IndexTriangle>((rows - 1) * (cols - 1) * 2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { triangles.Add(new IndexTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)); triangles.Add(new IndexTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); viewportLayout.Entities.Add(surface, 0, Color.Green); } public static void ColoredPlain(ViewportLayout viewportLayout) { List<Point3D> vertices = new List<Point3D>(rows*cols); Mesh surface = new Mesh(); for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i/5.0 - 2; double y = -j/5.0 - 2; double f = 0; double den = Math.Sqrt(x*x + y*y); if (den != 0) f = scale*Math.Sin(Math.Sqrt(x*x + y*y))/den; vertices.Add(new Point3D(x, y, f)); } List<ColorTriangle> triangles = new List<ColorTriangle>((rows - 1)*(cols - 1)*2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { // generates a random color int red = (int) (255 - i*100); int green = (int) (255 - j*50); int blue = 127; // clamps color values lat 0-255 Utility.LimitRange<int>(0, ref red, 255); Utility.LimitRange<int>(0, ref green, 255); Utility.LimitRange<int>(0, ref blue, 255); triangles.Add(new ColorTriangle(i + j*cols, i + j*cols + 1, i + (j + 1)*cols + 1, (byte) red, (byte) green, (byte) blue)); triangles.Add(new ColorTriangle(i + j*cols, i + (j + 1)*cols + 1, i + (j + 1)*cols, (byte) red, (byte) green, (byte) blue)); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); viewportLayout.Entities.Add(surface, 0); } public static void MulticolorPlain(ViewportLayout viewportLayout) { List<PointRGB> vertices = new List<PointRGB>(rows * cols); Mesh surface = new Mesh(); for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i / 5.0 - 2; double y = -j / 5.0 - 2; double f = 0; double den = Math.Sqrt(x * x + y * y); if (den != 0) f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den; // generates a random color int red = (int)(y * y * 30); int green = (int)(x * x * 30); int blue = (int)(255 - f * f * 1000); // clamps color values lat 0-255 Utility.LimitRange<int>(0, ref red, 255); Utility.LimitRange<int>(0, ref green, 255); Utility.LimitRange<int>(0, ref blue, 255); vertices.Add(new PointRGB(x, y, f, (byte)red, (byte)green, (byte)blue)); } List<IndexTriangle> triangles = new List<IndexTriangle>((rows - 1) * (cols - 1) * 2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { triangles.Add(new IndexTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)); triangles.Add(new IndexTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); viewportLayout.Entities.Add(surface); } public static void TexturedPlain(ViewportLayout viewportLayout) { List<Point3D> vertices = new List<Point3D>(rows * cols); List<Point2D> texCoords = new List<Point2D>(rows * cols); Mesh surface = new Mesh(); for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i / 5.0 - 2; double y = -j / 5.0 - 2; double f = 0; double den = Math.Sqrt(x * x + y * y); if (den != 0) f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den; vertices.Add(new Point3D(x, y, f)); texCoords.Add(new Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1))); } Bitmap bmp = new Bitmap(Properties.Resources.Smiley); Material mat = new Material(bmp); viewportLayout.Materials.Add("test", mat); List<RichTriangle> triangles = new List<RichTriangle>((rows - 1) * (cols - 1) * 2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { RichTriangle tri = new RichTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1); tri.T1 = tri.V1; tri.T2 = tri.V2; tri.T3 = tri.V3; triangles.Add(tri); tri = new RichTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols); tri.T1 = tri.V1; tri.T2 = tri.V2; tri.T3 = tri.V3; triangles.Add(tri); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); surface.TextureCoords = texCoords.ToArray(); surface.ColorMethod = colorMethodType.byEntity; surface.MaterialName = "test"; viewportLayout.Entities.Add(surface); } public static void Smooth(ViewportLayout viewportLayout) { List<Point3D> vertices = new List<Point3D>(rows * cols); Mesh surface = new Mesh(); surface.NormalAveragingMode = Mesh.normalAveragingType.Averaged; for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i / 5.0 - 2; double y = -j / 5.0 - 2; double f = 0; double den = Math.Sqrt(x * x + y * y); if (den != 0) f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den; vertices.Add(new Point3D(x, y, f)); } List<SmoothTriangle> triangles = new List<SmoothTriangle>((rows - 1) * (cols - 1) * 2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { triangles.Add(new SmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)); triangles.Add(new SmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); viewportLayout.Entities.Add(surface, 0, Color.Green); } public static void ColoredSmooth(ViewportLayout viewportLayout) { List<Point3D> vertices = new List<Point3D>(rows * cols); Mesh surface = new Mesh(); for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i / 5.0 - 2; double y = -j / 5.0 - 2; double f = 0; double den = Math.Sqrt(x * x + y * y); if (den != 0) f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den; vertices.Add(new Point3D(x, y, f)); } List<ColorSmoothTriangle> triangles = new List<ColorSmoothTriangle>((rows - 1) * (cols - 1) * 2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { // generates a random color int red = (255 - i * 100); int green = (255 - j * 50); int blue = 127; // clamps color values lat 0-255 Utility.LimitRange<int>(0, ref red, 255); Utility.LimitRange<int>(0, ref green, 255); Utility.LimitRange<int>(0, ref blue, 255); triangles.Add(new ColorSmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1, (byte)red, (byte)green, (byte)blue)); triangles.Add(new ColorSmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols, (byte)red, (byte)green, (byte)blue)); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); viewportLayout.Entities.Add(surface, 0); } public static void MulticolorSmooth(ViewportLayout viewportLayout) { List<PointRGB> vertices = new List<PointRGB>(rows * cols); Mesh surface = new Mesh(); surface.NormalAveragingMode = Mesh.normalAveragingType.Averaged; for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i / 5.0 - 2; double y = -j / 5.0 - 2; double f = 0; double den = Math.Sqrt(x * x + y * y); if (den != 0) f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den; // generates a random color int red = (int)(y * y * 30); int green = (int)(x * x * 30); int blue = (int)(255 - f * f * 1000); // clamps color values lat 0-255 Utility.LimitRange<int>(0, ref red, 255); Utility.LimitRange<int>(0, ref green, 255); Utility.LimitRange<int>(0, ref blue, 255); vertices.Add(new PointRGB(x, y, f, (byte)red, (byte)green, (byte)blue)); } List<SmoothTriangle> triangles = new List<SmoothTriangle>((rows - 1) * (cols - 1) * 2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { triangles.Add(new SmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)); triangles.Add(new SmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); viewportLayout.Entities.Add(surface, 0); } public static void TexturedSmooth(ViewportLayout viewportLayout) { List<Point3D> vertices = new List<Point3D>(rows * cols); List<Point2D> texCoords = new List<Point2D>(rows * cols); Mesh surface = new Mesh(); for (int j = 0; j < rows; j++) for (int i = 0; i < cols; i++) { double x = -i / 5.0 - 2; double y = -j / 5.0 - 2; double f = 0; double den = Math.Sqrt(x * x + y * y); if (den != 0) f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den; vertices.Add(new Point3D(x, y, f)); texCoords.Add(new Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1))); } Bitmap bmp = new Bitmap(Properties.Resources.Smiley); Material mat = new Material(bmp); viewportLayout.Materials.Add("test", mat); List<RichSmoothTriangle> triangles = new List<RichSmoothTriangle>((rows - 1) * (cols - 1) * 2); for (int j = 0; j < (rows - 1); j++) for (int i = 0; i < (cols - 1); i++) { RichSmoothTriangle tri = new RichSmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1); tri.T1 = tri.V1; tri.T2 = tri.V2; tri.T3 = tri.V3; triangles.Add(tri); tri = new RichSmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols); tri.T1 = tri.V1; tri.T2 = tri.V2; tri.T3 = tri.V3; triangles.Add(tri); } surface.Vertices = vertices.ToArray(); surface.Triangles = triangles.ToArray(); surface.TextureCoords = texCoords.ToArray(); surface.MaterialName = "test"; surface.ColorMethod = colorMethodType.byEntity; viewportLayout.Entities.Add(surface, 0); } }
Imports System Imports System.Collections.Generic Imports System.Drawing Imports devDept.Eyeshot Imports devDept.Eyeshot.Entities Imports devDept.Geometry Namespace MeshSamples Friend Class Mesh Private Shared rows As Integer = 8 Private Shared cols As Integer = 8 Private Shared scale As Double = 4 Public Shared Sub Plain(viewportLayout As ViewportLayout) Dim vertices As New List(Of Point3D)(rows * cols) Dim surface As New Mesh() surface.NormalAveragingMode = Mesh.normalAveragingType.Averaged For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If vertices.Add(New Point3D(x, y, f)) Next Next Dim triangles As New List(Of IndexTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 triangles.Add(New IndexTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)) triangles.Add(New IndexTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() viewportLayout.Entities.Add(surface, 0, Color.Green) End Sub Public Shared Sub ColoredPlain(viewportLayout As ViewportLayout) Dim vertices As New List(Of Point3D)(rows * cols) Dim surface As New Mesh() For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If vertices.Add(New Point3D(x, y, f)) Next Next Dim triangles As New List(Of ColorTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 ' generates a random color Dim red As Integer = CInt(255 - i * 100) Dim green As Integer = CInt(255 - j * 50) Dim blue As Integer = 127 ' clamps color values lat 0-255 Utility.LimitRange(Of Integer)(0, red, 255) Utility.LimitRange(Of Integer)(0, green, 255) Utility.LimitRange(Of Integer)(0, blue, 255) triangles.Add(New ColorTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1, CByte(red), CByte(green), CByte(blue))) triangles.Add(New ColorTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols, CByte(red), CByte(green), CByte(blue))) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() viewportLayout.Entities.Add(surface, 0) End Sub Public Shared Sub MulticolorPlain(viewportLayout As ViewportLayout) Dim vertices As New List(Of PointRGB)(rows * cols) Dim surface As New Mesh() For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If ' generates a random color Dim red As Integer = CInt(y * y * 30) Dim green As Integer = CInt(x * x * 30) Dim blue As Integer = CInt(255 - f * f * 1000) ' clamps color values lat 0-255 Utility.LimitRange(Of Integer)(0, red, 255) Utility.LimitRange(Of Integer)(0, green, 255) Utility.LimitRange(Of Integer)(0, blue, 255) vertices.Add(New PointRGB(x, y, f, CByte(red), CByte(green), CByte(blue))) Next Next Dim triangles As New List(Of IndexTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 triangles.Add(New IndexTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)) triangles.Add(New IndexTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() viewportLayout.Entities.Add(surface) End Sub Public Shared Sub TexturedPlain(viewportLayout As ViewportLayout) Dim vertices As New List(Of Point3D)(rows * cols) Dim texCoords As New List(Of Point2D)(rows * cols) Dim surface As New Mesh() For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If vertices.Add(New Point3D(x, y, f)) texCoords.Add(New Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1))) Next Next Dim bmp As New Bitmap(Properties.Resources.Smiley) Dim mat As New Material(bmp) viewportLayout.Materials.Add("test", mat) Dim triangles As New List(Of RichTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 Dim tri As New RichTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1) tri.T1 = tri.V1 tri.T2 = tri.V2 tri.T3 = tri.V3 triangles.Add(tri) tri = New RichTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols) tri.T1 = tri.V1 tri.T2 = tri.V2 tri.T3 = tri.V3 triangles.Add(tri) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() surface.TextureCoords = texCoords.ToArray() surface.ColorMethod = colorMethodType.byEntity surface.MaterialName = "test" viewportLayout.Entities.Add(surface) End Sub Public Shared Sub Smooth(viewportLayout As ViewportLayout) Dim vertices As New List(Of Point3D)(rows * cols) Dim surface As New Mesh() surface.NormalAveragingMode = Mesh.normalAveragingType.Averaged For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If vertices.Add(New Point3D(x, y, f)) Next Next Dim triangles As New List(Of SmoothTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 triangles.Add(New SmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)) triangles.Add(New SmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() viewportLayout.Entities.Add(surface, 0, Color.Green) End Sub Public Shared Sub ColoredSmooth(viewportLayout As ViewportLayout) Dim vertices As New List(Of Point3D)(rows * cols) Dim surface As New Mesh() For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If vertices.Add(New Point3D(x, y, f)) Next Next Dim triangles As New List(Of ColorSmoothTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 ' generates a random color Dim red As Integer = (255 - i * 100) Dim green As Integer = (255 - j * 50) Dim blue As Integer = 127 ' clamps color values lat 0-255 Utility.LimitRange(Of Integer)(0, red, 255) Utility.LimitRange(Of Integer)(0, green, 255) Utility.LimitRange(Of Integer)(0, blue, 255) triangles.Add(New ColorSmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1, CByte(red), CByte(green), CByte(blue))) triangles.Add(New ColorSmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols, CByte(red), CByte(green), CByte(blue))) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() viewportLayout.Entities.Add(surface, 0) End Sub Public Shared Sub MulticolorSmooth(viewportLayout As ViewportLayout) Dim vertices As New List(Of PointRGB)(rows * cols) Dim surface As New Mesh() surface.NormalAveragingMode = Mesh.normalAveragingType.Averaged For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If ' generates a random color Dim red As Integer = CInt(y * y * 30) Dim green As Integer = CInt(x * x * 30) Dim blue As Integer = CInt(255 - f * f * 1000) ' clamps color values lat 0-255 Utility.LimitRange(Of Integer)(0, red, 255) Utility.LimitRange(Of Integer)(0, green, 255) Utility.LimitRange(Of Integer)(0, blue, 255) vertices.Add(New PointRGB(x, y, f, CByte(red), CByte(green), CByte(blue))) Next Next Dim triangles As New List(Of SmoothTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 triangles.Add(New SmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1)) triangles.Add(New SmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols)) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() viewportLayout.Entities.Add(surface, 0) End Sub Public Shared Sub TexturedSmooth(viewportLayout As ViewportLayout) Dim vertices As New List(Of Point3D)(rows * cols) Dim texCoords As New List(Of Point2D)(rows * cols) Dim surface As New Mesh() For j As Integer = 0 To rows - 1 For i As Integer = 0 To cols - 1 Dim x As Double = -i / 5.0 - 2 Dim y As Double = -j / 5.0 - 2 Dim f As Double = 0 Dim den As Double = Math.Sqrt(x * x + y * y) If den <> 0 Then f = scale * Math.Sin(Math.Sqrt(x * x + y * y)) / den End If vertices.Add(New Point3D(x, y, f)) texCoords.Add(New Point2D((-x * 5) / (rows - 1), (-y * 5) / (cols - 1))) Next Next Dim bmp As New Bitmap(Properties.Resources.Smiley) Dim mat As New Material(bmp) viewportLayout.Materials.Add("test", mat) Dim triangles As New List(Of RichSmoothTriangle)((rows - 1) * (cols - 1) * 2) For j As Integer = 0 To (rows - 1) - 1 For i As Integer = 0 To (cols - 1) - 1 Dim tri As New RichSmoothTriangle(i + j * cols, i + j * cols + 1, i + (j + 1) * cols + 1) tri.T1 = tri.V1 tri.T2 = tri.V2 tri.T3 = tri.V3 triangles.Add(tri) tri = New RichSmoothTriangle(i + j * cols, i + (j + 1) * cols + 1, i + (j + 1) * cols) tri.T1 = tri.V1 tri.T2 = tri.V2 tri.T3 = tri.V3 triangles.Add(tri) Next Next surface.Vertices = vertices.ToArray() surface.Triangles = triangles.ToArray() surface.TextureCoords = texCoords.ToArray() surface.MaterialName = "test" surface.ColorMethod = colorMethodType.byEntity viewportLayout.Entities.Add(surface, 0) End Sub End Class End Namespace
System.Object
devDept.Eyeshot.Entities.Entity
devDept.Eyeshot.Entities.Mesh
devDept.Eyeshot.Entities.Solid.Portion
devDept.Eyeshot.Entities.Solid3D.TessellationMesh
devDept.Eyeshot.Translators.IfcMesh