using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Interop; using SlimDX; using SlimDX.Windows; using Aiwaz.Core; using Aiwaz.Resources; using Aiwaz.Editor.ViewModels; using Aiwaz.Resources.Prefab; using Aiwaz.Contracts; using Aiwaz.Editor.Controls; namespace Aiwaz.Editor { /// /// Interaction logic for Window1.xaml /// public partial class Window1 : Window { public ResourceViewModel ResourceViewModel; public Window1() { InitializeComponent(); aiwazControl.SwapChain.ClearColor = new Color4(0.0f, 0.0f, 1.0f); var model = new BluModel(new BluModelParams() { FileName = "Data/ChamferBox.blu" }); model.RootTransformation.LocalScale = new SlimDX.Vector3(0.1f, 0.1f, 0.1f); model.RootTransformation.LocalPosition = new SlimDX.Vector3(1.0f, 0.0f, 2.0f); var camera = new PerspectiveCamera(new PerspectiveCameraParams()); var normalMapping = new Shader(new ShaderParams() { FileName = "Data/NormalOutput.fx", TechniqueName = "NormalMapping" }); var wallTexture = new Texture(new FileTextureParams() { FileName = "Data/Wall.jpg" }); var wallNormalTexture = new Texture(new FileTextureParams() { FileName = "Data/WallNormal.jpg" }); wallNormalTexture.BindingName = "Normal"; var roomCube = new Cube(new CubeParams() { Width = 10.0f, Height = 10.0f, Depth = 10.0f, IsInverted = true }); roomCube.GeometryBuffer.IsPickable = true; var roomCubeTransformation = new Transformation(new DefaultTransformationBindings()); roomCubeTransformation.LocalPosition = new SlimDX.Vector3(0.0f, 0.0f, 2.0f); var lightPosition = new ReferenceT(new SlimDX.Vector3(0.0f, 1.0f, 0.0f)); var lightColor = new ReferenceT(new SlimDX.Vector4(2.0f, 2.0f, 1.0f, 1.0f)); var lightParameters = new ShaderParameterSet(); lightParameters.IsPreconditionForFollowingShaders = true; lightParameters.SetParameter("LightPosition", lightPosition, ParameterBindType.BindBySemantic); lightParameters.SetParameter("LightColor", lightColor, ParameterBindType.BindBySemantic); aiwazControl.RootNode.Children.Add(camera); aiwazControl.RootNode.Children.Add(lightParameters); aiwazControl.RootNode.Children.Add(roomCubeTransformation); aiwazControl.RootNode.Children.Add(normalMapping); aiwazControl.RootNode.Children.Add(wallTexture); aiwazControl.RootNode.Children.Add(wallNormalTexture); aiwazControl.RootNode.Children.Add(roomCube); aiwazControl.RootNode.Children.Add(model); ResourceViewModel = new ResourceViewModel(aiwazControl.RootNode); trvNodes.DataContext = ResourceViewModel; trvNodes.SelectedItemChanged += new RoutedPropertyChangedEventHandler(trvNodes_SelectedItemChanged); aiwazControl.PickableResources = PickableResourcesDataSource.CreateFromResource(aiwazControl.RootNode); aiwazControl.SelectedResourceChanged += new Aiwaz.Editor.Controls.AiwazViewControl.SelectedResourceChangedDelegate(aiwazControl_SelectedResourceChanged); } void aiwazControl_SelectedResourceChanged(object sender, Aiwaz.Editor.Controls.PickableResourceInfo newSelectedResourceInfo) { Properties.SelectedObject = newSelectedResourceInfo == null ? null : newSelectedResourceInfo.Resource; } void trvNodes_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) { Properties.SelectedObject = ((ResourceViewModel)(e.NewValue)).Resource; } } }