Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
s3py committed Sep 23, 2012
1 parent 4edc507 commit 029a757
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 138 deletions.
89 changes: 0 additions & 89 deletions Helpers/ModelViewer/Grid3D.cs

This file was deleted.

71 changes: 29 additions & 42 deletions Helpers/ModelViewer/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Window x:Class="s3piwrappers.ModelViewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:_3DTools;assembly=3DTools"
xmlns:ModelViewer="clr-namespace:s3piwrappers.ModelViewer"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ModelViewer="clr-namespace:s3piwrappers.ModelViewer"
xmlns:helix="http://helixtoolkit.codeplex.com"
Title="Model Viewer"
Height="600"
Width="800"
Expand Down Expand Up @@ -80,49 +80,54 @@
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>

<Border Grid.Column="0"
Grid.Row="0">
<StackPanel Focusable="True">
<StackPanel Margin="5">
<TextBlock>Shading:</TextBlock>
<StackPanel Margin="2,0">
<RadioButton

<TextBlock>Shading:</TextBlock>
<StackPanel Margin="2,0">
<RadioButton
x:Name="rbSolid"
Content="Solid"
GroupName="Shading"
Checked="RadioButton_Checked" />
<RadioButton
<RadioButton
x:Name="rbTextured"
Content="Textured"
GroupName="Shading"
Checked="RadioButton_Checked" />
<RadioButton
<RadioButton
Content="UV"
GroupName="Shading"
Checked="RadioButton_Checked" />
</StackPanel>
</StackPanel>
<StackPanel
x:Name="MeshesPanel">
<TextBlock>Meshes:</TextBlock>
<ListView x:Name="mMeshListView"
<ListView x:Name="mMeshListView"
SelectionChanged="mMeshListView_SelectionChanged"
SelectionMode="Single"></ListView>
</StackPanel>
<StackPanel x:Name="GeostatesPanel">
<TextBlock>States:</TextBlock>
<ListView x:Name="mStateListView"
<TextBlock>States:</TextBlock>
<ListView x:Name="mStateListView"
SelectionChanged="mStateListView_SelectionChanged"
SelectionMode="Single"
AllowDrop="True"></ListView>

</StackPanel>
<TextBlock
x:Name="VertexCount">
Vertices: 500</TextBlock>
<TextBlock
x:Name="PolygonCount">
Polygons: 1000</TextBlock>

<TextBlock x:Name="Help">

</TextBlock>
</StackPanel>
</StackPanel>
</Border>
Expand All @@ -137,35 +142,17 @@
Grid.RowSpan="1"
MinWidth="320"
Background="#FF6F6F6F">
<local:TrackballDecorator>
<local:Interactive3DDecorator>
<Viewport3D Name="mainViewport"
<helix:HelixViewport3D Name="mainViewport"
ClipToBounds="True"
Focusable="True">
<Viewport3D.Camera>
<PerspectiveCamera x:Name="viewCamera"
Position="0,0.5,5" />
</Viewport3D.Camera>
<ModelViewer:Grid3D x:Name="mGrid"></ModelViewer:Grid3D>
<ModelVisual3D x:Name="mLightGroup">
<ModelVisual3D.Content>
<Model3DGroup>
<AmbientLight Color="Gray"
x:Name="mAmbient" />
<DirectionalLight Color="White"
Direction="0,-2,-5"
x:Name="mDirectional" />
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="mGroupMeshes"></Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</local:Interactive3DDecorator>
</local:TrackballDecorator>
Focusable="True" CameraRotationMode="Trackball" ModelUpDirection="0,0,-1">
<helix:DefaultLights/>
<ModelVisual3D>
<helix:GridLinesVisual3D MajorDistance="1" ></helix:GridLinesVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="mGroupMeshes"></Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</helix:HelixViewport3D>
</DockPanel>
</Grid>
</Window>
24 changes: 23 additions & 1 deletion Helpers/ModelViewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ public MainWindow()
mShadowMapMaterial = new DiffuseMaterial(shadowBrush);
GeostateDictionary = LoadDictionary("Geostates");
MeshDictionary = LoadDictionary("MeshNames");
Help.Text =
@"
Zoom:
1. Mouse Wheel
2. Ctrl+RMB+Drag
3. PageUp/PageDown
Pan:
1. MouseWheel+Drag
2. Shift+RMB+Drag
3. Shift+Arrow Keys
Rotate:
1. RMB+Drag
2. Arrow Keys
";

}
public MainWindow(Stream s)
Expand Down Expand Up @@ -240,8 +256,13 @@ void InitScene()
if (chunk != null)
{
var mlod = chunk.RCOLBlock as MLOD;
double max_height = 0;
foreach (var m in mlod.Meshes)
{
if (m.Bounds.Max.Y > max_height)
{
max_height = m.Bounds.Max.Y;
}
vertCount += m.VertexCount;
polyCount += m.PrimitiveCount;
var vbuf = (VBUF)GenericRCOLResource.ChunkReference.GetBlock(rcol, m.VertexBufferIndex);
Expand Down Expand Up @@ -291,6 +312,7 @@ void InitScene()
mGroupMeshes.Children.Add(model);
mSceneMeshes.Add(sceneMesh);
}

}
else
{
Expand Down Expand Up @@ -403,7 +425,7 @@ static GeometryModel3D DrawModel(meshExpImp.ModelBlocks.Vertex[] verts, Int32[]
{
meshExpImp.ModelBlocks.Vertex v = verts[k];

if (v.Position != null) mesh.Positions.Add(new Point3D(v.Position[0], v.Position[1], v.Position[2]));
if (v.Position != null) mesh.Positions.Add(new Point3D(v.Position[0], -v.Position[2], v.Position[1]));
if (v.Normal != null) mesh.Normals.Add(new Vector3D(v.Normal[0], v.Normal[1], v.Normal[2]));
if (v.UV != null && v.UV.Length > 0) mesh.TextureCoordinates.Add(new Point(v.UV[0][0], v.UV[0][1]));
}
Expand Down
6 changes: 2 additions & 4 deletions Helpers/ModelViewer/ModelViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="3DTools, Version=1.0.2614.20437, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\3DTools-1.01-bin\3DTools.dll</HintPath>
<Reference Include="HelixToolkit.Wpf">
<HintPath>..\..\..\..\..\..\lib\NET\helix\HelixToolkit.Wpf.dll</HintPath>
</Reference>
<Reference Include="s3pi.GenericRCOLResource">
<HintPath>..\..\lib\s3pi_current\s3pi.GenericRCOLResource.dll</HintPath>
Expand Down Expand Up @@ -89,7 +88,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="App.cs" />
<Compile Include="Grid3D.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
4 changes: 2 additions & 2 deletions s3piwrappers.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Helpers", "Helpers", "{9F9C64E9-B8A3-4933-9C3B-78560F6A206E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "s3piwrappers.AnimationResources", "s3piwrappers.AnimationResources\s3piwrappers.AnimationResources.csproj", "{B33F19DE-F211-4D32-8D03-43024B88F177}"
Expand Down

0 comments on commit 029a757

Please sign in to comment.