private Model3DGroup CopyToWPFThread(Model3DGroup src_model) { /** disassemble */ var geometrymodel = src_model.Children[0] as GeometryModel3D; var geometry = geometrymodel.Geometry as MeshGeometry3D; string str_vertices = geometry.Positions.ToString(); string str_normals = geometry.Normals.ToString(); string str_indices = geometry.TriangleIndices.ToString(); string str_textures = geometry.TextureCoordinates.ToString(); Model3DGroup result_model = null; Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { result_model = new Model3DGroup(); result_model.Children.Add(new GeometryModel3D() { Geometry = new MeshGeometry3D() { /** re-assemble */ Positions = Point3DCollection.Parse(str_vertices), Normals = Vector3DCollection.Parse(str_normals), TriangleIndices = Int32Collection.Parse(str_indices), TextureCoordinates = PointCollection.Parse(str_textures) }, Material = new DiffuseMaterial(new ImageBrush(new BitmapImage(new Uri(@"image/marble.jpg", UriKind.Relative)))) }); })); return(result_model); }
/// <summary>Initializes the boid.</summary> /// <param name="colors">The boids color's, Item1 for Material and Item2 for BackMaterial.</param> public Boid(Tuple<Color,Color> colors) { if (colors == null) throw new ArgumentNullException("colors"); // Store the colors _colors = colors; _materialBrush = new SolidColorBrush(colors.Item1); _backmaterialBrush = new SolidColorBrush(colors.Item2); // Set up the boid's model base.Content = new GeometryModel3D() { Material = new DiffuseMaterial(_materialBrush), BackMaterial = new DiffuseMaterial(_backmaterialBrush), Geometry = new MeshGeometry3D() { // Two perpendicular triangles pointing up Positions = Point3DCollection.Parse("0 1 0 1 -1 0 -1 -1 0 0 1 0 0 -1 1 0 -1 -1"), Normals = Vector3DCollection.Parse("0 0 -1 1 0 0"), TriangleIndices = Int32Collection.Parse("0 1 2 3 4 5") } }; // Initialize its rotation and translation _rotation = new AxisAngleRotation3D(UNIT_Y, 0); _translation = new TranslateTransform3D(new Vector3D()); // Add all of the necessary transforms var t = new Transform3DGroup(); t.Children.Add(new ScaleTransform3D(MODEL_SCALE, MODEL_SCALE, MODEL_SCALE)); t.Children.Add(new RotateTransform3D(_rotation)); t.Children.Add(_translation); base.Transform = t; }
public static MeshGeometry3D CreateSquareGeometry(string positions) { return(new MeshGeometry3D { Positions = Point3DCollection.Parse(positions), TriangleIndices = Int32Collection.Parse("0,1,2 0,2,3"), TextureCoordinates = PointCollection.Parse("0,0 0,1 1,1 1,0"), }); }
/// <summary> /// Converts a string into a Int32Collection. /// </summary> public override object ConvertFromString(string value, IValueSerializerContext context) { if (value != null) { return(Int32Collection.Parse(value)); } else { return(base.ConvertFromString(value, context)); } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null) { throw GetConvertFromException(value); } string source = value as string; if (source != null) { return(Int32Collection.Parse(source)); } return(base.ConvertFrom(context, culture, value)); }
public ChessBoard() { material = new GeometryModel3D(); mesh = new MeshGeometry3D(); material.Geometry = mesh; this.Content = material; this.Mesh.Positions = Point3DCollection.Parse(ChessBoard_Mesh.Positions); this.Mesh.TextureCoordinates = PointCollection.Parse(ChessBoard_Mesh.TextureCoordinates); this.Mesh.TriangleIndices = Int32Collection.Parse(ChessBoard_Mesh.TriangleIndices); DiffuseMaterial mat = new DiffuseMaterial(); mat.Brush = Brushes.White; mat.AmbientColor = Colors.Silver; mat.Color = Colors.Chocolate; material.Material = mat; }
public Bishop() { try { this.Mesh.Normals = Vector3DCollection.Parse(Bishop_Mesh.Normals); this.Mesh.Positions = Point3DCollection.Parse(Bishop_Mesh.Positions); this.Mesh.TextureCoordinates = PointCollection.Parse(Bishop_Mesh.TextureCoordinates); this.Mesh.TriangleIndices = Int32Collection.Parse(Bishop_Mesh.TriangleIndices); //initialize to default position TranslateTransform3D translate = new TranslateTransform3D(-3, 7, 0); this.Transformations.Children.Add(translate); this.UnmutableTransformations.Add(translate); } catch (Exception ex) { } }
/// <summary> /// Initializes a Pawn from its resource file /// </summary> public Pawn() { try { this.Mesh.Positions = Point3DCollection.Parse(Pawn_Mesh.Positions); this.Mesh.TriangleIndices = Int32Collection.Parse(Pawn_Mesh.TriangleIndices); this.Mesh.TextureCoordinates = PointCollection.Parse(Pawn_Mesh.TextureCoordinates); this.Mesh.Normals = Vector3DCollection.Parse(Pawn_Mesh.Normals); //initialize pawn to default position, this centers the pawn in the middle of the board (0,0) and compensates obj imports deviations TranslateTransform3D translate = new TranslateTransform3D(-7, 5, 0); this.Transformations.Children.Add(translate); this.UnmutableTransformations.Add(translate); //RotateTransform3D rotate = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90)); //this.Transformations.Children.Add(rotate); //this.UnmutableTransformations.Add(rotate); } catch (Exception ex) { throw; } }
private void LoadQatItems() { if (this.QuickAccessToolBar == null) { this.QuickAccessToolBar = new RibbonQuickAccessToolBar(); } try { string text = Properties.Settings.Default.QuickAccessToolBar; if (!string.IsNullOrEmpty(text)) { List <QatItem> qatItems = text.Split(',').Select(i => Int32Collection.Parse(i)).Select(x => new QatItem() { ControlIndices = x }).ToList(); if ((qatItems != null) && (qatItems.Count > 0)) { SearchInApplicationMenu(qatItems); SearchInTabs(qatItems); qatItems.Where(qat => qat.Owner != null).ToList().ForEach(qat => { if (RibbonCommands.AddToQuickAccessToolBarCommand.CanExecute(null, qat.Owner)) { RibbonCommands.AddToQuickAccessToolBarCommand.Execute(null, qat.Owner); } }); } } } catch { } this.QuickAccessToolBar.ItemContainerGenerator.ItemsChanged += OnQuickAccessToolBarItemsChanged; }
// Token: 0x06002280 RID: 8832 RVA: 0x000AB618 File Offset: 0x000A9818 public override bool ConvertStringToCustomBinary(BinaryWriter writer, string stringValue) { Int32Collection int32Collection = Int32Collection.Parse(stringValue); int num = 0; int count = int32Collection.Count; bool flag = true; bool flag2 = true; for (int i = 1; i < count; i++) { int num2 = int32Collection.Internal_GetItem(i - 1); int num3 = int32Collection.Internal_GetItem(i); if (flag && num2 + 1 != num3) { flag = false; } if (num3 < 0) { flag2 = false; } if (num3 > num) { num = num3; } } if (flag) { writer.Write(1); writer.Write(count); writer.Write(int32Collection.Internal_GetItem(0)); } else { XamlInt32CollectionSerializer.IntegerCollectionType value; if (flag2 && num <= 255) { value = XamlInt32CollectionSerializer.IntegerCollectionType.Byte; } else if (flag2 && num <= 65535) { value = XamlInt32CollectionSerializer.IntegerCollectionType.UShort; } else { value = XamlInt32CollectionSerializer.IntegerCollectionType.Integer; } writer.Write((byte)value); writer.Write(count); switch (value) { case XamlInt32CollectionSerializer.IntegerCollectionType.Byte: for (int j = 0; j < count; j++) { writer.Write((byte)int32Collection.Internal_GetItem(j)); } break; case XamlInt32CollectionSerializer.IntegerCollectionType.UShort: for (int k = 0; k < count; k++) { writer.Write((ushort)int32Collection.Internal_GetItem(k)); } break; case XamlInt32CollectionSerializer.IntegerCollectionType.Integer: for (int l = 0; l < count; l++) { writer.Write(int32Collection.Internal_GetItem(l)); } break; } } return(true); }
/// <summary> /// Convert a string into a compact binary representation and write it out /// to the passed BinaryWriter. /// </summary> public override bool ConvertStringToCustomBinary( BinaryWriter writer, // Writer into the baml stream string stringValue) // String to convert { #if PBTCOMPILER List <IntegerMarkup> ints = Parse(stringValue); #else Int32Collection ints = Int32Collection.Parse(stringValue); #endif int cur, last, count, max = 0; count = ints.Count; // loop through the collection testing for // if the numbers are consecutive, and what's the max. bool consecutive = true; bool allPositive = true; for (int i = 1; i < count; i++) { #if PBTCOMPILER last = ints[i - 1].Value; cur = ints[i].Value; #else last = ints.Internal_GetItem(i - 1); cur = ints.Internal_GetItem(i); #endif if (consecutive && (last + 1 != cur)) { consecutive = false; } // // If any number is negative - we will just use Integer type. // // We could handle this by encoding the min/max and creating a different number of bit encoding. // For now - we're seeing enough gains with this change. // if (cur < 0) { allPositive = false; } if (cur > max) { max = cur; } } if (consecutive) { writer.Write((byte)IntegerCollectionType.Consecutive); writer.Write(count); // Write the count // Write the first number. #if PBTCOMPILER writer.Write(ints[0].Value); #else writer.Write(ints.Internal_GetItem(0)); #endif } else { IntegerCollectionType type; if (allPositive && max <= 255) { type = IntegerCollectionType.Byte; } else if (allPositive && max <= UInt16.MaxValue) { type = IntegerCollectionType.UShort; } else { type = IntegerCollectionType.Integer; } writer.Write((byte)type); writer.Write(count); // Write the count switch (type) { case IntegerCollectionType.Byte: { for (int i = 0; i < count; i++) { writer.Write((byte) #if PBTCOMPILER ints[i].Value #else ints.Internal_GetItem(i) #endif ); } } break; case IntegerCollectionType.UShort: { for (int i = 0; i < count; i++) { writer.Write((ushort) #if PBTCOMPILER ints[i].Value #else ints.Internal_GetItem(i) #endif ); } } break; case IntegerCollectionType.Integer: { for (int i = 0; i < count; i++) { writer.Write( #if PBTCOMPILER ints[i].Value #else ints.Internal_GetItem(i) #endif ); } } break; } } return(true); }