port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5AD414C8-9564-406C-888E-1C4E89DBA566}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Aiwaz.Editor</RootNamespace>
<AssemblyName>Aiwaz.Editor</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="IronPython, Version=2.6.10920.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\IronPython\IronPython.dll</HintPath>
</Reference>
<Reference Include="IronPython.Modules, Version=2.6.10920.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\IronPython\IronPython.Modules.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Dynamic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\IronPython\Microsoft.Dynamic.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\IronPython\Microsoft.Scripting.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\IronPython\Microsoft.Scripting.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting.Debugging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\IronPython\Microsoft.Scripting.Debugging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\IronPython\Microsoft.Scripting.ExtensionAttribute.dll</HintPath>
</Reference>
<Reference Include="SlimDX, Version=2.0.8.42, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Extern\SlimDX\x86\SlimDX.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Controls\AiwazViewControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\PropertyItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Controls\PropertyGrid.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Views\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\PropertyGrid.xaml.cs">
<DependentUpon>PropertyGrid.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\PropertyItem.xaml.cs">
<DependentUpon>PropertyItem.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\ResourceViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Controls\AiwazViewControl.xaml.cs">
<DependentUpon>AiwazViewControl.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="Editor.py">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Resources\SelectionHighlight.fx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aiwaz.Common\Aiwaz.Common.csproj">
<Project>{0F7D7168-08C1-45AE-AAE3-80506939D7E6}</Project>
<Name>Aiwaz.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Aiwaz.Contracts\Aiwaz.Contracts.csproj">
<Project>{DE4D6FE6-D1FB-41A1-8ABA-19635B8FFD7A}</Project>
<Name>Aiwaz.Contracts</Name>
</ProjectReference>
<ProjectReference Include="..\Aiwaz.Core\Aiwaz.Core.csproj">
<Project>{B7AB4BB3-6FFC-453E-928D-852A6FF8C508}</Project>
<Name>Aiwaz.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Aiwaz.Demo\Aiwaz.Demo.csproj">
<Project>{C3222C73-8869-46A6-862D-4B73DD52BC23}</Project>
<Name>Aiwaz.Demo</Name>
</ProjectReference>
<ProjectReference Include="..\Aiwaz.Resources\Aiwaz.Resources.csproj">
<Project>{EA73561A-0B57-4FDC-8AF3-52E959BA67E7}</Project>
<Name>Aiwaz.Resources</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\Untitled.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="EmbeddedResources\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,10 @@
<Application x:Class="Aiwaz.Editor.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Views/MainWindow.xaml"
Startup="Application_Startup"
Exit="Application_Exit">
<Application.Resources>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using Aiwaz.Core;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
using System.Reflection;
using System.IO;
namespace Aiwaz.Editor
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public ScriptEngine ScriptEngine;
private void Application_Exit(object sender, ExitEventArgs e)
{
Engine.Uninitialize();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
Engine.Initialize(null);
this.ScriptEngine = Python.CreateEngine();
this.ScriptEngine.Runtime.LoadAssembly(Assembly.LoadFile(Path.Combine(Environment.CurrentDirectory, "Aiwaz.Contracts.dll")));
this.ScriptEngine.Runtime.LoadAssembly(Assembly.LoadFile(Path.Combine(Environment.CurrentDirectory, "Aiwaz.Common.dll")));
this.ScriptEngine.Runtime.LoadAssembly(Assembly.LoadFile(Path.Combine(Environment.CurrentDirectory, "Aiwaz.Core.dll")));
this.ScriptEngine.Runtime.LoadAssembly(Assembly.LoadFile(Path.Combine(Environment.CurrentDirectory, "Aiwaz.Resources.dll")));
var globalScope = this.ScriptEngine.Runtime.CreateScope();
globalScope.SetVariable("myVar", "hallo");
var script = this.ScriptEngine.CreateScriptSourceFromFile("Editor.py");
var code = script.Compile();
script.Execute(globalScope); // see output window, fool!
var myVarResult = globalScope.GetVariable("myVar");
}
}
}

