本文整理汇总了C#中System.Windows.Media.Media3D.Model3DGroup.TransformScale方法的典型用法代码示例。如果您正苦于以下问题:C# Model3DGroup.TransformScale方法的具体用法?C# Model3DGroup.TransformScale怎么用?C# Model3DGroup.TransformScale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Media3D.Model3DGroup
的用法示例。
在下文中一共展示了Model3DGroup.TransformScale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadModelAsteroidVolmetic
// For a 1024 cubed asteroid, it takes approximately 6.5Gb of system memory.
public static MyVoxelMap ReadModelAsteroidVolmetic(Model3DGroup model, IList<MyMeshModel> mappedMesh, ScaleTransform3D scale, Transform3D rotateTransform, TraceType traceType, TraceCount traceCount, TraceDirection traceDirection,
Action<double, double> resetProgress, Action incrementProgress, Func<bool> checkCancel, Action complete)
{
var traceDirectionCount = 0;
var materials = new List<byte>();
var faceMaterials = new List<byte>();
foreach (var mesh in mappedMesh)
{
if (string.IsNullOrEmpty(mesh.Material))
materials.Add(0xff); // represent empty materials.
else
materials.Add(SpaceEngineersCore.Resources.GetMaterialIndex(mesh.Material));
if (string.IsNullOrEmpty(mesh.FaceMaterial))
faceMaterials.Add(0xff); // represent empty materials.
else
faceMaterials.Add(SpaceEngineersCore.Resources.GetMaterialIndex(mesh.FaceMaterial));
}
// How far to check in from the proposed Volumetric edge.
// This number is just made up, but small enough that it still represents the corner edge of the Volumetric space.
// But still large enough that it isn't the exact corner.
const double offset = 0.0000045f;
if (scale.ScaleX > 0 && scale.ScaleY > 0 && scale.ScaleZ > 0 && scale.ScaleX != 1.0f && scale.ScaleY != 1.0f && scale.ScaleZ != 1.0f)
{
model.TransformScale(scale.ScaleX, scale.ScaleY, scale.ScaleZ);
}
// Attempt to offset the model, so it's only caulated from zero (0) and up, instead of using zero (0) as origin.
//model.Transform = new TranslateTransform3D(-model.Bounds.X, -model.Bounds.Y, -model.Bounds.Z);
var tbounds = model.Bounds;
Matrix3D? rotate = null;
if (rotateTransform != null)
{
rotate = rotateTransform.Value;
tbounds = rotateTransform.TransformBounds(tbounds);
}
//model.Transform = new TranslateTransform3D(-tbounds.X, -tbounds.Y, -tbounds.Z);
// Add 2 to either side, to allow for material padding to expose internal materials.
var xMin = (int)Math.Floor(tbounds.X) - 2;
var yMin = (int)Math.Floor(tbounds.Y) - 2;
var zMin = (int)Math.Floor(tbounds.Z) - 2;
var xMax = (int)Math.Ceiling(tbounds.X + tbounds.SizeX) + 2;
var yMax = (int)Math.Ceiling(tbounds.Y + tbounds.SizeY) + 2;
var zMax = (int)Math.Ceiling(tbounds.Z + tbounds.SizeZ) + 2;
var xCount = (xMax - xMin).RoundUpToNearest(64);
var yCount = (yMax - yMin).RoundUpToNearest(64);
var zCount = (zMax - zMin).RoundUpToNearest(64);
Debug.WriteLine("Approximate Size: {0}x{1}x{2}", Math.Ceiling(tbounds.X + tbounds.SizeX) - Math.Floor(tbounds.X), Math.Ceiling(tbounds.Y + tbounds.SizeY) - Math.Floor(tbounds.Y), Math.Ceiling(tbounds.Z + tbounds.SizeZ) - Math.Floor(tbounds.Z));
Debug.WriteLine("Bounds Size: {0}x{1}x{2}", xCount, yCount, zCount);
var finalCubic = ArrayHelper.Create<byte>(xCount, yCount, zCount);
var finalMater = ArrayHelper.Create<byte>(xCount, yCount, zCount);
if (resetProgress != null)
{
long triangles = (from GeometryModel3D gm in model.Children select gm.Geometry as MeshGeometry3D).Aggregate<MeshGeometry3D, long>(0, (current, g) => current + (g.TriangleIndices.Count / 3));
long rays = 0;
if ((traceDirection & TraceDirection.X) == TraceDirection.X)
rays += ((yMax - yMin) * (zMax - zMin));
if ((traceDirection & TraceDirection.Y) == TraceDirection.Y)
rays += ((xMax - xMin) * (zMax - zMin));
if ((traceDirection & TraceDirection.Z) == TraceDirection.Z)
rays += ((xMax - xMin) * (yMax - yMin));
resetProgress.Invoke(0, rays * triangles);
}
if (checkCancel != null && checkCancel.Invoke())
{
if (complete != null)
complete.Invoke();
return null;
}
#region basic ray trace of every individual triangle.
// Start from the last mesh, which represents the bottom of the UI stack, and overlay each other mesh on top of it.
for (var modelIdx = mappedMesh.Count - 1; modelIdx >= 0; modelIdx--)
{
Debug.WriteLine("Model {0}", modelIdx);
var modelCubic = new byte[xCount][][];
var modelMater = new byte[xCount][][];
for (var x = 0; x < xCount; x++)
{
modelCubic[x] = new byte[yCount][];
modelMater[x] = new byte[yCount][];
for (var y = 0; y < yCount; y++)
//.........这里部分代码省略.........