public Trackball() { _transform = new Transform3DGroup(); _transform.Children.Add( _scale ); _transform.Children.Add( new RotateTransform3D( _rotation ) ); _transform.Children.Add( _translation ); }
public Plant() { var x = new Vector3D(1, 0, 0); var r1 = new RotateTransform3D(new AxisAngleRotation3D(x, 80)); var r2 = new RotateTransform3D(new AxisAngleRotation3D(x, -70)); var r3 = new RotateTransform3D(new AxisAngleRotation3D(x, -10)); var t1 = new TranslateTransform3D(0, 0, 0.5); var t2 = new TranslateTransform3D(0, 0, 0.7); var t3 = new TranslateTransform3D(0, 0, 1.0); var s1 = new ScaleTransform3D(0.5, 0.5, 0.5); var s2 = new ScaleTransform3D(0.3, 0.3, 0.3); var s3 = new ScaleTransform3D(0.8, 0.8, 0.8); var m1 = new Transform3DGroup(); m1.Children.Add(r1); m1.Children.Add(s1); m1.Children.Add(t1); var m2 = new Transform3DGroup(); m2.Children.Add(r2); m2.Children.Add(s2); m2.Children.Add(t2); var m3 = new Transform3DGroup(); m3.Children.Add(r3); m3.Children.Add(s3); m3.Children.Add(t3); T1 = m1; T2 = m2; T3 = m3; }
/// <summary> /// Combines two transforms. /// </summary> /// <param name="t1"> /// The first transform. /// </param> /// <param name="t2"> /// The second transform. /// </param> /// <returns> /// The combined transform group. /// </returns> public static Transform3D CombineTransform(Transform3D t1, Transform3D t2) { var g = new Transform3DGroup(); g.Children.Add(t1); g.Children.Add(t2); return g; }
public static Media3D.Transform3D CreateAnimatedTransform1(Media3D.Transform3DGroup transformGroup, Media3D.Vector3D center, Media3D.Vector3D axis, double speed = 4) { var rotateAnimation = new Rotation3DAnimation { RepeatBehavior = RepeatBehavior.Forever, By = new Media3D.AxisAngleRotation3D(axis, 90), Duration = TimeSpan.FromSeconds(speed / 2), IsCumulative = true, }; var rotateTransform = new Media3D.RotateTransform3D(); rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation); transformGroup.Children.Add(rotateTransform); var rotateAnimation1 = new Rotation3DAnimation { RepeatBehavior = RepeatBehavior.Forever, By = new Media3D.AxisAngleRotation3D(axis, 240), Duration = TimeSpan.FromSeconds(speed / 4), IsCumulative = true, }; var rotateTransform1 = new Media3D.RotateTransform3D(); rotateTransform1.CenterX = center.X; rotateTransform1.CenterY = center.Y; rotateTransform1.CenterZ = center.Z; rotateTransform1.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation1); transformGroup.Children.Add(rotateTransform1); return(transformGroup); }
public Cell(INeuron neuron, ModelVisual3D mophology, Imaging imager) { this.neuron = neuron; this.mophology = mophology; this.imager = imager; neuron.Updated += OnUpdated; neuron.Hillock.Spike += OnSpike; IsPushing = true; var transforms = new Transform3DGroup(); Rotate = new RotateTransform3D(new QuaternionRotation3D()); Translate = new TranslateTransform3D(neuron.Position.X, neuron.Position.Y, neuron.Position.Z); Scale = new ScaleTransform3D(); transforms.Children.Add(Rotate); transforms.Children.Add(Translate); transforms.Children.Add(Scale); Mophology.Transform = transforms; var binding = new Binding() { Source = neuron, Path = new PropertyPath("Position"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(this, Cell.PositionProperty, binding); }
public CellNet(INetwork network, ModelVisual3D mophology, Dictionary<Guid, ICell> cells, Dictionary<Guid, ICellNet> childcellnet) { this.network = network; this.mophology = mophology; this.cells = cells; this.childcellnet = childcellnet; IsPushing = true; var transforms = new Transform3DGroup(); Rotate = new RotateTransform3D(new QuaternionRotation3D()); Translate = new TranslateTransform3D(network.Position.X, network.Position.Y, network.Position.Z); Scale = new ScaleTransform3D(); transforms.Children.Add(Rotate); transforms.Children.Add(Translate); transforms.Children.Add(Scale); Mophology.Transform = transforms; var binding = new Binding() { Source = network, Path = new PropertyPath("Position"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(this, CellNet.PositionProperty, binding); }
protected override Matrix3D PartAnimation( string partName ) { if( partName == "propeller" ) { Transform3DGroup group = new Transform3DGroup( ); group.Children.Add( new TranslateTransform3D( -hubOffsetX, -hubOffsetY, -propZOffset ) ); group.Children.Add( new RotateTransform3D( new AxisAngleRotation3D( new Vector3D( 1, 0, 0 ), -propAngle ), 0, 0, 0 ) ); group.Children.Add( new RotateTransform3D( new AxisAngleRotation3D( new Vector3D( 0, 0, 1 ), propRotation ), 0, 0, 0 ) ); group.Children.Add( new RotateTransform3D( new AxisAngleRotation3D( new Vector3D( 1, 0, 0 ), +propAngle ), 0, 0, 0 ) ); group.Children.Add( new TranslateTransform3D( +hubOffsetX, +hubOffsetY, +propZOffset ) ); propRotation += 11; return group.Value; } else { return Matrix3D.Identity; } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var scale = (float)values[0]; var transform = (Numerics.Matrix4x4)values[1]; var tGroup = new Media3D.Transform3DGroup(); if (scale != 1) { var tform = new Media3D.ScaleTransform3D(scale, scale, scale); tform.Freeze(); tGroup.Children.Add(tform); } if (!transform.IsIdentity) { var tform = new Media3D.MatrixTransform3D(transform.ToMatrix3D()); tform.Freeze(); tGroup.Children.Add(tform); } tGroup.Freeze(); return(tGroup); }
void MotionWindow_Loaded(object sender, RoutedEventArgs e) { Transform3DGroup gp = new Transform3DGroup(); uBase.Load(@"3DModules\upper.xaml"); ScaleTransform3D sc = new ScaleTransform3D(12, 12, 1, 0, 0, 0); TranslateTransform3D tt = new TranslateTransform3D(0, 0, -15.5); gp.Children.Add(sc); gp.Children.Add(tt); uBase.Transform = gp; uPlatform.Load(@"3DModules\platform.xaml"); upper.Load(@"3DModules\upper.xaml"); AbsoluteVisual.AddLight(Colors.Wheat, new Vector3D(-1, -1, -1), Colors.Gray); vpMain.PlaceCamera( new Point3D(0, 0, 500), new Vector3D(0, 0, -1), new Vector3D(0, 1, 0), 45 ); AbsoluteVisual.Children.Add(uBase); AbsoluteVisual.Children.Add(uPlatform); AbsoluteVisual.Children.Add(upper); ca = new EventCameraAgent(vpMain); ca.MouseLockRelPos = new Point(1, 1); ca.BindEventTo(this); ca.OnCameraStatusChange += new CameraAgent.CameraTransformHandler(ca_OnCameraStatusChange); }
public void Setup3DItem(Model3DGroup targetGroup, DiffuseMaterial diffuseMaterialBrushPair, Size size, Point center, Material backMaterial, Rect backTextureCoordinates) { _locationDesired = new Point3D(center.X, center.Y, 0); _locationCurrent = new Point3D(0, 0, Rnd.NextDouble() * 10 - 20); _size = size; Point3D topLeft = new Point3D(-size.Width / 2, size.Height / 2, 0); Point3D topRight = new Point3D(size.Width / 2, size.Height / 2, 0); Point3D bottomLeft = new Point3D(-size.Width / 2, -size.Height / 2, 0); Point3D bottomRight = new Point3D(size.Width / 2, -size.Height / 2, 0); DiffuseMaterial = diffuseMaterialBrushPair; _quad.Children.Add( CreateTile( diffuseMaterialBrushPair, backMaterial, _borderMaterial, new Size3D(size.Width, size.Height, .01), backTextureCoordinates)); Transform3DGroup group = new Transform3DGroup(); group.Children.Add(new RotateTransform3D(_verticalFlipRotation)); group.Children.Add(new RotateTransform3D(this._quaternionRotation3D)); group.Children.Add(_scaleTransform); group.Children.Add(_translate); _quad.Transform = group; targetGroup.Children.Add(_quad); }
public GeometryModel3D ConvertOne( EngineViewModel engine ) { var white = Color.FromRgb(255, 255, 255); var whiteBrush = new SolidColorBrush(white); var model = new GeometryModel3D(GetGeometry(), new DiffuseMaterial(whiteBrush)); var transform = new Transform3DGroup(); var scaleTransform = new ScaleTransform3D(); var translateTransform = new TranslateTransform3D(); transform.Children.Add(scaleTransform); transform.Children.Add(translateTransform); scaleTransform.ScaleX = 3; scaleTransform.ScaleY = 3; var powerBinding = new Binding("Power") {Mode = BindingMode.OneWay, Source = engine}; BindingOperations.SetBinding( scaleTransform, ScaleTransform3D.ScaleZProperty, powerBinding); translateTransform.OffsetX = engine.OffsetX; translateTransform.OffsetY = engine.OffsetY; model.Transform = transform; return model; }
public Transform3DGroup CreateTransformGroup(Halo3.ObjectChunk placedObject) { var transformGroup = new Transform3DGroup(); float yaw, pitch, roll; Core.Helpers.VectorMath.Convert.ToYawPitchRoll( placedObject.SpawnPosition.Right, placedObject.SpawnPosition.Forward, placedObject.SpawnPosition.Up, out yaw, out pitch, out roll); // For some reason you have to swag the roll and yaw. var swag = Microsoft.Xna.Framework.Quaternion.CreateFromYawPitchRoll(roll, pitch, yaw); // Apply 3D Matrix var matrix = new Matrix3D(); matrix.Rotate(new Quaternion(swag.X, swag.Y, swag.Z, swag.W)); matrix.OffsetX = placedObject.SpawnCoordinates.X; matrix.OffsetY = placedObject.SpawnCoordinates.Y; matrix.OffsetZ = placedObject.SpawnCoordinates.Z; // TODO: F**K THIS VALUE // TODO: AND F**K BUNGIE //matrix.Prepend(new Matrix3D // { // OffsetX = 0, // OffsetY = 0, // OffsetZ = 0 // }); transformGroup.Children.Add(new MatrixTransform3D(matrix)); return transformGroup; }
/** * Creates transformation group for the object in the list, it can be rotated, translated, scaled, as layout class wish :) * \return transformation group for the object in the list */ public Transform3DGroup GetNextTransformation() { Point3D p = new Point3D(); p.X = 1.8f * Math.Cos(counter * 0.17 * 30.0); p.Y = 1.2f * Math.Sin(counter * 0.17 * 30.0); p.Z = -counter; if (p.Z < maxDist) maxDist = p.Z; ++counter; Transform3DGroup group = new Transform3DGroup(); group.Children.Add(new ScaleTransform3D { ScaleX = 1.0, ScaleY = 1.0, ScaleZ = 1.0 }); group.Children.Add(new RotateTransform3D { Rotation = new AxisAngleRotation3D { Angle = 35, Axis = new Vector3D(1, 1, 1) } }); group.Children.Add(new TranslateTransform3D { OffsetX = p.X, OffsetY = p.Y, OffsetZ = p.Z }); return group; }
public FlipTile(DiffuseMaterial frontMaterial, Size size, Point center, Material backMaterial, Rect backTextureCoordinates) { m_locationDesired = new Point3D(center.X, center.Y, 0); m_locationCurrent = new Point3D(0, 0, Util.Rnd.NextDouble() * 10 - 20); m_size = size; Point3D topLeft = new Point3D(-size.Width / 2, size.Height / 2, 0); Point3D topRight = new Point3D(size.Width / 2, size.Height / 2, 0); Point3D bottomLeft = new Point3D(-size.Width / 2, -size.Height / 2, 0); Point3D bottomRight = new Point3D(size.Width / 2, -size.Height / 2, 0); m_frontMaterial = frontMaterial; Model3DGroup quad = new Model3DGroup(); quad.Children.Add( CreateTile( frontMaterial, backMaterial, m_borderMaterial, new Size3D(size.Width, size.Height, .01), backTextureCoordinates)); Transform3DGroup group = new Transform3DGroup(); group.Children.Add(new RotateTransform3D(m_verticalFlipRotation)); group.Children.Add(new RotateTransform3D(m_quaternionRotation3D)); group.Children.Add(m_scaleTransform); group.Children.Add(m_translate); quad.Transform = group; this.Visual3DModel = quad; }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; // ---------------------------------------------- // titles this.Title = "SwapChain Top Surface Rendering Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(20, 20, 20), LookDirection = new Vector3D(-20, -20, -20), UpDirection = new Vector3D(0, 1, 0) }; // ---------------------------------------------- // setup scene this.Light1Color = Colors.White; var builder = new MeshBuilder(true, false, false); builder.AddBox(new Vector3(), 40, 0.1, 40); Plane1Model = FloorModel = builder.ToMeshGeometry3D(); builder = new MeshBuilder(true, false, false); builder.AddBox(new Vector3(), 0.1, 40, 40); Plane2Model = builder.ToMeshGeometry3D(); FloorMaterial = new PhongMaterial(); FloorMaterial.DiffuseColor = new Color4(1f, 1f, 1f, 0.2f); FloorMaterial.AmbientColor = new Color4(0, 0, 0, 0); FloorMaterial.ReflectiveColor = new Color4(0, 0, 0, 0); FloorMaterial.SpecularColor = new Color4(0, 0, 0, 0); PlaneMaterial = new PhongMaterial() { DiffuseColor = new Color4(0.1f, 0.1f, 0.8f, 0.2f) }; var landerItems = Load3ds("Car.3ds").Select(x => x.Geometry as MeshGeometry3D).ToArray(); Model = MeshGeometry3D.Merge(landerItems); Model.UpdateOctree(); ModelMaterial = PhongMaterials.Bronze; var transGroup = new Media3D.Transform3DGroup(); transGroup.Children.Add(new Media3D.ScaleTransform3D(0.01, 0.01, 0.01)); transGroup.Children.Add(new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Media3D.Vector3D(1, 0, 0), -90))); transGroup.Children.Add(new Media3D.TranslateTransform3D(new Media3D.Vector3D(0, 6, 0))); ModelTransform = transGroup; Plane1Transform = new TranslateTransform3D(new Vector3D(0, 15, 0)); Plane2Transform = new TranslateTransform3D(new Vector3D(15, 0, 0)); }
public Window1() { InitializeComponent(); Flickr.Initialize(); cv = new PhotoCarouselView(); ps = new PhotoStack3D(); Transform3DGroup cvTG = new Transform3DGroup(); cvTG.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 5))); cvTG.Children.Add(new TranslateTransform3D(0, 0, -1)); cv.Transform = cvTG; Transform3DGroup tg = new Transform3DGroup(); tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), -13))); tg.Children.Add(new TranslateTransform3D(0, ps.Height / 2, -1.2)); ps.Transform = tg; MainViewport.Children.Add(cv); MainViewport.Children.Add(ps); cv.ItemClickedOn += new PhotoBrowser.CarouselView.CarouselView.ItemClickedOnEvent(cv_ItemClickedOn); cv.GeoLocationAvailable += new PhotoCarouselView.GeoEventHandler(cv_GeoLocationAvailable); cv.GeoLocationHidden += new PhotoCarouselView.GeoEventHandler(cv_GeoLocationHidden); ps.GeoLocationSelected += new PhotoStack3D.GeoLocationSelectedDelegate(ps_GeoLocationSelected); ps.SelectionChanged += new PhotoBrowser.Stack3D.Stack3D.StackSelectionChangedEvent(ps_SelectionChanged); ps.BlogRequested += new PhotoStack3D.BlogRequestedDelegate(ps_BlogRequested); // create the globe we'll use earth = new InteractiveSphere(); mapVisual = new MapVisual(); mapVisual.searchMenuItem.Click += new RoutedEventHandler(searchMenuItem_Click); earth.Visual = mapVisual; // create the transformation applied to the globe earthTransform = new Transform3DGroup(); Point3D earthPos = new Point3D(-0.2, 0.05, -1.1); Vector3D earthToCam = new Vector3D(0 - earthPos.X, 0 - earthPos.Y, 0 - earthPos.Z); earthToCam.Normalize(); earthTransform.Children.Add(new ScaleTransform3D(0.0, 0.0, 0.0)); _myQuaternionRotLong = new QuaternionRotation3D(new Quaternion(new Vector3D(0, 1, 0), 0)); _myQuaternionRotLat = new QuaternionRotation3D(new Quaternion(new Vector3D(1, 0, 0), 0)); earthTransform.Children.Add(new RotateTransform3D(_myQuaternionRotLong)); earthTransform.Children.Add(new RotateTransform3D(_myQuaternionRotLat)); earthTransform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), Math.Acos(Vector3D.DotProduct(new Vector3D(0, 0, 1), earthToCam)) / Math.PI * 180))); earthTransform.Children.Add(new TranslateTransform3D((Vector3D)earthPos)); earth.Transform = earthTransform; // add in the earth HookUpEarthEvents(); }
/// <summary> /// Returns the world*perspective matrix for the camera /// </summary> /// <param name="camera">The WPF camera</param> /// <param name="aspectRatio">The aspect ratio of the device surface</param> /// <returns></returns> public static Matrix3D ToMatrix3DLH( this PerspectiveCamera camera, double aspectRatio ) { Transform3DGroup tg = new Transform3DGroup( ); tg.Children.Add(new MatrixTransform3D(GetLookAtMatrixLH(camera))); tg.Children.Add(camera.Transform); tg.Children.Add(new MatrixTransform3D(GetPerspectiveMatrixLH(camera, aspectRatio))); return tg.Value; }
public Element() { // TODO: Add custom rotation and (optional) scaling Transform3DGroup group = new Transform3DGroup(); group.Children.Add(new RotateTransform3D(Rotation, 0.5, 0, 0.5)); group.Children.Add(Translation); Transform = group; }
public static Transform3D PrependTransform(this Transform3D t1, Transform3D t2) { var g = new System.Windows.Media.Media3D.Transform3DGroup(); g.Children.Add(t2); g.Children.Add(t1); return(g); }
public static void AddCube(this Model3DCollection collection, double x, double y, double z, double size, Color color) { var cube = Model3DFactory.CreateNormalizedCube(Model3DFactory.GetSurfaceMaterial(color)); var transform = new Transform3DGroup(); transform.Children.Add(new ScaleTransform3D(size, size, size)); transform.Children.Add(new TranslateTransform3D(x, y, z)); cube.Transform = transform; collection.Add(cube); }
public FlyMotionController() { m_timer = new Timer(10); m_timer.Elapsed += OnTimerElapsed; m_transform = new Transform3DGroup(); m_transform.Children.Add(m_scale); m_transform.Children.Add(new RotateTransform3D(m_rotation)); }
public void UpdateTransform() { var tg = new Transform3DGroup(); // http://en.wikipedia.org/wiki/Argument_of_periapsis // tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0,0,1),LongitudeOfAscendingNode))); tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), Inclination))); // tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1,0,0),ArgumentOfPerihelion))); Transform = tg; }
public ModelVisual3D Render() { _blocks = new GeometryModel3D[_dimension, _dimension, _dimension]; Model3DGroup group = new Model3DGroup(); double space = 0.03; double w = (1 - space * (_dimension - 1)) / _dimension; double slot = w + space; ScaleTransform3D scaling = new ScaleTransform3D(w, w, w); for (int i = 0; i < _dimension * _dimension * _dimension; i++) { int x = i % _dimension; int y = (int)(i / _dimension) % _dimension; int z = (int)(i / (_dimension * _dimension)); GeometryModel3D c = CreateMiniCube(); _blocks[x, y, z] = c; TranslateTransform3D pos = new TranslateTransform3D((slot * x), (slot * y), -(slot * z)); Transform3DGroup tgroup = new Transform3DGroup(); tgroup.Children.Add(scaling); tgroup.Children.Add(pos); c.Transform = tgroup; group.Children.Add(c); } Transform3DGroup cubeTransGroup = new Transform3DGroup(); TranslateTransform3D cubePos = new TranslateTransform3D(-0.5, -0.5, 0.5); cubeTransGroup.Children.Add(cubePos); // Animation _spinTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0)); //Vector3DAnimation myVectorAnimation = new Vector3DAnimation(new Vector3D(0, 0, -1), new Duration(TimeSpan.FromMilliseconds(5000))); //myVectorAnimation.RepeatBehavior = RepeatBehavior.Forever; //myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AxisProperty, myVectorAnimation); //myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, doubleAnim); cubeTransGroup.Children.Add(_spinTransform); // Animation end group.Transform = cubeTransGroup; ModelVisual3D model = new ModelVisual3D(); model.Content = group; return model; }
public Trackball(double rotationFactor = 4.0, double zoomFacfor = 1.0) { _rotationFactor = rotationFactor; _zoomFactor = zoomFacfor; _transform = new Transform3DGroup(); _transform.Children.Add(_scale); _rotateTransform = new RotateTransform3D(_rotation); _transform.Children.Add(_rotateTransform); _transform.Children.Add(_translate); }
public void Move(double offsetX, double offsetY, double offsetZ, double angle) { Transform3DGroup transform = new Transform3DGroup(); RotateTransform3D rotateTrans = new RotateTransform3D(); rotateTrans.Rotation = new AxisAngleRotation3D(new Vector3D(0, 1, 0), angle); TranslateTransform3D translateTrans = new TranslateTransform3D(offsetX, offsetY, offsetZ); transform.Children.Add(rotateTrans); transform.Children.Add(translateTrans); this.Transform = transform; }
public Node(NodeTemplate template) { Translation = new TranslateTransform3D(); PrimaryRotation = new AxisAngleRotation3D(template.Axis, 0); Transform3DGroup group = new Transform3DGroup(); group.Children.Add(new RotateTransform3D(PrimaryRotation, template.Center)); group.Children.Add(Translation); Transform = group; }
public Cube(Viewport3D myViewport3D, float obesity) { this.up = ((PerspectiveCamera)myViewport3D.Camera).UpDirection; this.trans = new Transform3DGroup(); this.scale = new ScaleTransform3D(); this.translation = new TranslateTransform3D(); this.rotation = new RotateTransform3D(); this.axis = new AxisAngleRotation3D(); this.obesity = obesity; this.cube = new Model3DGroup(); Point3D p0 = new Point3D(-1, -1, -1); Point3D p1 = new Point3D(1, -1, -1); Point3D p2 = new Point3D(1, -1, 1); Point3D p3 = new Point3D(-1, -1, 1); Point3D p4 = new Point3D(-1, 0, -1); Point3D p5 = new Point3D(1, 0, -1); Point3D p6 = new Point3D(1, 0, 1); Point3D p7 = new Point3D(-1, 0, 1); //front side triangles cube.Children.Add(CreateTriangleModel(p3, p2, p6)); cube.Children.Add(CreateTriangleModel(p3, p6, p7)); //right side triangles cube.Children.Add(CreateTriangleModel(p2, p1, p5)); cube.Children.Add(CreateTriangleModel(p2, p5, p6)); //back side triangles cube.Children.Add(CreateTriangleModel(p1, p0, p4)); cube.Children.Add(CreateTriangleModel(p1, p4, p5)); //left side triangles cube.Children.Add(CreateTriangleModel(p0, p3, p7)); cube.Children.Add(CreateTriangleModel(p0, p7, p4)); //top side triangles cube.Children.Add(CreateTriangleModel(p7, p6, p5)); cube.Children.Add(CreateTriangleModel(p7, p5, p4)); //bottom side triangles cube.Children.Add(CreateTriangleModel(p2, p3, p0)); cube.Children.Add(CreateTriangleModel(p2, p0, p1)); this.model = new ModelVisual3D(); this.model.Content = cube; this.myDirectionalLight = new DirectionalLight(); this.myDirectionalLight.Color = Colors.Green; this.myDirectionalLight.Direction = new Vector3D(-2, -3, 1); this.cube.Children.Add(myDirectionalLight); myViewport3D.Children.Add(model); trans.Children.Add(scale); trans.Children.Add(rotation); trans.Children.Add(translation); this.cube.Transform = trans; }
public HandsTrackball() { this.timer = new DispatcherTimer(); this.timer.Interval = TimeSpan.FromMilliseconds(10); this.timer.Tick += new EventHandler(TimerTick); this.timer.Start(); transform = new Transform3DGroup(); transform.Children.Add(scale); transform.Children.Add(new RotateTransform3D(rotation)); }
public void initModel(string currentMovingBlack) { importer = new ObjReader(); model = importer.Read("..\\..\\ObjectFile\\hand_obj.obj"); transform3DGroup = new Transform3DGroup(); double _x = 0.0, _y = 0.0, _z = 0.0; MakeModel(_x, _y, _z, currentMovingBlack); }
internal static CollisionHull CreateSensorCollisionHull(WorldBase world, Vector3D scale, Quaternion orientation, Point3D position) { Transform3DGroup transform = new Transform3DGroup(); //transform.Children.Add(new ScaleTransform3D(scale)); // it ignores scale transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(orientation))); transform.Children.Add(new TranslateTransform3D(position.ToVector())); // Scale X and Y should be identical, but average them to be safe double radius = ((SIZEPERCENTOFSCALE_XY * scale.X) + (SIZEPERCENTOFSCALE_XY * scale.Y)) / 2d; return CollisionHull.CreateCylinder(world, 0, radius, SIZEPERCENTOFSCALE_Z * scale.Z, transform.Value); }
public TrackballDecorator() { // the transform that will be applied to the viewport 3d's camera _transform = new Transform3DGroup(); _transform.Children.Add(_scale); _transform.Children.Add(new RotateTransform3D(_rotation)); _eventSource = new Border(); _eventSource.Background = Brushes.Transparent; PreViewportChildren.Add(_eventSource); }
public Egg(Point3D position, World world, int materialID, ItemOptions itemOptions, ShipDNA dna) { // The radius should be 20% the size of the adult ship this.Radius = dna.PartsByLayer.SelectMany(o => o.Value). Max(o => o.Position.ToVector().Length + Math1D.Max(o.Scale.X, o.Scale.Y, o.Scale.Z)) * .2d; Vector3D scale = new Vector3D(.75d, .75d, 1d); #region WPF Model // Material MaterialGroup materials = new MaterialGroup(); materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(WorldColors.EggColor))); materials.Children.Add(WorldColors.EggSpecular); // Geometry Model GeometryModel3D geometry = new GeometryModel3D(); geometry.Material = materials; geometry.BackMaterial = materials; geometry.Geometry = UtilityWPF.GetSphere_LatLon(5, this.Radius); geometry.Transform = new ScaleTransform3D(scale); this.Model = geometry; // Model Visual ModelVisual3D model = new ModelVisual3D(); model.Content = geometry; #endregion #region Physics Body Transform3DGroup transform = new Transform3DGroup(); transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation()))); transform.Children.Add(new TranslateTransform3D(position.ToVector())); double volume = (4d / 3d) * Math.PI * scale.X * this.Radius * scale.Y * this.Radius * scale.Z * this.Radius; double mass = volume * itemOptions.Egg_Density; using (CollisionHull hull = CollisionHull.CreateSphere(world, 0, scale * this.Radius, null)) { this.PhysicsBody = new Body(hull, transform.Value, mass, new Visual3D[] { model }); this.PhysicsBody.MaterialGroupID = materialID; this.PhysicsBody.LinearDamping = .01f; this.PhysicsBody.AngularDamping = new Vector3D(.001f, .001f, .001f); } #endregion this.CreationTime = DateTime.UtcNow; }
/// <summary> /// Combines two transforms. /// Null Values are treated like the Identity transform. /// </summary> /// <param name="t1"> /// The first transform. /// </param> /// <param name="t2"> /// The second transform. /// </param> /// <returns> /// The combined transform group. /// </returns> public static Transform3D CombineTransform(Transform3D t1, Transform3D t2) { if (t1 == null && t2 == null) return Transform3D.Identity; if (t1 == null && t2 != null) return t2; if (t1 != null && t2 == null) return t1; var g = new Transform3DGroup(); g.Children.Add(t1); g.Children.Add(t2); return g; }
internal void sample(Color color) { ///* GeometryModel3D bigCubeModel = GeometryGenerator.CreateCubeModel(); bigCubeModel.Material = new DiffuseMaterial(new SolidColorBrush(color)); this.Content = bigCubeModel; Transform3DGroup transformGroup = new Transform3DGroup(); transformGroup.Children.Add(new TranslateTransform3D(0.5 * parent.Children.Count, 0, 0)); this.Transform = transformGroup; //*/ }
private void TransformParts() { foreach (Part part in parts) { Media3D.Transform3DGroup F = new Media3D.Transform3DGroup(); if (part.angle == part.initAngle) { part.R = null; } else { double angle = (part.reverse ? part.initAngle - part.angle : part.angle - part.initAngle); part.R = new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(part.rotAxis, angle), part.rotPoint); F.Children.Add(part.R); } Part parentPart = part.parent; while (parentPart != null) { if (parentPart.R != null) { F.Children.Add(parentPart.R); } parentPart = parentPart.parent; } if (F.Children.Count == 0) { part.T = null; } else { part.T = F; } foreach (MeshGeometryModel3D s in part.mgmList) { s.Transform = part.T; } } this.OnPropertyChanged("ModelGeometry"); }
private Media3D.Transform3D CreateAnimatedTransform1(Vector3D translate, Vector3D axis, double speed = 4) { var lightTrafo = new Media3D.Transform3DGroup(); lightTrafo.Children.Add(new Media3D.TranslateTransform3D(translate)); var rotateAnimation = new Rotation3DAnimation { RepeatBehavior = RepeatBehavior.Forever, By = new Media3D.AxisAngleRotation3D(axis, 90), Duration = TimeSpan.FromSeconds(speed / 4), IsCumulative = true, }; var rotateTransform = new Media3D.RotateTransform3D(); rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation); lightTrafo.Children.Add(rotateTransform); return(lightTrafo); }
private Media3D.Transform3D GetTransform(float scale, Matrix4x4 transform) { var tGroup = new Media3D.Transform3DGroup(); if (scale != 1) { var tform = new Media3D.ScaleTransform3D(scale, scale, scale); tform.Freeze(); tGroup.Children.Add(tform); } if (!transform.IsIdentity) { var tform = new Media3D.MatrixTransform3D(transform.ToMatrix3D()); tform.Freeze(); tGroup.Children.Add(tform); } tGroup.Freeze(); return(tGroup); }
public MainViewModel() { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); // ---------------------------------------------- // titles this.Title = "SwapChain Top Surface Rendering Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(20, 20, 20), LookDirection = new Vector3D(-1, -1, -1), UpDirection = new Vector3D(0, 1, 0) }; // (Camera as ProjectionCamera).FarPlaneDistance = 10000; this.Light1Direction = new Vector3(-100, -100, -100); SetupCameraBindings(this.Camera); // ---------------------------------------------- // setup scene this.Light1Color = (Color4)Color.White; var builder = new MeshBuilder(true, false, false); builder.AddBox(new Vector3(), 40, 0.1, 40); Plane1Model = FloorModel = builder.ToMeshGeometry3D(); builder = new MeshBuilder(true, false, false); builder.AddBox(new Vector3(), 0.1, 40, 40); Plane2Model = builder.ToMeshGeometry3D(); FloorMaterial = new PhongMaterial(); FloorMaterial.DiffuseColor = new Color4(1f, 1f, 1f, 0.2f); FloorMaterial.AmbientColor = new Color4(0, 0, 0, 0); FloorMaterial.ReflectiveColor = new Color4(0, 0, 0, 0); FloorMaterial.SpecularColor = new Color4(0, 0, 0, 0); PlaneMaterial = new PhongMaterial() { DiffuseColor = new Color4(0.1f, 0.1f, 0.8f, 0.2f) }; var landerItems = Load3ds("Car.3ds").Select(x => x.Geometry as MeshGeometry3D).ToArray(); Model = MeshGeometry3D.Merge(landerItems); ModelMaterial = PhongMaterials.Obsidian; var transGroup = new Media3D.Transform3DGroup(); transGroup.Children.Add(new Media3D.ScaleTransform3D(0.01, 0.01, 0.01)); transGroup.Children.Add(new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Media3D.Vector3D(1, 0, 0), -90))); transGroup.Children.Add(new Media3D.TranslateTransform3D(new Media3D.Vector3D(0, 6, 0))); ModelTransform = transGroup; Plane1Transform = new TranslateTransform3D(new Vector3D(0, 15, 0)); Plane2Transform = new TranslateTransform3D(new Vector3D(15, 0, 0)); timer = new DispatcherTimer(DispatcherPriority.Render); timer.Interval = TimeSpan.FromMilliseconds(30); timer.Tick += Timer_Tick; timer.Start(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.MainGrid = ((System.Windows.Controls.Grid)(target)); return; case 2: #line 30 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.CreateCustom3D); #line default #line hidden return; case 3: #line 33 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.RectCreate); #line default #line hidden return; case 4: #line 34 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.TriangleCreate); #line default #line hidden return; case 5: #line 35 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.CircleCreate); #line default #line hidden return; case 6: this.ligthsComboBox = ((System.Windows.Controls.ComboBox)(target)); return; case 7: this.drl = ((System.Windows.Controls.ComboBoxItem)(target)); #line 39 "..\..\MainWindow.xaml" this.drl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 8: this.aml = ((System.Windows.Controls.ComboBoxItem)(target)); #line 40 "..\..\MainWindow.xaml" this.aml.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 9: this.ptl = ((System.Windows.Controls.ComboBoxItem)(target)); #line 41 "..\..\MainWindow.xaml" this.ptl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 10: this.spl = ((System.Windows.Controls.ComboBoxItem)(target)); #line 42 "..\..\MainWindow.xaml" this.spl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 11: this.cameraBoxer = ((System.Windows.Controls.ComboBox)(target)); return; case 12: this.pers = ((System.Windows.Controls.ComboBoxItem)(target)); #line 46 "..\..\MainWindow.xaml" this.pers.Selected += new System.Windows.RoutedEventHandler(this.CameraSelected); #line default #line hidden return; case 13: this.orth = ((System.Windows.Controls.ComboBoxItem)(target)); #line 47 "..\..\MainWindow.xaml" this.orth.Selected += new System.Windows.RoutedEventHandler(this.CameraSelected); #line default #line hidden return; case 14: this.DB_Enter_Button = ((System.Windows.Controls.MenuItem)(target)); #line 49 "..\..\MainWindow.xaml" this.DB_Enter_Button.Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click); #line default #line hidden return; case 15: this.mainViewport = ((System.Windows.Controls.Viewport3D)(target)); return; case 16: this.perspectiveCameraEditor = ((System.Windows.Media.Media3D.PerspectiveCamera)(target)); return; case 17: this.LightGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target)); return; case 18: this.Figures = ((System.Windows.Media.Media3D.ModelVisual3D)(target)); return; case 19: this.Figures3D = ((System.Windows.Media.Media3D.Model3DGroup)(target)); return; case 20: this.transformGroup = ((System.Windows.Media.Media3D.Transform3DGroup)(target)); return; case 21: this.figureRotateTransformationX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 22: this.figureRotateTransformationY = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 23: this.figureRotateTransformationZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 24: this.osLines = ((System.Windows.Media.Media3D.ModelVisual3D)(target)); return; case 25: this.OsXMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target)); return; case 26: this.OsYMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target)); return; case 27: this.OsZMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target)); return; case 28: this.gridSliderX = ((System.Windows.Controls.Slider)(target)); return; case 29: this.gridSliderY = ((System.Windows.Controls.Slider)(target)); return; case 30: this.gridSliderZ = ((System.Windows.Controls.Slider)(target)); return; case 31: this.objectSliderX = ((System.Windows.Controls.Slider)(target)); #line 153 "..\..\MainWindow.xaml" this.objectSliderX.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged); #line default #line hidden return; case 32: this.objectSliderY = ((System.Windows.Controls.Slider)(target)); #line 154 "..\..\MainWindow.xaml" this.objectSliderY.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged); #line default #line hidden return; case 33: this.objectSliderZ = ((System.Windows.Controls.Slider)(target)); #line 155 "..\..\MainWindow.xaml" this.objectSliderZ.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged); #line default #line hidden return; case 34: this.FiguresList3D = ((System.Windows.Controls.ComboBox)(target)); #line 159 "..\..\MainWindow.xaml" this.FiguresList3D.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.FiguresList3D_SelectionChanged); #line default #line hidden return; case 35: this.Updater = ((System.Windows.Controls.Button)(target)); #line 161 "..\..\MainWindow.xaml" this.Updater.Click += new System.Windows.RoutedEventHandler(this.UpdateFigure); #line default #line hidden return; case 36: this.Deleter = ((System.Windows.Controls.Button)(target)); #line 162 "..\..\MainWindow.xaml" this.Deleter.Click += new System.Windows.RoutedEventHandler(this.DeleteFigure); #line default #line hidden return; } this._contentLoaded = true; }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; // ---------------------------------------------- // titles this.Title = "SwapChain Top Surface Rendering Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(100, 100, 100), LookDirection = new Vector3D(-100, -100, -100), UpDirection = new Vector3D(0, 1, 0) }; // ---------------------------------------------- // setup scene this.AmbientLightColor = Colors.DimGray; this.Light1Color = Colors.White; this.Light2Color = Colors.Red; this.Light3Color = Colors.LightYellow; this.Light4Color = Colors.LightBlue; this.Light2Attenuation = new Vector3D(0.1f, 0.05f, 0.010f); this.Light3Attenuation = new Vector3D(0.1f, 0.01f, 0.005f); this.Light4Attenuation = new Vector3D(0.1f, 0.02f, 0.0f); this.Light1Direction = new Vector3D(0, -10, -10); this.Light1Transform = new TranslateTransform3D(-Light1Direction); this.Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction, new Vector3D(0, 1, -1), 36); this.Light2Transform = CreateAnimatedTransform1(new Vector3D(-100, 50, 0), new Vector3D(0, 0, 1), 3); this.Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 50, 100), new Vector3D(0, 1, 0), 5); this.Light4Direction = new Vector3D(0, -100, 0); this.Light4Transform = new TranslateTransform3D(-Light4Direction); this.Light4DirectionTransform = CreateAnimatedTransform2(-Light4Direction, new Vector3D(1, 0, 0), 48); // ---------------------------------------------- // light model3d var sphere = new MeshBuilder(); sphere.AddSphere(new Vector3(0, 0, 0), 4); Sphere = sphere.ToMeshGeometry3D(); this.LightModelMaterial = new PhongMaterial { AmbientColor = Colors.Gray.ToColor4(), DiffuseColor = Colors.Gray.ToColor4(), EmissiveColor = Colors.Yellow.ToColor4(), SpecularColor = Colors.Black.ToColor4(), }; Task.Run(() => { LoadFloor(); }); Task.Run(() => { LoadLander(); }); var transGroup = new Media3D.Transform3DGroup(); transGroup.Children.Add(new Media3D.ScaleTransform3D(0.04, 0.04, 0.04)); var rotateAnimation = new Rotation3DAnimation { RepeatBehavior = RepeatBehavior.Forever, By = new Media3D.AxisAngleRotation3D(new Vector3D(0, 1, 0), 90), Duration = TimeSpan.FromSeconds(4), IsCumulative = true, }; var rotateTransform = new Media3D.RotateTransform3D(); transGroup.Children.Add(rotateTransform); rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation); transGroup.Children.Add(new Media3D.TranslateTransform3D(0, 60, 0)); ModelTransform = transGroup; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.griddnnmm = ((System.Windows.Controls.Grid)(target)); #line 10 "..\..\MainWindow.xaml" this.griddnnmm.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.grdm); #line default #line hidden return; case 2: this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target)); return; case 3: this.camusernnn = ((System.Windows.Media.Media3D.PerspectiveCamera)(target)); return; case 4: this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target)); return; case 5: this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target)); return; case 6: this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target)); return; case 7: this.diffuseennn = ((System.Windows.Media.Media3D.DiffuseMaterial)(target)); return; case 8: this.cangroupname = ((System.Windows.Media.Media3D.Transform3DGroup)(target)); return; case 9: this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 10: this.rotatey = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 11: this.rotatez = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 12: this.viewport3D12 = ((System.Windows.Controls.Viewport3D)(target)); return; case 13: this.camusermmm = ((System.Windows.Media.Media3D.PerspectiveCamera)(target)); return; case 14: this.dirLightMain2 = ((System.Windows.Media.Media3D.DirectionalLight)(target)); return; case 15: this.MyModel2 = ((System.Windows.Media.Media3D.ModelVisual3D)(target)); return; case 16: this.wtfrmodel = ((System.Windows.Media.Media3D.GeometryModel3D)(target)); return; case 17: this.tr = ((System.Windows.Media.Media3D.MeshGeometry3D)(target)); return; case 18: this.diffuseemmm = ((System.Windows.Media.Media3D.DiffuseMaterial)(target)); return; case 19: this.rotate2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 20: this.rotatey2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 21: this.rotatez2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 22: this.slider1 = ((System.Windows.Controls.Slider)(target)); #line 146 "..\..\MainWindow.xaml" this.slider1.DataContextChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.cngs); #line default #line hidden return; case 23: this.slider1y = ((System.Windows.Controls.Slider)(target)); return; case 24: this.slider1z = ((System.Windows.Controls.Slider)(target)); return; case 25: this.label = ((System.Windows.Controls.Label)(target)); return; case 26: this.label1 = ((System.Windows.Controls.Label)(target)); return; case 27: this.label1_Copy = ((System.Windows.Controls.Label)(target)); return; case 28: this.label1_Copy1 = ((System.Windows.Controls.Label)(target)); return; case 29: this.slider1_Copy = ((System.Windows.Controls.Slider)(target)); return; case 30: this.slider1y_Copy = ((System.Windows.Controls.Slider)(target)); return; case 31: this.slider1z_Copy = ((System.Windows.Controls.Slider)(target)); return; case 32: this.label_Copy = ((System.Windows.Controls.Label)(target)); return; case 33: this.label_Copy1 = ((System.Windows.Controls.Label)(target)); return; case 34: this.button = ((System.Windows.Controls.Button)(target)); #line 179 "..\..\MainWindow.xaml" this.button.Click += new System.Windows.RoutedEventHandler(this.Button_Click); #line default #line hidden return; case 35: this.button_Copy = ((System.Windows.Controls.Button)(target)); #line 180 "..\..\MainWindow.xaml" this.button_Copy.Click += new System.Windows.RoutedEventHandler(this.Button_Copy_Click); #line default #line hidden return; case 36: this.button_Copy1 = ((System.Windows.Controls.Button)(target)); #line 181 "..\..\MainWindow.xaml" this.button_Copy1.Click += new System.Windows.RoutedEventHandler(this.Button_Copy1_Click); #line default #line hidden return; case 37: this.label_Copy2 = ((System.Windows.Controls.Label)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 9 "..\..\MainWindow.xaml" ((System.Windows.Controls.Grid)(target)).ManipulationDelta += new System.EventHandler <System.Windows.Input.ManipulationDeltaEventArgs>(this.OnDeltaChange); #line default #line hidden #line 9 "..\..\MainWindow.xaml" ((System.Windows.Controls.Grid)(target)).TouchUp += new System.EventHandler <System.Windows.Input.TouchEventArgs>(this.OnTouch); #line default #line hidden #line 9 "..\..\MainWindow.xaml" ((System.Windows.Controls.Grid)(target)).MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Grid_MouseLeftButtonDown); #line default #line hidden #line 9 "..\..\MainWindow.xaml" ((System.Windows.Controls.Grid)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.Grid_MouseMove); #line default #line hidden #line 9 "..\..\MainWindow.xaml" ((System.Windows.Controls.Grid)(target)).MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.Grid_MouseLeftButtonUp); #line default #line hidden #line 9 "..\..\MainWindow.xaml" ((System.Windows.Controls.Grid)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Zoom); #line default #line hidden return; case 2: this.BackgroundImage = ((System.Windows.Controls.Image)(target)); return; case 3: this.viewport = ((System.Windows.Controls.Viewport3D)(target)); return; case 4: this.Light = ((System.Windows.Media.Media3D.ModelVisual3D)(target)); return; case 5: this.light = ((System.Windows.Media.Media3D.AmbientLight)(target)); return; case 6: this.Earth = ((EarthViewerWPF.Sphere)(target)); return; case 7: this.transformGroup = ((System.Windows.Media.Media3D.Transform3DGroup)(target)); return; case 8: this.scaleTransform = ((System.Windows.Media.Media3D.ScaleTransform3D)(target)); return; case 9: this.sphereRec = ((System.Windows.Shapes.Rectangle)(target)); return; case 10: this.InfoTextBox = ((System.Windows.Controls.TextBlock)(target)); return; case 11: this.InfoScale = ((System.Windows.Media.ScaleTransform)(target)); return; case 12: this.TouchLine = ((System.Windows.Shapes.Line)(target)); return; case 13: this.detailsContainer = ((System.Windows.Controls.Label)(target)); return; case 14: this.countryLabel = ((System.Windows.Controls.Label)(target)); return; case 15: this.countryText = ((System.Windows.Controls.Label)(target)); return; case 16: this.capitalLabel = ((System.Windows.Controls.Label)(target)); return; case 17: this.capitalText = ((System.Windows.Controls.Label)(target)); return; case 18: this.languageLabel = ((System.Windows.Controls.Label)(target)); return; case 19: this.languageText = ((System.Windows.Controls.Label)(target)); return; case 20: this.populationLabel = ((System.Windows.Controls.Label)(target)); return; case 21: this.populationText = ((System.Windows.Controls.Label)(target)); return; case 22: this.areaLabel = ((System.Windows.Controls.Label)(target)); return; case 23: this.areaText = ((System.Windows.Controls.Label)(target)); return; case 24: this.anthemLabel = ((System.Windows.Controls.Label)(target)); return; case 25: this.currencyLabel = ((System.Windows.Controls.Label)(target)); return; case 26: this.currencyText = ((System.Windows.Controls.Label)(target)); return; case 27: this.gdpLabel = ((System.Windows.Controls.Label)(target)); return; case 28: this.gdpText = ((System.Windows.Controls.Label)(target)); return; case 29: this.religionLabel = ((System.Windows.Controls.Label)(target)); return; case 30: this.religionText = ((System.Windows.Controls.Label)(target)); return; case 31: this.anthemButton = ((System.Windows.Controls.Button)(target)); #line 72 "..\..\MainWindow.xaml" this.anthemButton.Click += new System.Windows.RoutedEventHandler(this.anthemButton_Click); #line default #line hidden return; case 32: this.anthemButtonStop = ((System.Windows.Controls.Button)(target)); #line 73 "..\..\MainWindow.xaml" this.anthemButtonStop.Click += new System.Windows.RoutedEventHandler(this.anthemButtonStop_Click); #line default #line hidden return; case 33: this.bottomBarContainer = ((System.Windows.Controls.Label)(target)); return; case 34: this.gamesBg = ((System.Windows.Controls.Label)(target)); return; case 35: this.gamesIcon = ((System.Windows.Controls.Image)(target)); #line 78 "..\..\MainWindow.xaml" this.gamesIcon.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.gamesIcon_MouseDown); #line default #line hidden #line 78 "..\..\MainWindow.xaml" this.gamesIcon.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.gamesIcon_MouseUp); #line default #line hidden return; case 36: this.settingsBg = ((System.Windows.Controls.Label)(target)); return; case 37: this.settingsIcon = ((System.Windows.Controls.Image)(target)); #line 80 "..\..\MainWindow.xaml" this.settingsIcon.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.settingsIcon_MouseDown); #line default #line hidden #line 80 "..\..\MainWindow.xaml" this.settingsIcon.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.settingsIcon_MouseUp); #line default #line hidden return; case 38: this.highScoresBg = ((System.Windows.Controls.Label)(target)); return; case 39: this.highScoresIcon = ((System.Windows.Controls.Image)(target)); #line 82 "..\..\MainWindow.xaml" this.highScoresIcon.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.highScoresIcon_MouseDown); #line default #line hidden #line 82 "..\..\MainWindow.xaml" this.highScoresIcon.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.highScoresIcon_MouseUp); #line default #line hidden return; case 40: this.powerBttn = ((System.Windows.Controls.Image)(target)); #line 83 "..\..\MainWindow.xaml" this.powerBttn.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.powerBttn_MouseDown); #line default #line hidden #line 83 "..\..\MainWindow.xaml" this.powerBttn.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.powerBttn_MouseUp); #line default #line hidden return; case 41: this.usernameLabel = ((System.Windows.Controls.Label)(target)); return; case 42: this.settingsReset = ((System.Windows.Controls.Image)(target)); #line 85 "..\..\MainWindow.xaml" this.settingsReset.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseDown); #line default #line hidden #line 85 "..\..\MainWindow.xaml" this.settingsReset.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseUp); #line default #line hidden return; case 43: this.ControlCheckBox = ((System.Windows.Controls.CheckBox)(target)); return; case 44: this.RotationResetButton = ((System.Windows.Controls.Button)(target)); #line 89 "..\..\MainWindow.xaml" this.RotationResetButton.Click += new System.Windows.RoutedEventHandler(this.RotationResetButton_Click); #line default #line hidden return; case 45: this.textureComboBox = ((System.Windows.Controls.ComboBox)(target)); #line 90 "..\..\MainWindow.xaml" this.textureComboBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.ComboBox_SelectionChanged); #line default #line hidden return; case 46: this.sensitivitySlider = ((System.Windows.Controls.Slider)(target)); return; case 47: this.sensitivityLabel = ((System.Windows.Controls.Label)(target)); return; case 48: this.gameButton = ((System.Windows.Controls.Button)(target)); #line 104 "..\..\MainWindow.xaml" this.gameButton.Click += new System.Windows.RoutedEventHandler(this.gameButton_Click); #line default #line hidden return; case 49: this.countryGText = ((System.Windows.Controls.TextBlock)(target)); return; case 50: this.timerText = ((System.Windows.Controls.TextBlock)(target)); return; case 51: this.recentScore1 = ((System.Windows.Controls.Label)(target)); return; case 52: this.scoreLabel1 = ((System.Windows.Controls.Label)(target)); return; case 53: this.game2Button = ((System.Windows.Controls.Button)(target)); #line 109 "..\..\MainWindow.xaml" this.game2Button.Click += new System.Windows.RoutedEventHandler(this.game2Button_Click); #line default #line hidden return; case 54: this.game2RecentScore = ((System.Windows.Controls.Label)(target)); return; case 55: this.game3Button = ((System.Windows.Controls.Button)(target)); #line 111 "..\..\MainWindow.xaml" this.game3Button.Click += new System.Windows.RoutedEventHandler(this.game3Button_Click); #line default #line hidden return; case 56: this.game3RecentScore = ((System.Windows.Controls.Label)(target)); return; case 57: this.placeNameImage = ((System.Windows.Controls.Image)(target)); #line 113 "..\..\MainWindow.xaml" this.placeNameImage.MouseEnter += new System.Windows.Input.MouseEventHandler(this.placeNameImage_MouseEnter); #line default #line hidden #line 113 "..\..\MainWindow.xaml" this.placeNameImage.MouseLeave += new System.Windows.Input.MouseEventHandler(this.placeNameImage_MouseLeave); #line default #line hidden return; case 58: this.skipImage = ((System.Windows.Controls.Image)(target)); #line 114 "..\..\MainWindow.xaml" this.skipImage.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.skipImage_MouseDown); #line default #line hidden #line 114 "..\..\MainWindow.xaml" this.skipImage.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.skipImage_MouseUp); #line default #line hidden return; case 59: this.leftSideDivider = ((System.Windows.Controls.Label)(target)); return; case 60: this.rightSideDivider = ((System.Windows.Controls.Label)(target)); return; case 61: this.gameModeLabelHs = ((System.Windows.Controls.Label)(target)); return; case 62: this.usernameLabelHs = ((System.Windows.Controls.Label)(target)); return; case 63: this.scoreLabelHs = ((System.Windows.Controls.Label)(target)); return; case 64: this.gameMode1 = ((System.Windows.Controls.Label)(target)); return; case 65: this.gamemode2 = ((System.Windows.Controls.Label)(target)); return; case 66: this.gameMode3 = ((System.Windows.Controls.Label)(target)); return; case 67: this.player1 = ((System.Windows.Controls.Label)(target)); return; case 68: this.player2 = ((System.Windows.Controls.Label)(target)); return; case 69: this.player3 = ((System.Windows.Controls.Label)(target)); return; case 70: this.score1 = ((System.Windows.Controls.Label)(target)); return; case 71: this.score2 = ((System.Windows.Controls.Label)(target)); return; case 72: this.score3 = ((System.Windows.Controls.Label)(target)); return; case 73: this.settingsReset_Copy = ((System.Windows.Controls.Image)(target)); #line 131 "..\..\MainWindow.xaml" this.settingsReset_Copy.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseDown); #line default #line hidden #line 131 "..\..\MainWindow.xaml" this.settingsReset_Copy.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseUp); #line default #line hidden return; } this._contentLoaded = true; }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; // ---------------------------------------------- // titles this.Title = "SwapChain Top Surface Rendering Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(100, 100, 100), LookDirection = new Vector3D(-100, -100, -100), UpDirection = new Vector3D(0, 1, 0) }; // ---------------------------------------------- // setup scene this.AmbientLightColor = Colors.DimGray; this.Light1Color = Colors.White; this.Light2Color = Colors.Red; this.Light3Color = Colors.LightYellow; this.Light4Color = Colors.LightBlue; this.Light2Attenuation = new Vector3D(0.1f, 0.05f, 0.010f); this.Light3Attenuation = new Vector3D(0.1f, 0.01f, 0.005f); this.Light4Attenuation = new Vector3D(0.1f, 0.02f, 0.0f); this.Light1Direction = new Vector3D(0, -10, -10); this.Light1Transform = new TranslateTransform3D(-Light1Direction); this.Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction, new Vector3D(0, 1, -1), 36); this.Light2Transform = CreateAnimatedTransform1(new Vector3D(-100, 50, 0), new Vector3D(0, 0, 1), 3); this.Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 50, 100), new Vector3D(0, 1, 0), 5); this.Light4Direction = new Vector3D(0, -100, 0); this.Light4Transform = new TranslateTransform3D(-Light4Direction); this.Light4DirectionTransform = CreateAnimatedTransform2(-Light4Direction, new Vector3D(1, 0, 0), 48); // ---------------------------------------------- // light model3d var sphere = new MeshBuilder(); sphere.AddSphere(new Vector3(0, 0, 0), 4); Sphere = sphere.ToMeshGeometry3D(); this.LightModelMaterial = new PhongMaterial { AmbientColor = Colors.Gray.ToColor4(), DiffuseColor = Colors.Gray.ToColor4(), EmissiveColor = Colors.Yellow.ToColor4(), SpecularColor = Colors.Black.ToColor4(), }; var models = Load3ds("wall12.obj").Select(x => x.Geometry as MeshGeometry3D).ToArray(); Floor = models[0]; Floor.OctreeParameter.EnableParallelBuild = true; this.FloorTransform = new Media3D.TranslateTransform3D(0, 0, 0); this.FloorMaterial = new PhongMaterial { AmbientColor = Colors.Gray.ToColor4(), DiffuseColor = new Color4(0.75f, 0.75f, 0.75f, 1.0f), SpecularColor = Colors.White.ToColor4(), SpecularShininess = 100f }; var landerItems = Load3ds("Car.3ds").Select(x => x.Geometry as MeshGeometry3D).ToArray(); Model = MeshGeometry3D.Merge(landerItems); Model.OctreeParameter.EnableParallelBuild = true; ModelMaterial = PhongMaterials.BlackRubber; var transGroup = new Media3D.Transform3DGroup(); transGroup.Children.Add(new Media3D.ScaleTransform3D(0.04, 0.04, 0.04)); var rotateAnimation = new Rotation3DAnimation { RepeatBehavior = RepeatBehavior.Forever, By = new Media3D.AxisAngleRotation3D(new Vector3D(0, 1, 0), 90), Duration = TimeSpan.FromSeconds(4), IsCumulative = true, }; var rotateTransform = new Media3D.RotateTransform3D(); transGroup.Children.Add(rotateTransform); rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation); transGroup.Children.Add(new Media3D.TranslateTransform3D(0, 60, 0)); ModelTransform = transGroup; NumberOfTriangles = Floor.Indices.Count / 3 + Model.Indices.Count / 3; NumberOfVertices = Floor.Positions.Count + Model.Positions.Count; }
/// <summary> /// Constructor of the MainViewModel /// </summary> public MainViewModel() { // titles this.Title = "Deferred Shading Demo"; this.SubTitle = "WPF & SharpDX"; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(18, 64, 30), LookDirection = new Vector3D(-18, -64, -30), UpDirection = new Vector3D(0, 1, 0) }; // deferred render technique EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DeferredRenderTechniqueNames.Deferred]; //load model var reader = new ObjReader(); var objModel = reader.Read(@"./Media/bunny.obj"); this.Model = objModel[0].Geometry as MeshGeometry3D; var scale = 2.0; // model trafos var transf1 = new Transform3DGroup(); transf1.Children.Add(new ScaleTransform3D(scale, scale, scale)); transf1.Children.Add(new RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(0, 1, 0), 40), 0.0, 0.0, 0.0)); transf1.Children.Add(new TranslateTransform3D(0, -2, 3)); this.Model1Transform = transf1; var transf2 = new Transform3DGroup(); transf2.Children.Add(new ScaleTransform3D(scale, scale, scale)); transf2.Children.Add(new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(0, 1, 0), 66), 0.0, 0.0, 0.0)); transf2.Children.Add(new Media3D.TranslateTransform3D(-3.0, -2, -2.5)); this.Model2Transform = transf2; var transf3 = new Transform3DGroup(); transf3.Children.Add(new ScaleTransform3D(scale, scale, scale)); transf3.Children.Add(new TranslateTransform3D(+3.5, -2, -1.0)); this.Model3Transform = transf3; // floor plane var meshBuilder = new MeshBuilder(); meshBuilder.AddBox(new Vector3(0, 0, 0), 100, 0.0, 100, BoxFaces.PositiveY); this.Plane = meshBuilder.ToMeshGeometry3D(); this.PlaneTransform = new TranslateTransform3D(0, -1.05, 0); // model materials this.RedMaterial = PhongMaterials.Red; this.GreenMaterial = PhongMaterials.Green; this.BlueMaterial = PhongMaterials.Blue; this.PlaneMaterial = PhongMaterials.DefaultVRML; this.PlaneMaterial.DiffuseMap = LoadFileToMemory(new System.Uri(@"./Media/TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute).ToString()); this.PlaneMaterial.NormalMap = LoadFileToMemory(new System.Uri(@"./Media/TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute).ToString()); // setup lighting this.AmbientLightColor = Colors.DarkGray; this.DirectionalLightColor = Colors.Gray; this.DirectionalLightDirection = new Vector3D(-2, -5, -2); this.PointLightColor = Colors.White; this.PointLightAttenuation = new Vector3D(0.0f, 0.0f, 0.18f); //1/0/0 ; 0.1, 0.2, 0.3 this.PointLightTransform1 = new TranslateTransform3D(new Vector3D(0, 1, 0)); this.PointLightTransform2 = new TranslateTransform3D(new Vector3D(6, 1, 3)); this.PointLightTransform3 = new TranslateTransform3D(new Vector3D(-3, 1, -6)); this.SpotLightColor = Colors.AntiqueWhite; this.SpotLightAttenuation = new Vector3D(1.0, 0.1, 0.01); // light collection this.PointLightCollection = new ObservableElement3DCollection(); this.PointLightCount = 7; this.PointLightSpread = 100; // spotlight collection this.SpotLightCollection = new ObservableElement3DCollection(); this.SpotLightCount = 7; this.SpotLightSpread = 100; }
//------------------------------------------------------ // // Public Properties // //------------------------------------------------------ private static void ChildrenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // The first change to the default value of a mutable collection property (e.g. GeometryGroup.Children) // will promote the property value from a default value to a local value. This is technically a sub-property // change because the collection was changed and not a new collection set (GeometryGroup.Children. // Add versus GeometryGroup.Children = myNewChildrenCollection). However, we never marshalled // the default value to the compositor. If the property changes from a default value, the new local value // needs to be marshalled to the compositor. We detect this scenario with the second condition // e.OldValueSource != e.NewValueSource. Specifically in this scenario the OldValueSource will be // Default and the NewValueSource will be Local. if (e.IsASubPropertyChange && (e.OldValueSource == e.NewValueSource)) { return; } Transform3DGroup target = ((Transform3DGroup)d); // If this is both non-null and mutable, we need to unhook the Changed event. Transform3DCollection oldCollection = null; Transform3DCollection newCollection = null; if ((e.OldValueSource != BaseValueSourceInternal.Default) || e.IsOldValueModified) { oldCollection = (Transform3DCollection)e.OldValue; if ((oldCollection != null) && !oldCollection.IsFrozen) { oldCollection.ItemRemoved -= target.ChildrenItemRemoved; oldCollection.ItemInserted -= target.ChildrenItemInserted; } } // If this is both non-null and mutable, we need to hook the Changed event. if ((e.NewValueSource != BaseValueSourceInternal.Default) || e.IsNewValueModified) { newCollection = (Transform3DCollection)e.NewValue; if ((newCollection != null) && !newCollection.IsFrozen) { newCollection.ItemInserted += target.ChildrenItemInserted; newCollection.ItemRemoved += target.ChildrenItemRemoved; } } if (oldCollection != newCollection && target.Dispatcher != null) { using (CompositionEngineLock.Acquire()) { DUCE.IResource targetResource = (DUCE.IResource)target; int channelCount = targetResource.GetChannelCount(); for (int channelIndex = 0; channelIndex < channelCount; channelIndex++) { DUCE.Channel channel = targetResource.GetChannel(channelIndex); Debug.Assert(!channel.IsOutOfBandChannel); Debug.Assert(!targetResource.GetHandle(channel).IsNull); // resource shouldn't be null because // 1) If the field is one of our collections, we don't allow null elements // 2) Codegen already made sure the collection contains DUCE.IResources // ... so we'll Assert it if (newCollection != null) { int count = newCollection.Count; for (int i = 0; i < count; i++) { DUCE.IResource resource = newCollection.Internal_GetItem(i) as DUCE.IResource; Debug.Assert(resource != null); resource.AddRefOnChannel(channel); } } if (oldCollection != null) { int count = oldCollection.Count; for (int i = 0; i < count; i++) { DUCE.IResource resource = oldCollection.Internal_GetItem(i) as DUCE.IResource; Debug.Assert(resource != null); resource.ReleaseOnChannel(channel); } } } } } target.PropertyChanged(ChildrenProperty); }
public MainViewModel() { // RenderTechniquesManager = new DefaultRenderTechniquesManager(); EffectsManager = new DefaultEffectsManager(); // ---------------------------------------------- // titles this.Title = "Lighting Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(8, 9, 7), LookDirection = new Vector3D(-5, -12, -5), UpDirection = new Vector3D(0, 1, 0) }; // ---------------------------------------------- // setup scene this.AmbientLightColor = Colors.DarkGray; this.RenderLight1 = true; this.RenderLight2 = true; this.RenderLight3 = true; this.RenderLight4 = true; this.Light1Color = Colors.White; this.Light2Color = Colors.Red; this.Light3Color = Colors.LightYellow; this.Light4Color = Colors.LightBlue; this.Light2Attenuation = new Vector3D(1.0f, 0.5f, 0.10f); this.Light3Attenuation = new Vector3D(1.0f, 0.1f, 0.05f); this.Light4Attenuation = new Vector3D(0.1f, 0.1f, 0.0f); this.Light1Direction = new Vector3D(0, -10, 0); this.Light1Transform = CreateAnimatedTransform1(-Light1Direction, new Vector3D(1, 0, 0), 24); this.Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction, new Vector3D(0, 1, -1), 24); this.Light2Transform = CreateAnimatedTransform1(new Vector3D(-4, 0, 0), new Vector3D(0, 0, 1), 3); this.Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 0, 4), new Vector3D(0, 1, 0), 5); this.Light4Direction = new Vector3D(0, -5, -1); this.Light4Transform = CreateAnimatedTransform2(-Light4Direction * 2, new Vector3D(0, 1, 0), 24); this.Light4DirectionTransform = CreateAnimatedTransform2(-Light4Direction, new Vector3D(1, 0, 0), 12); var transformGroup = new Media3D.Transform3DGroup(); transformGroup.Children.Add(new Media3D.ScaleTransform3D(10, 10, 10)); transformGroup.Children.Add(new Media3D.TranslateTransform3D(2, -4, 2)); Model1Transform = transformGroup; // ---------------------------------------------- // light model3d var sphere = new MeshBuilder(); sphere.AddSphere(new Vector3(0, 0, 0), 0.2); Sphere = sphere.ToMeshGeometry3D(); this.LightModelMaterial = new PhongMaterial { AmbientColor = Colors.Gray.ToColor4(), DiffuseColor = Colors.Gray.ToColor4(), EmissiveColor = Colors.Yellow.ToColor4(), SpecularColor = Colors.Black.ToColor4(), }; // ---------------------------------------------- // scene model3d var b1 = new MeshBuilder(true, true, true); b1.AddSphere(new Vector3(0.25f, 0.25f, 0.25f), 0.75, 24, 24); b1.AddBox(-new Vector3(0.25f, 0.25f, 0.25f), 1, 1, 1, BoxFaces.All); b1.AddBox(-new Vector3(5.0f, 0.0f, 0.0f), 1, 1, 1, BoxFaces.All); b1.AddSphere(new Vector3(5f, 0f, 0f), 0.75, 24, 24); b1.AddCylinder(new Vector3(0f, -3f, -5f), new Vector3(0f, 3f, -5f), 1.2, 24); b1.AddSphere(new Vector3(-5.0f, -5.0f, 5.0f), 4, 24, 64); b1.AddCone(new Vector3(6f, -9f, -6f), new Vector3(6f, -1f, -6f), 4f, true, 64); this.Model = b1.ToMeshGeometry3D(); this.ModelTransform = new Media3D.TranslateTransform3D(0, 0, 0); this.ModelMaterial = PhongMaterials.Chrome; this.ModelMaterial.NormalMap = LoadFileToMemory(new System.Uri(SelectedNormalTexture, System.UriKind.RelativeOrAbsolute).ToString()); // ---------------------------------------------- // floor model3d var b2 = new MeshBuilder(true, true, true); //b2.AddRectangularMesh(BoxFaces.Left, 10, 10, 10, 10); b2.AddBox(new Vector3(0.0f, -5.0f, 0.0f), 15, 1, 15, BoxFaces.All); //b2.AddSphere(new Vector3(-5.0f, -5.0f, 5.0f), 4, 24, 64); //b2.AddCone(new Vector3(6f, -9f, -6f), new Vector3(6f, -1f, -6f), 4f, true, 64); this.Floor = b2.ToMeshGeometry3D(); this.FloorTransform = new Media3D.TranslateTransform3D(0, 0, 0); this.FloorMaterial = new PhongMaterial { AmbientColor = Colors.Gray.ToColor4(), DiffuseColor = new Color4(0.75f, 0.75f, 0.75f, 1.0f), SpecularColor = Colors.White.ToColor4(), SpecularShininess = 100f, DiffuseMap = LoadFileToMemory(new System.Uri(SelectedDiffuseTexture, System.UriKind.RelativeOrAbsolute).ToString()), NormalMap = ModelMaterial.NormalMap, RenderShadowMap = true }; ModelMaterial.DiffuseMap = FloorMaterial.DiffuseMap; ReflectMaterial = PhongMaterials.PolishedSilver; ReflectMaterial.ReflectiveColor = global::SharpDX.Color.Silver; ReflectMaterial.RenderEnvironmentMap = true; InitialObjectTransforms(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.ligthsComboBox = ((System.Windows.Controls.ComboBox)(target)); return; case 2: this.drl = ((System.Windows.Controls.ComboBoxItem)(target)); #line 47 "..\..\..\Views\MainWindow.xaml" this.drl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 3: this.aml = ((System.Windows.Controls.ComboBoxItem)(target)); #line 48 "..\..\..\Views\MainWindow.xaml" this.aml.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 4: this.ptl = ((System.Windows.Controls.ComboBoxItem)(target)); #line 49 "..\..\..\Views\MainWindow.xaml" this.ptl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 5: this.spl = ((System.Windows.Controls.ComboBoxItem)(target)); #line 50 "..\..\..\Views\MainWindow.xaml" this.spl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected); #line default #line hidden return; case 6: #line 52 "..\..\..\Views\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click); #line default #line hidden return; case 7: this.mainViewport = ((System.Windows.Controls.Viewport3D)(target)); return; case 8: this.perspectiveCameraEditor = ((System.Windows.Media.Media3D.PerspectiveCamera)(target)); return; case 9: this.LightGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target)); return; case 10: this.MaterialGroup = ((System.Windows.Media.Media3D.MaterialGroup)(target)); return; case 11: this.DiffuseMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target)); return; case 12: this.transformGroup = ((System.Windows.Media.Media3D.Transform3DGroup)(target)); return; case 13: this.figureRotateTransformationX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 14: this.figureRotateTransformationY = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 15: this.figureRotateTransformationZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target)); return; case 16: this.gridSliderX = ((System.Windows.Controls.Slider)(target)); return; case 17: this.gridSliderY = ((System.Windows.Controls.Slider)(target)); return; case 18: this.gridSliderZ = ((System.Windows.Controls.Slider)(target)); return; case 19: this.objectSliderX = ((System.Windows.Controls.Slider)(target)); #line 129 "..\..\..\Views\MainWindow.xaml" this.objectSliderX.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged); #line default #line hidden return; case 20: this.objectSliderY = ((System.Windows.Controls.Slider)(target)); #line 130 "..\..\..\Views\MainWindow.xaml" this.objectSliderY.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged); #line default #line hidden return; case 21: this.objectSliderZ = ((System.Windows.Controls.Slider)(target)); #line 131 "..\..\..\Views\MainWindow.xaml" this.objectSliderZ.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged); #line default #line hidden return; } this._contentLoaded = true; }