private void HandleMaterialSelection() { switch( MaterialComboBox.SelectedIndex ) { case 0: { _selectedMaterial = _flatMaterial; } break; case 1: { _selectedMaterial = _gouraudMaterial; } break; case 2: { _selectedMaterial = _texturedMaterial; } break; case 3: { _selectedMaterial = _reflectionMaterial; } break; } _selectedNode.Material = _selectedMaterial; HandleTextureSelection(); }
public Content() { InitializeComponent(); Loaded += Content_Loaded; _flatMaterial = Resources["FlatMaterial"] as Material; _gouraudMaterial = Resources["GouraudMaterial"] as Material; _texturedMaterial = Resources["TexturedMaterial"] as Material; _reflectionMaterial = Resources["ReflectionMaterial"] as Material; }
public void SetMaterialForAllFaces(Material material) { if (null == Faces) { return; } for (var index = 0; index < Faces.Length; index++) { Faces[index].Material = material; } }
public void SetMaterial(int index, Material material) { Faces[index].Material = material; }
private void Game_LoadContent(Game game) { _container = new Geometry(); game.Scene.AddNode(_container); _teapot = game.ContentManager.Load<Mesh>("teapot.ASE"); _container.Children.Add(_teapot); _teapot.IsVisible = false; _box = new Box {Dimension = new Coordinate(40, 40, 40)}; _box.Position.Set(0,10,0); _container.Children.Add(_box); _cylinder = new Cylinder {Segments = 16, Size = 20, TopRadius = 20, BottomRadius = 40}; _cylinder.Position.Set(0, 10, 0); _container.Children.Add(_cylinder); _ring = new Ring {Segments = 16, Size = 20, InnerRadius = 20, OuterRadius = 40}; _ring.Position.Set(0, 10, 0); _container.Children.Add(_ring); _reflectionMapTexture = LoadTexture("/Balder.Silverlight.SampleBrowser;component/Samples/Programatic/Materials/Assets/ReflectionMap.jpg"); _visualStudioTexture = LoadTexture("/Balder.Silverlight.SampleBrowser;component/Samples/Programatic/Materials/Assets/VisualStudio.png"); _balderLogoTexture = LoadTexture("/Balder.Silverlight.SampleBrowser;component/Samples/Programatic/Materials/Assets/BalderLogo.png"); _flatMaterial = new Material { Diffuse = Colors.Red, Shade = MaterialShade.Flat }; _gouraudMaterial = new Material { Diffuse = Colors.Red, Shade = MaterialShade.Gouraud }; _texturedMaterial = new Material { DiffuseMap = _reflectionMapTexture, Shade = MaterialShade.Flat, }; _reflectionMaterial = new Material { ReflectionMap = _reflectionMapTexture, Shade = MaterialShade.Flat }; }
public Cover() { this.AddVertex(-CoverWidth, -CoverHeight, 0); this.AddVertex(CoverWidth, -CoverWidth, 0); this.AddVertex(-CoverWidth, CoverHeight, 0); this.AddVertex(CoverWidth, CoverWidth, 0); this.AddTextureCoordinate(0d, 0d); this.AddTextureCoordinate(1d, 0d); this.AddTextureCoordinate(0d, 1d); this.AddTextureCoordinate(1d, 1d); Material material = new Material(new Uri("Empty.png",UriKind.Relative)); Face face1 = this.AddFace(0, 1, 2, 0, 1, 2); face1.DoubleSided = true; Face face2 = this.AddFace(3, 2, 1, 3, 2, 1); face2.DoubleSided = true; face1.Material = material; face2.Material = material; // Move left this._moveToLeftStoryboard = new Storyboard(); var moveToLeftAnimation = new DoubleAnimation(); moveToLeftAnimation.To = CoverAngle; moveToLeftAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToLeftStoryboard.Children.Add(moveToLeftAnimation); Storyboard.SetTarget(moveToLeftAnimation, this); Storyboard.SetTargetProperty(moveToLeftAnimation, new PropertyPath("(Node.YRotation)")); var offsetToLeftAnimation = new DoubleAnimation(); offsetToLeftAnimation.To = -CoverOffset; offsetToLeftAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToLeftStoryboard.Children.Add(offsetToLeftAnimation); Storyboard.SetTarget(offsetToLeftAnimation, this); Storyboard.SetTargetProperty(offsetToLeftAnimation, new PropertyPath("(Node.XPosition)")); var moveLeftBackwardAnimation = new DoubleAnimation(); moveLeftBackwardAnimation.To = 0; moveLeftBackwardAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToLeftStoryboard.Children.Add(moveLeftBackwardAnimation); Storyboard.SetTarget(moveLeftBackwardAnimation, this); Storyboard.SetTargetProperty(moveLeftBackwardAnimation, new PropertyPath("(Node.ZPosition)")); // Move right this._moveToRightStoryboard = new Storyboard(); var moveToRightAnimation = new DoubleAnimation(); moveToRightAnimation.To = -CoverAngle; moveToRightAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToRightStoryboard.Children.Add(moveToRightAnimation); Storyboard.SetTarget(moveToRightAnimation, this); Storyboard.SetTargetProperty(moveToRightAnimation, new PropertyPath("(Node.YRotation)")); var offsetToRightAnimation = new DoubleAnimation(); offsetToRightAnimation.To = CoverOffset; offsetToRightAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToRightStoryboard.Children.Add(offsetToRightAnimation); Storyboard.SetTarget(offsetToRightAnimation, this); Storyboard.SetTargetProperty(offsetToRightAnimation, new PropertyPath("(Node.XPosition)")); var moveRightBackwardAnimation = new DoubleAnimation(); moveRightBackwardAnimation.To = 0; moveRightBackwardAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToRightStoryboard.Children.Add(moveRightBackwardAnimation); Storyboard.SetTarget(moveRightBackwardAnimation, this); Storyboard.SetTargetProperty(moveRightBackwardAnimation, new PropertyPath("(Node.ZPosition)")); // Move front this._moveToFrontStoryboard = new Storyboard(); var moveToFrontAnimation = new DoubleAnimation(); moveToFrontAnimation.To = 0d; moveToFrontAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToFrontStoryboard.Children.Add(moveToFrontAnimation); Storyboard.SetTarget(moveToFrontAnimation, this); Storyboard.SetTargetProperty(moveToFrontAnimation, new PropertyPath("(Node.YRotation)")); var offsetToFrontAnimation = new DoubleAnimation(); offsetToFrontAnimation.To = 0; offsetToFrontAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToFrontStoryboard.Children.Add(offsetToFrontAnimation); Storyboard.SetTarget(offsetToFrontAnimation, this); Storyboard.SetTargetProperty(offsetToFrontAnimation, new PropertyPath("(Node.XPosition)")); var moveForwardAnimation = new DoubleAnimation(); moveForwardAnimation.To = 20; moveForwardAnimation.Duration = TimeSpan.FromMilliseconds(CoverMoveDuration); this._moveToFrontStoryboard.Children.Add(moveForwardAnimation); Storyboard.SetTarget(moveForwardAnimation, this); Storyboard.SetTargetProperty(moveForwardAnimation, new PropertyPath("(Node.ZPosition)")); }