View File

@@ -0,0 +1,10 @@
<UserControl x:Class="Aiwaz.Editor.Controls.AiwazViewControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms">
<Grid>
<WindowsFormsHost>
<wf:UserControl x:Name="RenderTarget" Resize="RenderTarget_Resize"/>
</WindowsFormsHost>
</Grid>
</UserControl>

View File

@@ -0,0 +1,407 @@
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 Aiwaz.Resources;
using System.Windows.Threading;
using Aiwaz.Core;
using Aiwaz.Contracts;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using SlimDX;
namespace Aiwaz.Editor.Controls
{
/// <summary>
/// Interaction logic for AiwazViewControl.xaml
/// </summary>
public partial class AiwazViewControl : System.Windows.Controls.UserControl
{
#region Win32
public static Point CorrectGetPosition(Visual relativeTo)
{
Win32Point w32Mouse = new Win32Point();
GetCursorPos(ref w32Mouse);
return relativeTo.PointFromScreen(new Point(w32Mouse.X, w32Mouse.Y));
}
[StructLayout(LayoutKind.Sequential)]
internal struct Win32Point
{
public Int32 X;
public Int32 Y;
};
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetCursorPos(ref Win32Point pt);
#endregion
private DateTime lastPerformCalledTime = DateTime.UtcNow;
private bool rightButtonPressed;
private bool leftButtonPressed;
private bool moveThresholdReached;
private Point lastMousePosition;
private int desiredFPS = 30;
private DispatcherTimer renderTimer;
private RenderCommandNode mainRootNode;
private RenderCommandNode rootNode;
private Shader selectionShader;
private RenderCommandNode selectionMarkerNode;
private PickableResourceInfo selectedResourceInfo;
public delegate void PerformCalledDelegate(object sender, TimeSpan elapsedTime);
public delegate void SelectedResourceChangedDelegate(object sender, PickableResourceInfo newSelectedResourceInfo);
public event PerformCalledDelegate PerformCalled;
public event SelectedResourceChangedDelegate SelectedResourceChanged;
public AiwazViewControl()
{
InitializeComponent();
if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
return;
this.SwapChain = new SwapChain(RenderTarget.Handle);
this.SwapChain.HasDepthStencilBuffer = true;
MainRootNode.Children.Add(this.SwapChain);
MainRootNode.Children.Add(RootNode);
renderTimer = new DispatcherTimer();
renderTimer.Tick += new EventHandler(delegate(object s, EventArgs a)
{
this.Perform();
});
renderTimer.Interval = TimeSpan.FromMilliseconds(1000 / 30.0);
renderTimer.Start();
selectionMarkerNode = new RenderCommandNode();
selectionShader = new Shader(new ShaderParams() { FileName = "Resources/SelectionHighlight.fx" });
selectionShader.Priority = 128;
MainRootNode.Children.Add(selectionMarkerNode);
this.RenderTarget.MouseDown += new System.Windows.Forms.MouseEventHandler(RenderTarget_MouseButtonDown);
this.RenderTarget.MouseUp += new System.Windows.Forms.MouseEventHandler(RenderTarget_MouseButtonUp);
}
public ICamera MainCamera
{
get
{
return FindLastAvailableCamera(MainRootNode);
}
}
public PickableResourcesDataSource PickableResources { get; set; }
public RenderCommandNode MainRootNode
{
get
{
if (mainRootNode == null)
{
mainRootNode = new RenderCommandNode();
}
return mainRootNode;
}
set
{
mainRootNode = value;
}
}
public SwapChain SwapChain { get; protected set; }
public RenderCommandNode RootNode
{
get
{
if (rootNode == null)
{
rootNode = new RenderCommandNode();
}
return rootNode;
}
set
{
mainRootNode.Children.Remove(rootNode);
rootNode = value;
mainRootNode.Children.Add(value);
}
}
public TimeSpan RenderInterval
{
get { return renderTimer.Interval; }
set { renderTimer.Interval = value; }
}
public PickableResourceInfo SelectedResourceInfo
{
get
{
return selectedResourceInfo;
}
set
{
if (selectedResourceInfo != null)
{
selectionMarkerNode.Children.Clear();
selectionMarkerNode.MarkDirty();
}
selectedResourceInfo = value;
if (selectedResourceInfo != null)
{
selectionMarkerNode.Children.Add(selectionShader);
if (selectedResourceInfo.Transformation != null)
selectionMarkerNode.Children.Add(selectedResourceInfo.Transformation);
if (selectedResourceInfo.Resource != null)
selectionMarkerNode.Children.Add(selectedResourceInfo.Resource);
}
if (SelectedResourceChanged != null)
SelectedResourceChanged(this, selectedResourceInfo);
}
}
public int DesiredFPS
{
get
{
return desiredFPS;
}
set
{
desiredFPS = value;
if (desiredFPS <= 0)
renderTimer.Interval = TimeSpan.FromMilliseconds(0);
else
renderTimer.Interval = TimeSpan.FromMilliseconds(1000 / (double)desiredFPS);
}
}
private ICamera FindLastAvailableCamera(Resource rootNode)
{
ICamera lastFoundCamera = null;
if (rootNode.Children != null)
foreach (var child in rootNode.Children)
{
if (child is ICamera)
lastFoundCamera = child as ICamera;
if (child is Resource)
lastFoundCamera = this.FindLastAvailableCamera(child as Resource) ?? lastFoundCamera;
}
return lastFoundCamera;
}
protected void Perform()
{
mainRootNode.Update(false);
mainRootNode.ProcessCommands();
this.SwapChain.Present();
var deltaTime = DateTime.UtcNow - lastPerformCalledTime;
this.PerformCalledInternal(deltaTime);
if (PerformCalled != null)
PerformCalled(this, deltaTime);
lastPerformCalledTime = DateTime.UtcNow;
}
private void RenderTarget_Resize(object sender, EventArgs e)
{
if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
return;
this.SwapChain.Resize((int)this.Width, (int)this.Height);
}
private void RenderTarget_MouseButtonUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
rightButtonPressed = false;
else if (e.Button == MouseButtons.Left)
leftButtonPressed = false;
lastMousePosition = CorrectGetPosition(this);
if (!moveThresholdReached)
{
if (e.Button == MouseButtons.Right)
{
if (this.ContextMenu != null)
this.ContextMenu.IsOpen = true;
}
else if (e.Button == MouseButtons.Left)
{
if (PickableResources != null)
{
var mainCamera = this.MainCamera;
int width = this.SwapChain.ViewPort.Width;
int height = this.SwapChain.ViewPort.Height;
var viewProj = mainCamera.ViewMatrix * mainCamera.ProjectionMatrix;
Vector3 ZNearPlane = Vector3.Unproject(new Vector3((float)lastMousePosition.X, (float)lastMousePosition.Y, 0), 0, 0, width, height,
this.SwapChain.ViewPort.MinDepth, this.SwapChain.ViewPort.MaxDepth, viewProj);
Vector3 ZFarPlane = Vector3.Unproject(new Vector3((float)lastMousePosition.X, (float)lastMousePosition.Y, 1), 0, 0, width, height,
this.SwapChain.ViewPort.MinDepth, this.SwapChain.ViewPort.MaxDepth, viewProj);
Vector3 direction = ZFarPlane - ZNearPlane;
direction.Normalize();
Ray ray = new Ray(ZNearPlane, direction);
PickableResourceInfo winnerResourceInfo = this.SelectedResourceInfo;
float distance = float.MaxValue;
foreach (var pickable in PickableResources)
{
float newDistance;
if (pickable.PickHull.TryPick(ray, pickable.Transformation.WorldMatrix, out newDistance)
&& newDistance < distance)
{
winnerResourceInfo = pickable;
distance = newDistance;
}
}
if (this.SelectedResourceInfo != null && winnerResourceInfo != null && this.SelectedResourceInfo.Resource == winnerResourceInfo.Resource)
winnerResourceInfo = null;
this.SelectedResourceInfo = winnerResourceInfo;
}
}
}
if (!leftButtonPressed && !rightButtonPressed)
{
renderTimer.Interval = TimeSpan.FromMilliseconds(1000 / (double)desiredFPS);
moveThresholdReached = false;
}
}
private void RenderTarget_MouseButtonDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
rightButtonPressed = true;
else if (e.Button == MouseButtons.Left)
leftButtonPressed = true;
if (leftButtonPressed || rightButtonPressed)
renderTimer.Interval = TimeSpan.FromMilliseconds(0);
lastMousePosition = CorrectGetPosition(this);
}
private void PerformCalledInternal(TimeSpan elapsedTime)
{
var currentMousePosition = CorrectGetPosition(this);
var deltaTime = Math.Max(1.0, elapsedTime.TotalSeconds);
var deltaMouse = currentMousePosition - lastMousePosition;
lastMousePosition = currentMousePosition;
var power = 1.7;
if (rightButtonPressed && !leftButtonPressed)
power = 1.25;
deltaMouse.X = Math.Pow(Math.Abs(deltaMouse.X), power) * Math.Sign(deltaMouse.X) * deltaTime;
deltaMouse.Y = Math.Pow(Math.Abs(deltaMouse.Y), power) * Math.Sign(deltaMouse.Y) * deltaTime;
if (!leftButtonPressed && !rightButtonPressed)
return;
moveThresholdReached = moveThresholdReached || deltaMouse.Length >= 3.0;
if (!moveThresholdReached)
return;
var mainCamera = this.MainCamera as Transformation;
if (rightButtonPressed && leftButtonPressed)
{
mainCamera.LocalPosition += mainCamera.LocalUpDirection * -(float)deltaMouse.Y * 0.005f +
mainCamera.LocalRightDirection * (float)deltaMouse.X * 0.005f;
}
else if (leftButtonPressed)
{
mainCamera.LocalPosition += mainCamera.LocalDirection * -(float)deltaMouse.Y * 0.005f +
mainCamera.LocalRightDirection * (float)deltaMouse.X * 0.005f;
}
else if (rightButtonPressed)
{
var yawPitchRoll = mainCamera.LocalRotationYPR;
yawPitchRoll.X += (float)deltaMouse.X * 0.005f;
yawPitchRoll.Y += (float)deltaMouse.Y * 0.005f;
if (yawPitchRoll.Y > Math.PI / 2)
yawPitchRoll.Y = (float)Math.PI / 2;
else if (yawPitchRoll.Y < -Math.PI / 2)
yawPitchRoll.Y = -(float)Math.PI / 2;
mainCamera.LocalRotationYPR = yawPitchRoll;
}
}
}
public class PickableResourcesDataSource : List<PickableResourceInfo>
{
public static PickableResourcesDataSource CreateFromResource(Resource rootNode)
{
var pickablesDataResource = new PickableResourcesDataSource();
List<KeyValuePair<Transformation, IGeometryBuffer>> pickables = new List<KeyValuePair<Transformation, IGeometryBuffer>>();
FindAllPickables(rootNode, null, pickables);
foreach (var pickable in pickables)
{
pickablesDataResource.Add(new PickableResourceInfo()
{
PickHull = pickable.Value.PickHull,
Transformation = pickable.Key,
Resource = pickable.Value as IResource
});
}
return pickablesDataResource;
}
private static void FindAllPickables(Resource rootNode, Transformation lastTransformation, List<KeyValuePair<Transformation, IGeometryBuffer>> pickables)
{
if (rootNode.Children != null)
foreach (var child in rootNode.Children)
{
if (child is Transformation)
lastTransformation = child as Transformation;
if (child is IGeometryBuffer && lastTransformation != null)
{
var geoBuffer = child as IGeometryBuffer;
if (geoBuffer.IsPickable)
pickables.Add(new KeyValuePair<Transformation, IGeometryBuffer>(lastTransformation, geoBuffer));
}
if (child is Resource)
FindAllPickables(child as Resource, lastTransformation, pickables);
}
}
}
public class PickableResourceInfo
{
public IResource Resource;
public Transformation Transformation;
public IPickHull PickHull;
}
}

