[Liblas-commits] libpc: pcview work
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Mar 4 17:47:45 EST 2011
details: http://hg.liblas.orglibpc/rev/23e91f43b490
changeset: 178:23e91f43b490
user: Michael P. Gerlek <mpg at flaxen.com>
date: Fri Mar 04 14:47:27 2011 -0800
description:
pcview work
diffstat:
csharp/PCView/App.xaml | 2 +-
csharp/PCView/MainWindow.xaml | 14 +
csharp/PCView/MainWindow.xaml.cs | 196 ++++++++++++
csharp/PCView/Mouse.fx | 35 --
csharp/PCView/Mouse.xaml | 14 -
csharp/PCView/Mouse.xaml.cs | 205 -------------
csharp/PCView/MouseRenderEngine.cs | 296 -------------------
csharp/PCView/PCView.csproj | 10 +-
csharp/PCView/PointCloudRenderEngine.cs | 493 ++++++++++++++++++++++++++++++++
csharp/PCView/pipeline.fx | 35 ++
10 files changed, 744 insertions(+), 556 deletions(-)
diffs (truncated from 1366 to 300 lines):
diff -r d0ca3d54fcdb -r 23e91f43b490 csharp/PCView/App.xaml
--- a/csharp/PCView/App.xaml Fri Mar 04 12:39:35 2011 -0800
+++ b/csharp/PCView/App.xaml Fri Mar 04 14:47:27 2011 -0800
@@ -1,7 +1,7 @@
<Application x:Class="Flaxen.SlimDXControlLib.MouseExample.MouseApp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- StartupUri="Mouse.xaml">
+ StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
diff -r d0ca3d54fcdb -r 23e91f43b490 csharp/PCView/MainWindow.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/csharp/PCView/MainWindow.xaml Fri Mar 04 14:47:27 2011 -0800
@@ -0,0 +1,14 @@
+<Window x:Class="Flaxen.SlimDXControlLib.MouseExample.MainWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d3d="clr-namespace:Flaxen.SlimDXControlLib;assembly=Flaxen.SlimDXControlLib"
+ Title="Mouse Example"
+ Width="500"
+ Height="500">
+
+ <DockPanel LastChildFill="True" >
+ <TextBlock DockPanel.Dock="Bottom" Text="{Binding Path=PositionString}" />
+ <d3d:SlimDXControl DockPanel.Dock="Top" x:Name="x_contentControl" />
+ </DockPanel>
+
+</Window>
diff -r d0ca3d54fcdb -r 23e91f43b490 csharp/PCView/MainWindow.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/csharp/PCView/MainWindow.xaml.cs Fri Mar 04 14:47:27 2011 -0800
@@ -0,0 +1,196 @@
+//-----------------------------------------------------------------------
+// <copyright file="Mouse.xaml.cs" company="Flaxen Geo">
+// Copyright (c) 2011, Michael P. Gerlek. All rights reserved.
+// </copyright>
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of Flaxen Geo nor the names of its contributors may be
+// used to endorse or promote products derived from this software without
+// specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//-----------------------------------------------------------------------
+
+namespace Flaxen.SlimDXControlLib.MouseExample
+{
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Windows;
+ using System.Windows.Documents;
+ using System.Windows.Input;
+ using SlimDX;
+
+ /// <summary>
+ /// Implements the MouseExample test.
+ /// </summary>
+ public partial class MainWindow : Window, INotifyPropertyChanged
+ {
+ private PointCloudRenderEngine m_renderEngine;
+ private Point m_downPoint;
+ private bool m_isMoving = false;
+ private string m_positionString;
+
+ /// <summary>
+ /// Initializes a new instance of the Mouse class.
+ /// </summary>
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ m_renderEngine = new PointCloudRenderEngine();
+ x_contentControl.RegisterRenderer(m_renderEngine);
+
+ this.MouseMove += new MouseEventHandler(Mouse_MouseMove);
+ this.MouseDown += new MouseButtonEventHandler(Mouse_MouseDown);
+ this.MouseUp += new MouseButtonEventHandler(Mouse_MouseUp);
+ this.MouseWheel += new MouseWheelEventHandler(Mouse_MouseWheel);
+
+ PositionString = string.Empty;
+
+ this.DataContext = this;
+
+ Vector4[] points = CreateData();
+ m_renderEngine.SetPoints(points);
+
+ return;
+ }
+
+ /// <summary>
+ /// Gets or sets a string containing the mouse position (in world coordinates).
+ /// </summary>
+ public string PositionString
+ {
+ get
+ {
+ return m_positionString;
+ }
+
+ set
+ {
+ if (value != m_positionString)
+ {
+ m_positionString = value;
+ NotifyPropertyChanged("PositionString");
+ }
+ }
+ }
+
+ #region mouse handlers
+ private void Mouse_MouseDown(object sender, MouseButtonEventArgs e)
+ {
+ if (e.LeftButton == MouseButtonState.Pressed)
+ {
+ m_downPoint = e.GetPosition(x_contentControl);
+ m_isMoving = true;
+ }
+ }
+
+ private void Mouse_MouseUp(object sender, MouseButtonEventArgs e)
+ {
+ m_isMoving = false;
+ }
+
+ private void Mouse_MouseMove(object sender, MouseEventArgs e)
+ {
+ Point mouse = e.GetPosition(x_contentControl);
+
+ Vector3 world = m_renderEngine.ConvertToWorldCoordinates(mouse, (float)x_contentControl.ActualWidth, (float)x_contentControl.ActualHeight);
+
+ PositionString = string.Format(
+ CultureInfo.InvariantCulture,
+ "[{0},{1}] X={2} Y={3} Z={4}",
+ mouse.X,
+ mouse.Y,
+ world.X.ToString("F1", CultureInfo.InvariantCulture),
+ world.Y.ToString("F1", CultureInfo.InvariantCulture),
+ world.Z.ToString("F1", CultureInfo.InvariantCulture));
+
+ if (e.LeftButton == MouseButtonState.Pressed)
+ {
+ if (m_isMoving)
+ {
+ Point currPoint = e.GetPosition(x_contentControl);
+ Vector3 camera = m_renderEngine.CameraPosition;
+ Vector3 target = m_renderEngine.TargetPosition;
+ camera.X += (float)(m_downPoint.X - currPoint.X) / 100.0f;
+ target.X += (float)(m_downPoint.X - currPoint.X) / 100.0f;
+ camera.Y += -(float)(m_downPoint.Y - currPoint.Y) / 100.0f;
+ target.Y += -(float)(m_downPoint.Y - currPoint.Y) / 100.0f;
+ m_renderEngine.CameraPosition = camera;
+ m_renderEngine.TargetPosition = target;
+ m_downPoint = currPoint;
+ }
+ }
+
+ return;
+ }
+
+ private void Mouse_MouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ Vector3 camera = m_renderEngine.CameraPosition;
+ camera.Z += e.Delta / 100.0f;
+ camera.Z += e.Delta / 100.0f;
+ m_renderEngine.CameraPosition = camera;
+ }
+ #endregion
+
+ private Vector4[] CreateData()
+ {
+ Vector4 red = new Vector4(1, 0, 0, 1);
+ Vector4 green = new Vector4(0, 1, 0, 1);
+ Vector4 blue = new Vector4(0, 0, 1, 1);
+
+ List<Vector4> points = new List<Vector4>();
+
+ System.Random rand = new System.Random();
+
+ for (int p = 0; p < 1000; p++)
+ {
+ float x = (float)rand.NextDouble() * 100;
+ float y = (float)rand.NextDouble() * 10 + 45;
+ float z = (float)rand.NextDouble() * 100;
+ points.Add(new Vector4(x, y, z, 1));
+
+ float r = (float)rand.NextDouble();
+ float g = (float)rand.NextDouble();
+ float b = (float)rand.NextDouble();
+ points.Add(new Vector4(r, g, b, 1));
+ }
+
+ return points.ToArray();
+ }
+
+ #region INotifyPropertyChanged
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private void NotifyPropertyChanged(string info)
+ {
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs(info));
+ }
+ }
+ #endregion
+ }
+}
diff -r d0ca3d54fcdb -r 23e91f43b490 csharp/PCView/Mouse.fx
--- a/csharp/PCView/Mouse.fx Fri Mar 04 12:39:35 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-cbuffer cbPerObject
-{
- float4x4 gWVP;
-}
-
-// VertexShader
-void VS(float4 inputPos: POSITION,
- float4 inputCol: COLOR,
- out float4 outputPos : SV_POSITION,
- out float4 outputCol : COLOR)
-{
- //PS_IN output = (PS_IN)0;
-
- outputPos = mul(inputPos, gWVP);
-
- outputCol = inputCol;
-}
-
-// PixelShader
-void PS(float4 inputPos: SV_POSITION,
- float4 inputCol: COLOR,
- out float4 outputCol: SV_TARGET)
-{
- outputCol = inputCol;
-}
-
-technique10 Render
-{
- pass P0
- {
- SetGeometryShader( 0 );
- SetVertexShader( CompileShader( vs_4_0, VS() ) );
- SetPixelShader( CompileShader( ps_4_0, PS() ) );
- }
-}
diff -r d0ca3d54fcdb -r 23e91f43b490 csharp/PCView/Mouse.xaml
--- a/csharp/PCView/Mouse.xaml Fri Mar 04 12:39:35 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-<Window x:Class="Flaxen.SlimDXControlLib.MouseExample.Mouse"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d3d="clr-namespace:Flaxen.SlimDXControlLib;assembly=Flaxen.SlimDXControlLib"
- Title="Mouse Example"
- Width="500"
- Height="500">
-
- <DockPanel LastChildFill="True" >
- <TextBlock DockPanel.Dock="Bottom" Text="{Binding Path=PositionString}" />
- <d3d:SlimDXControl DockPanel.Dock="Top" x:Name="x_contentControl" />
- </DockPanel>
-
-</Window>
diff -r d0ca3d54fcdb -r 23e91f43b490 csharp/PCView/Mouse.xaml.cs
--- a/csharp/PCView/Mouse.xaml.cs Fri Mar 04 12:39:35 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="Mouse.xaml.cs" company="Flaxen Geo">
-// Copyright (c) 2011, Michael P. Gerlek. All rights reserved.
-// </copyright>
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
More information about the Liblas-commits
mailing list