本文整理汇总了C#中System.Windows.Media.Media3D.Model3DGroup.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# Model3DGroup.Freeze方法的具体用法?C# Model3DGroup.Freeze怎么用?C# Model3DGroup.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Media3D.Model3DGroup
的用法示例。
在下文中一共展示了Model3DGroup.Freeze方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// create square model
/// </summary>
/// <param name="modelColor">model color</param>
/// <param name="points">model points</param>
/// <returns>model3d group</returns>
public Model3DGroup Create(Color modelColor, Point3D[] points)
{
try
{
Point[] texturepoint0 = { new Point(0, 0), new Point(0, 1), new Point(1, 0) };
Point[] texturepoint1 = { new Point(1, 0), new Point(0, 1), new Point(1, 1) };
SolidColorBrush modelbrush = new SolidColorBrush(modelColor);
modelbrush.Freeze();
Model3DGroup bottomside = new Model3DGroup();
bottomside.Children.Add(CreateGeoModel3D(points[2], points[3], points[0], modelbrush));
bottomside.Children.Add(CreateGeoModel3D(points[2], points[0], points[1], modelbrush));
bottomside.Freeze();
Model3DGroup topside = new Model3DGroup();
topside.Children.Add(CreateGeoModel3D(points[7], points[6], points[5], modelbrush));
topside.Children.Add(CreateGeoModel3D(points[7], points[5], points[4], modelbrush));
topside.Freeze();
Model3DGroup rightside = new Model3DGroup();
rightside.Children.Add(CreateGeoModel3D(points[2], points[1], points[5], modelbrush));
rightside.Children.Add(CreateGeoModel3D(points[2], points[5], points[6], modelbrush));
rightside.Freeze();
Model3DGroup leftside = new Model3DGroup();
leftside.Children.Add(CreateGeoModel3D(points[0], points[3], points[7], modelbrush));
leftside.Children.Add(CreateGeoModel3D(points[0], points[7], points[4], modelbrush));
leftside.Freeze();
Model3DGroup frontside = new Model3DGroup();
frontside.Children.Add(CreateGeoModel3D(points[3], points[2], points[6], modelbrush));
frontside.Children.Add(CreateGeoModel3D(points[3], points[6], points[7], modelbrush));
frontside.Freeze();
Model3DGroup backside = new Model3DGroup();
backside.Children.Add(CreateGeoModel3D(points[0], points[4], points[5], modelbrush));
backside.Children.Add(CreateGeoModel3D(points[1], points[0], points[5], modelbrush));
backside.Freeze();
Model3DGroup cube = new Model3DGroup();
cube.Children.Add(bottomside);
cube.Children.Add(topside);
cube.Children.Add(rightside);
cube.Children.Add(leftside);
cube.Children.Add(frontside);
cube.Children.Add(backside);
return cube;
}
catch (Exception ex)
{
throw ex;
}
}
示例2: Transition3D
// static constructor
static Transition3D() {
var defaultLight = new Model3DGroup();
var direction = new Vector3D(1, 1, 1);
direction.Normalize();
byte ambient = 108; // 108 is minimum for directional to be < 256 (for direction = [1,1,1])
byte directional = (byte)Math.Min((255 - ambient) / Vector3D.DotProduct(direction, new Vector3D(0, 0, 1)), 255);
defaultLight.Children.Add(new AmbientLight(Color.FromRgb(ambient, ambient, ambient)));
defaultLight.Children.Add(new DirectionalLight(Color.FromRgb(directional, directional, directional), direction));
defaultLight.Freeze();
LightProperty = DependencyProperty.Register("Light", typeof(Model3D), typeof(Transition3D), new UIPropertyMetadata(defaultLight));
}
示例3: ToModel3D
/// <summary>
/// Builds the model.
/// </summary>
/// <returns>The model.</returns>
public Model3DGroup ToModel3D()
{
Model3DGroup modelGroup = null;
this.Dispatch(
() =>
{
modelGroup = new Model3DGroup();
int i = 0;
foreach (var mesh in this.Meshes)
{
var gm = new GeometryModel3D
{
Geometry = mesh.ToMesh(),
Material = this.Materials[i],
BackMaterial = this.Materials[i]
};
if (this.Freeze)
{
gm.Freeze();
}
modelGroup.Children.Add(gm);
i++;
}
if (this.Freeze)
{
modelGroup.Freeze();
}
});
return modelGroup;
}
示例4: CreateModel3D
/// <summary>
/// Creates a <see cref="Model3DGroup" /> from the loaded file.
/// </summary>
/// <returns>A <see cref="Model3DGroup" />.</returns>
public Model3DGroup CreateModel3D()
{
Model3DGroup modelGroup = null;
this.Dispatch(
() =>
{
modelGroup = new Model3DGroup();
var g = this.CreateMeshGeometry3D();
var gm = new GeometryModel3D { Geometry = g, Material = this.DefaultMaterial };
gm.BackMaterial = gm.Material;
if (this.Freeze)
{
gm.Freeze();
}
modelGroup.Children.Add(gm);
if (this.Freeze)
{
modelGroup.Freeze();
}
});
return modelGroup;
}
示例5: CreateMockModel
private Model3DGroup CreateMockModel(ImageSource image, double width, double height)
{
//Создаем фон
Point3D p1 = new Point3D(0, 0, 0);
Point3D p2 = new Point3D(0, width, 0);
Point3D p3 = new Point3D(height, width, 0);
Point3D p4 = new Point3D(height, 0, 0);
ImageBrush brush = new ImageBrush(image);
//добавляем фон в группу
Model3DGroup background = new Model3DGroup();
background.Children.Add(CreateBackgroundModelGroup(p1, p2, p3, p4, brush));
background.Freeze();
return background;
}
示例6: GetNewStitching
public Model3DGroup GetNewStitching()
{
//if (!m_stitchingHasChanged || !m_hasStitching)
// return null;
m_stitchingHasChanged = false;
Model3DGroup model = new Model3DGroup();
for (int i = 0; i < 3; i++)
{
if (m_stitchingGeometry[i] != null)
model.Children.Add(m_stitchingGeometry[i]);
}
model.Freeze();
return model;
}
示例7: UpdateCurrentTile
private void UpdateCurrentTile(PointCloudTile tile)
{
if (tile == null)
return;
List<PointCloudTile> tilesToLoad = new List<PointCloudTile>();
int pointsToLoad = 0;
Model3DGroup emptyModelGroup = new Model3DGroup();
emptyModelGroup.Freeze();
bool isDirty = false;
int radius = 2;
int xMin = Math.Max(0, tile.Col - radius);
int xMax = Math.Min(tile.Col + radius + 1, CurrentTileSource.TileSet.Cols);
int yMin = Math.Max(0, tile.Row - radius);
int yMax = Math.Min(tile.Row + radius + 1, CurrentTileSource.TileSet.Rows);
for (int x = xMin; x < xMax; x++)
{
for (int y = yMin; y < yMax; y++)
{
PointCloudTile currentTile = CurrentTileSource.TileSet.GetTile(y, x);
if (currentTile != null)
{
if (!m_loadedTiles.ContainsKey(currentTile))
{
tilesToLoad.Add(currentTile);
pointsToLoad += currentTile.PointCount;
isDirty = true;
}
}
}
}
PointCloudTile[] loadedTiles = m_loadedTiles.Keys.ToArray();
SortByDistanceFromTile(loadedTiles, tile);
Array.Reverse(loadedTiles);
// drop loaded tiles that are the farthest from the center
int totalAllowedPoints = MAX_BUFFER_SIZE_BYTES / CurrentTileSource.PointSizeBytes;
int loadedPoints = loadedTiles.Sum(t => t.PointCount);
int potentialTotalPoints = loadedPoints + pointsToLoad;
Dictionary<PointCloudTile, TileInfo3D> alteredTiles = new Dictionary<PointCloudTile, TileInfo3D>();
if (potentialTotalPoints > totalAllowedPoints)
{
int pointsToDrop = potentialTotalPoints - totalAllowedPoints;
int i = 0;
while (pointsToDrop > 0)
{
PointCloudTile currentTile = loadedTiles[i];
TileInfo3D tileInfo = m_tileInfo[currentTile];
GeometryModel3D model = m_loadedTiles[currentTile];
m_meshTileMap.Remove(model);
m_loadedTiles.Remove(currentTile);
//m_loadedTileBuffers.Remove(currentTile);
// replace high-res tile with low-res geometry
int modelIndex = tileInfo.Tile.ValidIndex;
m_tileModelCollection[modelIndex] = tileInfo.LowResGeometry;
// clear stitching
m_stitchingModelCollection[modelIndex] = emptyModelGroup;
tileInfo.ClearGeometry();
alteredTiles.Add(currentTile, tileInfo);
pointsToDrop -= currentTile.PointCount;
++i;
}
}
Jacere.Core.Geometry.Point3D centerOfMass = CurrentTileSource.CenterOfMass;
PointCloudTile[] tilesToLoadArray = tilesToLoad.ToArray();
#warning sort so that disk reads are in order? or make a tile cache
SortByDistanceFromTile(tilesToLoadArray, tile);
foreach (PointCloudTile currentTile in tilesToLoadArray)
{
TileInfo3D tileInfo = m_tileInfo[currentTile];
CurrentTileSource.LoadTileGrid(currentTile, m_buffer, m_gridHighRes, m_quantizedGridHighRes);
if (ENABLE_HEIGHT_EXAGGERATION)
m_gridHighRes.Multiply(m_heightExaggerationFactor, (float)centerOfMass.Z);
Jacere.Core.Geometry.Extent3D tileExtent = currentTile.Extent;
MeshGeometry3D mesh = CurrentTileSource.GenerateMesh(m_gridHighRes, tileExtent);
DiffuseMaterial material = new DiffuseMaterial();
if (USE_HIGH_RES_TEXTURE)
{
material.Brush = m_overviewTextureBrush;
mesh.TextureCoordinates = MeshUtils.GeneratePlanarTextureCoordinates(mesh, m_overallCenteredExtent, MathUtils.ZAxis);
}
else
//.........这里部分代码省略.........
示例8: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <returns>A Model3D object.</returns>
private Model3DGroup BuildModel()
{
Model3DGroup modelGroup = null;
this.Dispatch(() =>
{
modelGroup = new Model3DGroup();
foreach (var g in this.Groups)
{
foreach (var gm in g.CreateModels())
{
if (this.Freeze)
{
gm.Freeze();
}
modelGroup.Children.Add(gm);
}
}
if (this.Freeze)
{
modelGroup.Freeze();
}
});
return modelGroup;
}
示例9: Paint3DScena
private void Paint3DScena()
{
//Создаем фон
int width = scenario.map.GetMap().GetLength(0), height = scenario.map.GetMap().GetLength(1);
Point3D p1 = new Point3D(-width / 2, 0, -height / 2);
Point3D p2 = new Point3D(width / 2, 0, -height / 2);
Point3D p3 = new Point3D(width / 2, 0, height / 2);
Point3D p4 = new Point3D(-width / 2, 0, height / 2);
ImageBrush brush;
if (File.Exists(Properties.Settings.Default.ScenarioPath + "image.jpg"))
{
brush = new ImageBrush(new BitmapImage(new Uri(Properties.Settings.Default.ScenarioPath + "image.jpg")));
}
else
{
brush = new ImageBrush(scenario.Image);
}
//добавляем фон в группу
Model3DGroup background = new Model3DGroup();
background.Children.Add(CreateBackgroundModelGroup(p1, p2, p3, p4, brush));
background.Freeze();
ModelVisual3D backgroundModel = new ModelVisual3D();
backgroundModel.Content = background;
//Заполняем ViewPort фоном
mainViewport.Children.Add(backgroundModel);
}
示例10: CreateSquare2D
/// <summary>
/// create square 2D
/// </summary>
/// <param name="pictureName"></param>
/// <param name="points"></param>
/// <returns></returns>
public Model3DGroup CreateSquare2D(string pictureName, Point3D[] points)
{
try
{
Uri inpuri = new Uri(@pictureName, UriKind.Relative);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = inpuri;
bi.EndInit();
ImageBrush imagebrush = new ImageBrush(bi);
imagebrush.Opacity = 100;
imagebrush.Freeze();
Point[] ptexture0 = { new Point(0, 0), new Point(0, 1), new Point(1, 0) };
Point[] ptexture1 = { new Point(1, 0), new Point(0, 1), new Point(1, 1) };
Model3DGroup square = new Model3DGroup();
square.Children.Add(CreateGeoModel2D(points[0], points[3], points[1], ptexture0, imagebrush));
square.Children.Add(CreateGeoModel2D(points[1], points[3], points[2], ptexture1, imagebrush));
square.Freeze();
return square;
}
catch (Exception ex)
{
throw ex;
}
}
示例11: Read
/// <summary>
/// Reads the model from the specified stream.
/// </summary>
/// <param name="s">The stream.</param>
/// <returns>The model.</returns>
public override Model3DGroup Read(Stream s)
{
using (var reader = new BinaryReader(s))
{
long length = reader.BaseStream.Length;
// http://gpwiki.org/index.php/Loading_3ds_files
// http://www.flipcode.com/archives/3DS_File_Loader.shtml
// http://sandy.googlecode.com/svn/trunk/sandy/as3/branches/3.0.2/src/sandy/parser/Parser3DS.as
var headerId = this.ReadChunkId(reader);
if (headerId != ChunkID.MAIN3DS)
{
throw new FileFormatException("Unknown file");
}
int headerSize = this.ReadChunkSize(reader);
if (headerSize != length)
{
throw new FileFormatException("Incomplete file (file length does not match header)");
}
while (reader.BaseStream.Position < reader.BaseStream.Length)
{
var id = this.ReadChunkId(reader);
int size = this.ReadChunkSize(reader);
switch (id)
{
case ChunkID.EDIT_MATERIAL:
this.ReadMaterial(reader, size);
break;
case ChunkID.EDIT_OBJECT:
this.ReadObject(reader, size);
break;
case ChunkID.EDIT3DS:
case ChunkID.OBJ_CAMERA:
case ChunkID.OBJ_LIGHT:
case ChunkID.OBJ_TRIMESH:
// don't read the whole chunk, read the sub-defines...
break;
default:
// download the whole chunk
this.ReadData(reader, size - 6);
break;
}
}
Model3DGroup mg = null;
this.Dispatch(
() =>
{
mg = new Model3DGroup();
foreach (var m in this.meshes)
{
var model = m.CreateModel();
if (this.Freeze)
{
model.Freeze();
}
mg.Children.Add(model);
}
if (this.Freeze)
{
mg.Freeze();
}
});
return mg;
}
}