View File

@@ -0,0 +1,36 @@
<HeaderedContentControl x:Class="Aiwaz.Editor.Controls.PropertyGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pg="clr-namespace:Aiwaz.Editor.Controls">
<HeaderedContentControl.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Search:" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBox x:Name="searchTextBox" Grid.Column="1"/>
</Grid>
</HeaderedContentControl.Header>
<Border BorderThickness="1" BorderBrush="#FF828790">
<Grid>
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="LightGray" Offset="0.0" />
<GradientStop Color="White" Offset="1.0" />
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer x:Name="propertyGridScrollBar" Grid.Row="0" CanContentScroll="False" VerticalScrollBarVisibility="Visible">
<ScrollViewer.Content>
<StackPanel x:Name="PropertyPanel"/> <!--PropertyItems go in here-->
</ScrollViewer.Content>
</ScrollViewer>
<TextBlock x:Name="descriptionTextBlock" Grid.Row="1" TextWrapping="Wrap"/>
</Grid>
</Border>
</HeaderedContentControl>

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.ComponentModel;
namespace Aiwaz.Editor.Controls
{
public partial class PropertyGrid : HeaderedContentControl
{
private object selectedObject = null;
public PropertyGrid()
{
InitializeComponent();
searchTextBox.TextChanged += new TextChangedEventHandler(searchTextBox_TextChanged);
}
#region PropertyGrid related stuff
public object SelectedObject{
get { return selectedObject; }
set { selectedObject = value; SelectedObjectHelper(selectedObject,null); }
}
public void SelectedObjectHelper(object value,EventArgs e) {
if (!Application.Current.Dispatcher.CheckAccess())
{
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
new EventHandler(SelectedObjectHelper), value, e);
}
else
{
this.PropertyPanel.Children.Clear(); //clear propertypanel
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(value))
{
if (!property.IsBrowsable) continue; //could also check for browsableattribute, but this one's shorter
PropertyItem currentProperty = new PropertyItem();
currentProperty.PropertyName = property.Name;
Binding b = new Binding(property.Name);
b.Source = selectedObject;
b.Mode = property.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
currentProperty.SetBinding(PropertyItem.PropertyValueProperty, b);
currentProperty.OnActive += new EventHandler<DescriptionEventArgs>(currentProperty_OnActive);
foreach (Attribute attribute in property.Attributes)
{
if (attribute.GetType() == typeof(DescriptionAttribute))
{
currentProperty.PropertyDescription = ((DescriptionAttribute)attribute).Description;
}
if (attribute.GetType() == typeof(CategoryAttribute)) {
currentProperty.PropertyCategory = ((CategoryAttribute)attribute).Category;
}
}
PropertyPanel.Children.Add(currentProperty); //add the propertyitem
}
}
}
#endregion
#region events
void searchTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
string filterText = searchTextBox.Text.ToLower(); //we don't want to be case sensitive
foreach (PropertyItem pi in PropertyPanel.Children)
{ //hide PropertyItem if it does not contain filter text
pi.Visibility = (pi.PropertyName.ToLower().Contains(filterText) || filterText.Equals(string.Empty)) ? Visibility.Visible : Visibility.Collapsed;
}
}
void currentProperty_OnActive(object sender, DescriptionEventArgs e)
{
if (!Application.Current.Dispatcher.CheckAccess()){
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
new EventHandler<DescriptionEventArgs>(currentProperty_OnActive),sender, e);
}else{
this.descriptionTextBlock.Text = e.Description;
}
}
#endregion
}
}

