本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddRectangularMesh方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddRectangularMesh方法的具体用法?C# MeshBuilder.AddRectangularMesh怎么用?C# MeshBuilder.AddRectangularMesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HelixToolkit.Wpf.MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.AddRectangularMesh方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateModel
private Model3D CreateModel()
{
var plotModel = new Model3DGroup();
int rows = Points.GetUpperBound(0) + 1;
int columns = Points.GetUpperBound(1) + 1;
double minX = double.MaxValue;
double maxX = double.MinValue;
double minY = double.MaxValue;
double maxY = double.MinValue;
double minZ = double.MaxValue;
double maxZ = double.MinValue;
double minColorValue = double.MaxValue;
double maxColorValue = double.MinValue;
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
double x = Points[i, j].X;
double y = Points[i, j].Y;
double z = Points[i, j].Z;
maxX = Math.Max(maxX, x);
maxY = Math.Max(maxY, y);
maxZ = Math.Max(maxZ, z);
minX = Math.Min(minX, x);
minY = Math.Min(minY, y);
minZ = Math.Min(minZ, z);
if (ColorValues != null)
{
maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]);
minColorValue = Math.Min(minColorValue, ColorValues[i, j]);
}
}
// make color value 0 at texture coordinate 0.5
if (Math.Abs(minColorValue) < Math.Abs(maxColorValue))
minColorValue = -maxColorValue;
else
maxColorValue = -minColorValue;
// set the texture coordinates by z-value or ColorValue
var texcoords = new Point[rows,columns];
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
double u = (Points[i, j].Z - minZ)/(maxZ - minZ);
if (ColorValues != null)
u = (ColorValues[i, j] - minColorValue)/(maxColorValue - minColorValue);
texcoords[i, j] = new Point(u, u);
}
var surfaceMeshBuilder = new MeshBuilder();
surfaceMeshBuilder.AddRectangularMesh(Points, texcoords);
var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
surfaceModel.BackMaterial = surfaceModel.Material;
var axesMeshBuilder = new MeshBuilder();
for (double x = minX; x <= maxX; x += IntervalX)
{
double j = (x - minX)/(maxX - minX)*(columns - 1);
var path = new List<Point3D> {new Point3D(x, minY, minZ)};
for (int i = 0; i < rows; i++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(x, maxY, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize,
new Point3D(x, minY - FontSize*2.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize,
new Point3D((minX + maxX)*0.5,
minY - FontSize*6, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
for (double y = minY; y <= maxY; y += IntervalY)
{
double i = (y - minY)/(maxY - minY)*(rows - 1);
var path = new List<Point3D> {new Point3D(minX, y, minZ)};
for (int j = 0; j < columns; j++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(maxX, y, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize,
new Point3D(minX - FontSize*3, y, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
//.........这里部分代码省略.........
示例2: CreateModel
private Model3D CreateModel()
{
if (Points == null || Points.Length == 0) return null;
var plotModel = new Model3DGroup();
int rows = Points.GetUpperBound(0) + 1;
int columns = Points.GetUpperBound(1) + 1;
double minX = double.MaxValue;
double maxX = double.MinValue;
double minY = double.MaxValue;
double maxY = double.MinValue;
double minZ = double.MaxValue;
double maxZ = double.MinValue;
double minColorValue = double.MaxValue;
double maxColorValue = double.MinValue;
minX = Points.OfType<Point3D>().Min(x => x.X);
maxX = Points.OfType<Point3D>().Max(x => x.X);
minY = Points.OfType<Point3D>().Min(x => x.Y);
maxY = Points.OfType<Point3D>().Max(x => x.Y);
minZ = Points.OfType<Point3D>().Min(x => x.Z);
maxZ = Points.OfType<Point3D>().Max(x => x.Z);
if (ColorValues != null) minColorValue = ColorValues.OfType<double>().Min(x => x);
if (ColorValues != null) maxColorValue = ColorValues.OfType<double>().Max(x => x);
if (Functions.Abs(minColorValue) < Functions.Abs(maxColorValue))
minColorValue = -maxColorValue;
else
maxColorValue = -minColorValue;
BitmapPixelMaker bm_maker =
new BitmapPixelMaker(columns, rows);
for (int ix = 0; ix < columns; ix++)
{
for (int iy = 0; iy < rows; iy++)
{
try
{
byte red, green, blue;
MapRainbowColor(Points[ix, iy].Z, minZ, maxZ,
out red, out green, out blue);
bm_maker.SetPixel(ix, iy, red, green, blue, 255);
}
catch
{
}
}
}
var texcoords = new Point[rows, columns];
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
texcoords[i, j] = new Point(i, j);
}
var surfaceMeshBuilder = new MeshBuilder();
surfaceMeshBuilder.AddRectangularMesh(Points, texcoords);
var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(new ImageBrush(bm_maker.MakeBitmap(128, 128)), null, null, 1, 0));
surfaceModel.BackMaterial = surfaceModel.Material;
var axesMeshBuilder = new MeshBuilder();
for (double x = minX; x <= maxX; x += IntervalX)
{
double j = (x - minX) / (maxX - minX) * (columns - 1);
var path = new List<Point3D> {new Point3D(x, minY, minZ)};
for (int i = 0; i < rows; i++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(x, maxY, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true,
FontSize * 3,
new Point3D(x, minY - FontSize * 2.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Axe réel", Brushes.Black, true,
FontSize * 10,
new Point3D((minX + maxX) * 0.25,
minY - FontSize * 6 - 0.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
for (double y = minY; y <= maxY; y += IntervalY)
{
double i = (y - minY) / (maxY - minY) * (rows - 1);
var path = new List<Point3D> {new Point3D(minX, y, minZ)};
for (int j = 0; j < columns; j++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(maxX, y, minZ));
//.........这里部分代码省略.........
示例3: CreateModel
private Model3D CreateModel()
{
// if (Points ==null)
var plotModel = new Model3DGroup();
int rows = Points.GetUpperBound(0) + 1;
int columns = Points.GetUpperBound(1) + 1;
double minX = double.MaxValue;
double maxX = double.MinValue;
double minY = double.MaxValue;
double maxY = double.MinValue;
double minZ = double.MaxValue;
double maxZ = double.MinValue;
//double RealminX = double.MaxValue;
//double RealmaxX = double.MinValue;
//double RealminY = double.MaxValue;
//double RealmaxY = double.MinValue;
//double RealminZ = double.MaxValue;
//double RealmaxZ = double.MinValue;
#region Color things
double minColorValue = double.MaxValue;
double maxColorValue = double.MinValue;
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
double x = Points[i, j].X;
double y = Points[i, j].Y;
double z = Points[i, j].Z;
maxX = Math.Max(maxX, x);
maxY = Math.Max(maxY, y);
maxZ = Math.Max(maxZ, z);
minX = Math.Min(minX, x);
minY = Math.Min(minY, y);
minZ = Math.Min(minZ, z);
if (ColorValues != null)
{
maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]);
minColorValue = Math.Min(minColorValue, ColorValues[i, j]);
}
}
// make color value 0 at texture coordinate 0.5
if (Math.Abs(minColorValue) < Math.Abs(maxColorValue))
minColorValue = -maxColorValue;
else
maxColorValue = -minColorValue;
#endregion
// set the texture coordinates by z-value or ColorValue
var texcoords = new Point[rows,columns];
if (OriginalData == null || ColorCoding != ComplexPlainVisualizer.ColorCoding.Custom)
{
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
double u = (Points[i, j].Z - minZ) / (maxZ - minZ);
//double v =
if (ColorValues != null)
u = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue);
texcoords[i, j] = new Point(u, u);
}
}
else
{
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
double u = MathUtil.Scale(minZ, maxZ, Math.Log10(OriginalData[i, j].Z), 0.5);
double v = OriginalData[i, j].W;
double uu = 0.5 + u * Math.Cos(v);
double vv = 0.5 + u * Math.Sin(v);
texcoords[i, j] = new Point(uu, vv);
}
}
if (AutoScale)
{
ScaleX =10 / Math.Abs(maxX - minX);
ScaleY =10/ Math.Abs(maxY - minY);
ScaleZ =5 / Math.Abs(maxZ - minZ);
}
var surfaceMeshBuilder = new MeshBuilder();
surfaceMeshBuilder.AddRectangularMesh(Points, texcoords);
surfaceMeshBuilder.Scale(ScaleX, ScaleY, ScaleZ);
var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
surfaceModel.BackMaterial = surfaceModel.Material;
//RealmaxX = maxX;
//RealminX = minX;
//.........这里部分代码省略.........
示例4: CreateInitialMesh
private void CreateInitialMesh()
{
var pts = new Point3D[n, m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
{
pts[i, j] = new Point3D(-Length * j / (m - 1), 0, PoleHeight - Height * i / (n - 1));
}
var mb = new MeshBuilder(false, true);
mb.AddRectangularMesh(pts, null, false, false);
Mesh = mb.ToMesh();
}
示例5: CreateModel
/// <summary>
/// This function contains all the "business logic" for constructing a SurfacePlot 3D.
/// </summary>
/// <returns>A Model3DGroup containing all the component models (mesh, surface definition, grid objects, etc).</returns>
private Model3DGroup CreateModel()
{
var newModelGroup = new Model3DGroup();
double lineThickness = 0.01;
double axesOffset = 0.05;
// Get relevant constaints from the DataPoints object
int numberOfRows = DataPoints.GetUpperBound(0) + 1;
int numberOfColumns = DataPoints.GetUpperBound(1) + 1;
// Determine the x, y, and z ranges of the DataPoints collection
double minX = double.MaxValue;
double maxX = double.MinValue;
double minY = double.MaxValue;
double maxY = double.MinValue;
double minZ = double.MaxValue;
double maxZ = double.MinValue;
double minColorValue = double.MaxValue;
double maxColorValue = double.MinValue;
for (int i = 0; i < numberOfRows; i++)
{
for (int j = 0; j < numberOfColumns; j++)
{
double x = DataPoints[i, j].X;
double y = DataPoints[i, j].Y;
double z = DataPoints[i, j].Z;
maxX = Math.Max(maxX, x);
maxY = Math.Max(maxY, y);
maxZ = Math.Max(maxZ, z);
minX = Math.Min(minX, x);
minY = Math.Min(minY, y);
minZ = Math.Min(minZ, z);
if (ColorValues != null)
{
maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]);
minColorValue = Math.Min(minColorValue, ColorValues[i, j]);
}
}
}
/* TEMP */
int numberOfXAxisTicks = 10;
int numberOfYAxisTicks = 10;
int numberOfZAxisTicks = 5;
double XAxisInterval = (maxX - minX) / numberOfXAxisTicks;
double YAxisInterval = (maxY - minY) / numberOfYAxisTicks;
double ZAxisInterval = (maxZ - minZ) / numberOfZAxisTicks;
/* /TEMP */
// Set color value to 0 at texture coordinate 0.5, with an even spread in either direction
if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) { minColorValue = -maxColorValue; }
else { maxColorValue = -minColorValue; }
// Set the texture coordinates by either z-value or ColorValue
var textureCoordinates = new Point[numberOfRows, numberOfColumns];
for (int i = 0; i < numberOfRows; i++)
{
for (int j = 0; j < numberOfColumns; j++)
{
double tc;
if (ColorValues != null) { tc = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); }
else { tc = (DataPoints[i, j].Z - minZ) / (maxZ - minZ); }
textureCoordinates[i, j] = new Point(tc, tc);
}
}
// Build the surface model (i.e. the coloured surface model)
MeshBuilder surfaceModelBuilder = new MeshBuilder();
surfaceModelBuilder.AddRectangularMesh(DataPoints, textureCoordinates);
GeometryModel3D surfaceModel = new GeometryModel3D(surfaceModelBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
surfaceModel.BackMaterial = surfaceModel.Material;
// Instantiate MeshBuilder objects for the Grid and SurfaceMeshLines meshes
MeshBuilder surfaceMeshLinesBuilder = new MeshBuilder();
MeshBuilder surfaceContourLinesBuilder = new MeshBuilder();
MeshBuilder gridBuilder = new MeshBuilder();
// Build the axes labels model (i.e. the object that holds the axes labels and ticks)
ModelVisual3D axesLabelsModel = new ModelVisual3D();
// Loop through x intervals - for the surface meshlines, the grid, and X axes ticks
for (double x = minX; x <= maxX + 0.0001; x += XAxisInterval)
{
// Add surface mesh lines which denote intervals along the x-axis
var surfacePath = new List<Point3D>();
double i = (x - minX) / (maxX - minX) * (numberOfColumns - 1);
for (int j = 0; j < numberOfColumns; j++)
{
surfacePath.Add(DoBilinearInterpolation(DataPoints, i, j));
}
surfaceMeshLinesBuilder.AddTube(surfacePath, lineThickness, 9, false);
// Axes labels
//.........这里部分代码省略.........
示例6: CreateModel
/// <summary>
/// Creates the 3D model of the terrain.
/// </summary>
/// <param name="lod">
/// The level of detail.
/// </param>
/// <returns>
/// The Model3D.
/// </returns>
public GeometryModel3D CreateModel(int lod)
{
int ni = this.Height / lod;
int nj = this.Width / lod;
var pts = new List<Point3D>(ni * nj);
double mx = (this.Left + this.Right) / 2;
double my = (this.Top + this.Bottom) / 2;
double mz = (this.MinimumZ + this.MaximumZ) / 2;
this.Offset = new Point3D(mx, my, mz);
for (int i = 0; i < ni; i++)
{
for (int j = 0; j < nj; j++)
{
double x = this.Left + (this.Right - this.Left) * j / (nj - 1);
double y = this.Top + (this.Bottom - this.Top) * i / (ni - 1);
double z = this.Data[i * lod * this.Width + j * lod];
x -= this.Offset.X;
y -= this.Offset.Y;
z -= this.Offset.Z;
pts.Add(new Point3D(x, y, z));
}
}
var mb = new MeshBuilder(false, false);
mb.AddRectangularMesh(pts, nj);
var mesh = mb.ToMesh();
var material = Materials.Green;
if (this.Texture != null)
{
this.Texture.Calculate(this, mesh);
material = this.Texture.Material;
mesh.TextureCoordinates = this.Texture.TextureCoordinates;
}
return new GeometryModel3D { Geometry = mesh, Material = material, BackMaterial = material };
}
示例7: Tessellate
/// <summary>
/// Do the tessellation and return the <see cref="MeshGeometry3D"/>.
/// </summary>
/// <returns>A triangular mesh geometry.</returns>
protected override MeshGeometry3D Tessellate()
{
Vector3D u = this.LengthDirection;
Vector3D w = this.Normal;
Vector3D v = Vector3D.CrossProduct(w, u);
u = Vector3D.CrossProduct(v, w);
u.Normalize();
v.Normalize();
w.Normalize();
double le = this.Length;
double wi = this.Width;
var pts = new List<Point3D>();
for (int i = 0; i < this.DivLength; i++)
{
double fi = -0.5 + ((double)i / (this.DivLength - 1));
for (int j = 0; j < this.DivWidth; j++)
{
double fj = -0.5 + ((double)j / (this.DivWidth - 1));
pts.Add(this.Origin + (u * le * fi) + (v * wi * fj));
}
}
var builder = new MeshBuilder(false, true);
builder.AddRectangularMesh(pts, this.DivWidth);
return builder.ToMesh();
}
示例8: CreateLeftSlice
/// <summary>
/// Raw Left==Helix Front
/// </summary>
/// <param name="plotModel"></param>
/// <param name="brush"></param>
/// <param name="currentPosition"></param>
private void CreateLeftSlice(Model3DGroup plotModel, sysMedia.Brush brush, double currentPosition)
{
var position = currentPosition * _realRect3D.SizeY;
var sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(0, position, _realRect3D.SizeZ),
new Point3D(_realRect3D.SizeX, position, _realRect3D.SizeZ),
new Point3D(0, position, 0),
new Point3D(_realRect3D.SizeX, position, 0)
}, 2);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(brush)));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(_realRect3D.SizeX, position, _realRect3D.SizeZ),
new Point3D(0, position, _realRect3D.SizeZ),
new Point3D(_realRect3D.SizeX, position, 0),
new Point3D(0, position, 0)
}, 2);
var bgBrush = FilpAndRotateImageBrush(brush);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(bgBrush)));
}
示例9: CreateFrontPartSlice
private void CreateFrontPartSlice(Model3DGroup plotModel, double currentPosition)
{
var position = (1 - currentPosition) * _realRect3D.SizeX;
if (position < 0.0)
return;
#region Left
var leftImageBrush = ClipImageBrush(LeftBrush, new Rect(0, 0, 1 - currentPosition, 1));
var sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(0, 0, _realRect3D.SizeZ),
new Point3D(position, 0, _realRect3D.SizeZ),
new Point3D(0, 0, 0),
new Point3D(position, 0, 0)
}, 2);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(leftImageBrush)));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(position, _realRect3D.SizeY, _realRect3D.SizeZ),
new Point3D(0, _realRect3D.SizeY, _realRect3D.SizeZ),
new Point3D(position, _realRect3D.SizeY, 0),
new Point3D(0, _realRect3D.SizeY, 0)
}, 2);
leftImageBrush = ClipImageBrush(RightBrush, new Rect(0, 0, 1 - currentPosition, 1));
var bgBrush = FilpAndRotateImageBrush(leftImageBrush);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(bgBrush)));
#endregion Left
#region Top
var topImageBrush = ClipImageBrush(TopBrush, new Rect(0, 0, 1, 1 - currentPosition));
topImageBrush = RotateImageBrush(topImageBrush, 270);
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(0, _realRect3D.SizeY, _realRect3D.SizeZ),
new Point3D(position, _realRect3D.SizeY, _realRect3D.SizeZ),
new Point3D(0, 0, _realRect3D.SizeZ),
new Point3D(position, 0, _realRect3D.SizeZ)
}, 2);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(topImageBrush)));
sectionMeshBuilder = new MeshBuilder();
//The
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(position, 0, 0),
new Point3D(position, _realRect3D.SizeY, 0),
new Point3D(0, 0, 0),
new Point3D(0, _realRect3D.SizeY, 0)
}, 2);
topImageBrush = ClipImageBrush(BottomBrush, new Rect(0, 0, 1, 1 - currentPosition));
bgBrush = FilpImageBrush(topImageBrush);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(bgBrush)));
#endregion Top
}
示例10: CreateLeftPartSlice
private void CreateLeftPartSlice(Model3DGroup plotModel, double currentPosition)
{
#region Top
var position = currentPosition * _realRect3D.SizeY;
var topImageBrush = ClipImageBrush(TopBrush, new Rect(currentPosition, 0
, 1 - currentPosition, 1));
var sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(0, position, _realRect3D.SizeZ),
new Point3D(0, _realRect3D.SizeY, _realRect3D.SizeZ),
new Point3D(_realRect3D.SizeX, position, _realRect3D.SizeZ),
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, _realRect3D.SizeZ)
}, 2);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(topImageBrush)));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(_realRect3D.SizeX, position, 0),
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, 0),
new Point3D(0, position, 0),
new Point3D(0, _realRect3D.SizeY, 0)
}, 2);
topImageBrush = ClipImageBrush(BottomBrush, new Rect(currentPosition, 0
, 1 - currentPosition, 1));
var bgBrush = topImageBrush;
bgBrush = FilpImageBrush(bgBrush);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(bgBrush)));
#endregion Top
#region Front
var frontImageBrush = ClipImageBrush(FrontBrush, new Rect(currentPosition, 0
, (1 - currentPosition), 1));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(_realRect3D.SizeX, position, _realRect3D.SizeZ),
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, _realRect3D.SizeZ),
new Point3D(_realRect3D.SizeX, position, 0),
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, 0)
}, 2);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(frontImageBrush)));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(0, _realRect3D.SizeY, _realRect3D.SizeZ),
new Point3D(0, position, _realRect3D.SizeZ),
new Point3D(0, _realRect3D.SizeY, 0),
new Point3D(0, position, 0)
}, 2);
frontImageBrush = ClipImageBrush(BackBrush, new Rect(currentPosition, 0
, 1 - currentPosition, 1));
bgBrush = FilpAndRotateImageBrush(frontImageBrush);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(bgBrush)));
#endregion Front
}
示例11: CreateTopPartSlice
private void CreateTopPartSlice(Model3DGroup plotModel, double currentPosition)
{
var position = (1 - currentPosition) * _realRect3D.SizeZ;
if (position < 0.0)
return;
#region Left
var leftImageBrush = ClipImageBrush(LeftBrush,
new Rect(0, currentPosition, 1, 1 - currentPosition));
var sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(0, 0, position),
new Point3D(_realRect3D.SizeX, 0, position),
new Point3D(0, 0, 0),
new Point3D(_realRect3D.SizeX, 0, 0)
}, 2);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(leftImageBrush)));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, position),
new Point3D(0, _realRect3D.SizeY, position),
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, 0),
new Point3D(0, _realRect3D.SizeY, 0)
}, 2);
leftImageBrush = ClipImageBrush(RightBrush,
new Rect(0, currentPosition, 1, 1 - currentPosition));
var bgBrush = FilpAndRotateImageBrush(leftImageBrush);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(bgBrush)));
#endregion Left
#region Front
var frontImageBrush = ClipImageBrush(FrontBrush,
new Rect(0, currentPosition, 1, 1 - currentPosition));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(_realRect3D.SizeX, 0, position),
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, position),
new Point3D(_realRect3D.SizeX, 0, 0),
new Point3D(_realRect3D.SizeX, _realRect3D.SizeY, 0)
}, 2);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(frontImageBrush)));
sectionMeshBuilder = new MeshBuilder();
sectionMeshBuilder.AddRectangularMesh(
new[]
{
new Point3D(0, _realRect3D.SizeY, position),
new Point3D(0, 0, position),
new Point3D(0, _realRect3D.SizeY, 0),
new Point3D(0, 0, 0)
}, 2);
frontImageBrush = ClipImageBrush(BackBrush,
new Rect(0, currentPosition, 1, 1 - currentPosition));
bgBrush = FilpAndRotateImageBrush(frontImageBrush);
plotModel.Children.Add(new GeometryModel3D(sectionMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(bgBrush)));
#endregion Front
}
示例12: CreateModel
//.........这里部分代码省略.........
ynBrush.Viewbox = new Rect(0, 0, c, 1);
ypBrush.Viewbox = new Rect(0, 0, c, 1);
xnBrush.Viewbox = new Rect(0, 0, 1, c);
xpBrush.Viewbox = new Rect(0, 0, 1, c);
expBrush.Viewbox = new Rect(0, 0, 1, c);
}
break;
case CooridinateDirection.ZN:
{
rectDraw.Z = SectionPosition;
rectDraw.SizeZ -= rectDraw.Z;
znBrush = SectionBrush.Clone();
double c = SectionPosition / _realRect3D.SizeZ;
ynBrush.Viewbox = new Rect(c, 0, 1 - c, 1);
ypBrush.Viewbox = new Rect(c, 0, 1 - c, 1);
xnBrush.Viewbox = new Rect(0, c, 1, 1 - c);
xpBrush.Viewbox = new Rect(0, c, 1, 1 - c);
expBrush.Viewbox = new Rect(0, c, 1, 1 - c);
}
break;
default:
break;
}
}
MeshBuilder mb = null;
if (!isCylindarMode)
{
// draw faces in z directions
mb = new MeshBuilder();
mb.AddRectangularMesh(
new[] {
new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z), //0,0,0
new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z), //1,0,0
new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z), //0,1,0
new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z) //1,1,0
}, 2);
plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(znBrush)));
mb = new MeshBuilder(); mb.AddRectangularMesh(
new[] {
new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ), // 0,1,1
new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ), // 1,1,1
new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ), // 0,0,1
new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ) // 1,0,1
}
, 2);
plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(zpBrush)));
// draw faces in y directions
mb = new MeshBuilder();
mb.AddRectangularMesh(
new[] {
new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z),
new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ),
new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z),
new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ)
}, 2);
plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(ynBrush)));