View File

@@ -0,0 +1,13 @@
<UserControl x:Class="Aiwaz.Editor.Controls.PropertyItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid x:Name="PropertyItemGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Path=PropertyName}" Grid.Column="0"/>
<TextBox Text="{Binding Path=PropertyValue,Mode=TwoWay}" Grid.Column="1" MouseEnter="TextBox_MouseEnter" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.ComponentModel;
namespace Aiwaz.Editor.Controls
{
/// <summary>
/// Interaction logic for PropertyItem.xaml
/// </summary>
public partial class PropertyItem : UserControl
{
public static readonly DependencyProperty PropertyNameProperty = DependencyProperty.Register("PropertyName", typeof(string), typeof(PropertyItem));
public static readonly DependencyProperty PropertyValueProperty = DependencyProperty.Register("PropertyValue", typeof(object), typeof(PropertyItem));
public static readonly DependencyProperty PropertyDescriptionProperty = DependencyProperty.Register("PropertyDescription", typeof(string), typeof(PropertyItem));
public static readonly DependencyProperty PropertyCategoryProperty = DependencyProperty.Register("PropertyCategory", typeof(string), typeof(PropertyItem));
public EventHandler<DescriptionEventArgs> DescriptionEventHandler;
public event EventHandler<DescriptionEventArgs> OnActive;
public PropertyItem()
{
InitializeComponent();
PropertyItemGrid.DataContext = this;
}
public string PropertyName {
get { return (string)GetValue(PropertyItem.PropertyNameProperty); }
set { SetValue(PropertyItem.PropertyNameProperty, value); }
}
public object PropertyValue
{
get{ return (string)GetValue(PropertyItem.PropertyValueProperty);}
set{ SetValue(PropertyItem.PropertyValueProperty, value); }
}
public string PropertyDescription
{
get { return (string)GetValue(PropertyItem.PropertyDescriptionProperty); }
set { SetValue(PropertyItem.PropertyDescriptionProperty, value);}
}
public string PropertyCategory
{
get { return (string)GetValue(PropertyItem.PropertyCategoryProperty); }
set { SetValue(PropertyItem.PropertyCategoryProperty, value); }
}
#region events
private void TextBox_MouseEnter(object sender, MouseEventArgs e)
{
if (OnActive != null) {
OnActive(this, new DescriptionEventArgs(PropertyDescription));
}
}
#endregion
}
public class DescriptionEventArgs : EventArgs{
public string Description { get; set;}
public DescriptionEventArgs(string descr){
this.Description = descr;
}
}
}

View File

@@ -0,0 +1,3 @@
print myVar
myVar = 100
print myVar

View File

@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Aiwaz.Editor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Aiwaz.Editor")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Aiwaz.Editor.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Aiwaz.Editor.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Aiwaz.Editor.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,76 @@
matrix WorldMatrix : WorldMatrix;
matrix ViewMatrix : ViewMatrix;
matrix ProjectionMatrix : ProjectionMatrix;
Texture2D Diffuse : Diffuse;
SamplerState samLinear
{
Filter = ANISOTROPIC;
AddressU = Wrap;
AddressV = Wrap;
};
DepthStencilState RenderWithStencilState
{
StencilEnable = false;
DepthEnable = TRUE;
DepthWriteMask = ALL;
DepthFunc = Equal;
};
RasterizerState EnableCulling
{
CullMode = Back;
};
BlendState AlphaBlending
{
AlphaToCoverageEnable = FALSE;
BlendEnable[0] = TRUE;
SrcBlend = SRC_ALPHA;
DestBlend = INV_SRC_ALPHA;
BlendOp = ADD;
SrcBlendAlpha = SRC_ALPHA;
DestBlendAlpha = INV_SRC_ALPHA;
BlendOpAlpha = ADD;
};
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};
VS_OUTPUT VS(float4 Pos : POSITION, float2 Tex : TEXCOORD)
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.Pos = mul( Pos, WorldMatrix );
output.Pos = mul( output.Pos, ViewMatrix );
output.Pos = mul( output.Pos, ProjectionMatrix );
output.Tex = Tex;
return output;
}
float4 PS( VS_OUTPUT input) : SV_Target
{
return float4(0.0, 1.0, 1.0, 0.25);
}
//--------------------------------------------------------------------------------------
technique10 Render
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
SetDepthStencilState( RenderWithStencilState, 0 );
SetBlendState( AlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetRasterizerState( EnableCulling );
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Aiwaz.Contracts;
using System.Collections.Specialized;
using System.Windows.Controls;
using System.Windows.Media;
using System.Reflection;
using System.IO;
using System.Windows.Media.Imaging;
namespace Aiwaz.Editor.ViewModels
{
public class ResourceViewModel : ViewModelBase
{
private bool creating;
public IResource Resource;
public string DisplayName
{
get
{
return Resource.WellKnownName;
}
set
{
Resource.WellKnownName = value;
}
}
public ImageSource DisplayIcon
{
get
{
var stream = File.OpenRead("Resources/Untitled.png");
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = stream;
bitmap.EndInit();
return bitmap;
}
}
private ObservableCollection<ResourceViewModel> nodes;
public ObservableCollection<ResourceViewModel> Nodes
{
get
{
if (nodes == null)
{
nodes = new ObservableCollection<ResourceViewModel>();
nodes.CollectionChanged += new NotifyCollectionChangedEventHandler(nodes_CollectionChanged);
}
return nodes;
}
set
{
if (nodes != value)
{
nodes = value;
OnPropertyChanged("Nodes");
}
}
}
void nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (creating)
return;
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (ResourceViewModel newItem in e.NewItems)
{
Resource.Children.Insert(e.NewStartingIndex, newItem.Resource);
}
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (ResourceViewModel oldItem in e.OldItems)
{
Resource.Children.Remove(oldItem.Resource);
}
}
OnPropertyChanged("Nodes");
}
public ResourceViewModel(IResource resource)
{
this.Resource = resource;
creating = true;
if (resource.Children != null)
foreach (var child in resource.Children)
{
Nodes.Add(new ResourceViewModel(child));
}
creating = false;
OnPropertyChanged("Nodes");
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace Aiwaz.Editor.ViewModels
{
public class ViewModelBase : INotifyPropertyChanged
{
#region INotifyPropertyChanged Members
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
}

View File

@@ -0,0 +1,62 @@
<Window x:Class="Aiwaz.Editor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:cus="clr-namespace:Aiwaz.Editor.Controls"
Title="Window1" Height="550" Width="900">
<Window.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="Gray" Offset="0.0" />
<GradientStop Color="LightGray" Offset="1.0" />
</LinearGradientBrush>
</Window.Background>
<Grid Margin="5">
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="LightGray" Offset="0.0" />
<GradientStop Color="White" Offset="1.0" />
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="10" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" Grid.RowSpan="3">
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="10" />
<RowDefinition Height="3*" />
</Grid.RowDefinitions>
<TreeView Grid.Row="0" x:Name="trvNodes" ItemsSource="{Binding Nodes}" AllowDrop="True">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Nodes}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding DisplayIcon}"/>
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
<TreeView.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="LightGray" Offset="0.0" />
<GradientStop Color="White" Offset="1.0" />
</LinearGradientBrush>
</TreeView.Background>
</TreeView>
<GridSplitter Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="10" />
<cus:PropertyGrid x:Name="Properties" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
<GridSplitter Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="10" Grid.RowSpan="3"/>
<cus:AiwazViewControl Grid.Row="0" Grid.Column="2" x:Name="aiwazControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
</cus:AiwazViewControl>
<GridSplitter Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="10" />
<Slider Grid.Row="2" Grid.Column="2" />
</Grid>
</Window>

View File

@@ -0,0 +1,87 @@
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
{
public partial class MainWindow : Window
{
public ResourceViewModel ResourceViewModel;
public MainWindow()
{
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<SlimDX.Vector3>(new SlimDX.Vector3(0.0f, 1.0f, 0.0f));
var lightColor = new ReferenceT<SlimDX.Vector4>(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<object>(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<object> e)
{
Properties.SelectedObject = ((ResourceViewModel)(e.NewValue)).Resource;
}
}
}