Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for .NET

3D Symbol Rotation

Download Samples Repository

Description

Demonstrates how to rotate 3d symbols

"Desktop" Available for Desktop

Sample Code

<UserControl x:Class="ArcGISRuntime.Samples.Desktop.SymbolRotation3d"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
             mc:Ignorable="d" >
	<Grid>
		<Grid.Resources>
			<esri:SimpleRenderer x:Key="SimpleDiamondRenderer">
				<esri:SimpleRenderer.SceneProperties>
					<esri:RendererSceneProperties HeadingExpression="[Heading]" 
												  PitchExpression="[Pitch]"
												  RollExpression="[Roll]" />
				</esri:SimpleRenderer.SceneProperties>
				<esri:SimpleRenderer.Symbol>
					<esri:DiamondMarkerSymbol Color="Blue" Width="1000" Height="2000"/>
				</esri:SimpleRenderer.Symbol>
			</esri:SimpleRenderer>

			<esri:SimpleRenderer x:Key="SimpleBoxRenderer">
				<esri:SimpleRenderer.SceneProperties>
					<esri:RendererSceneProperties HeadingExpression="[Heading]" 
												  PitchExpression="[Pitch]" 
												  RollExpression="[Roll]" />
				</esri:SimpleRenderer.SceneProperties>
				<esri:SimpleRenderer.Symbol>
					<esri:BoxMarkerSymbol Width="1000" Height="1000" Depth="1000" Color="Red"/>
				</esri:SimpleRenderer.Symbol>
			</esri:SimpleRenderer>
		</Grid.Resources>
		
		<esri:SceneView x:Name="MySceneView" LayerLoaded="MySceneView_LayerLoaded">
			<esri:Scene>
				<esri:Scene.Surface>
					<esri:ServiceElevationSource ServiceUri="http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" 
												 IsEnabled="True" />
				</esri:Scene.Surface>
				<esri:ArcGISTiledMapServiceLayer ID="AGOLayer" 
												 ServiceUri="http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer" />				
			</esri:Scene>
			<esri:SceneView.GraphicsOverlays>
				<esri:GraphicsOverlay ID="DiamondGraphicsLayer" Renderer="{StaticResource SimpleDiamondRenderer}">
					<esri:GraphicsOverlay.SceneProperties>
						<esri:LayerSceneProperties SurfacePlacement="Relative"/>
					</esri:GraphicsOverlay.SceneProperties>
				</esri:GraphicsOverlay>
				<esri:GraphicsOverlay ID="BoxGraphicsLayer" Renderer="{StaticResource SimpleBoxRenderer}">
					<esri:GraphicsOverlay.SceneProperties>
						<esri:LayerSceneProperties SurfacePlacement="Draped"/>
					</esri:GraphicsOverlay.SceneProperties>
				</esri:GraphicsOverlay>
			</esri:SceneView.GraphicsOverlays>
		</esri:SceneView>
		<Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Width="100">
			<Border BorderBrush="Gray" BorderThickness="2" CornerRadius="4" Background="LightGray">
				<StackPanel>
					<StackPanel Background="Transparent" Margin="5">
						<TextBlock x:Name="txtHeading" Text="Heading" Foreground="Black"/>
						<Slider x:Name="HeadingSlider" Minimum="0" Maximum="360" ValueChanged="OnHeadingSliderChanged"/>
					</StackPanel>
					<StackPanel Background="Transparent" Margin="5">
						<TextBlock x:Name="txtPitch" Text="Pitch"  Foreground="Black"/>
						<Slider x:Name="PitchSlider" Minimum="0" Maximum="360" ValueChanged="OnPitchSliderChanged"/>
					</StackPanel>
					<StackPanel Background="Transparent" Margin="5">
						<TextBlock x:Name="txtRoll" Text="Roll"  Foreground="Black"/>
						<Slider x:Name="RollSlider" Minimum="0" Maximum="360" ValueChanged="OnRollSliderChanged"/>
					</StackPanel>
				</StackPanel>
			</Border>
		</Grid>
	</Grid>
</UserControl>
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Layers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace ArcGISRuntime.Samples.Desktop
{
	/// <summary>
	/// Demonstrates how to rotate 3d symbols
	/// </summary>
	/// <title>3D Symbol Rotation</title>
	/// <category>Scene</category>
	/// <subcategory>Symbology</subcategory>
	public partial class SymbolRotation3d : UserControl
	{
		public SymbolRotation3d()
		{
			InitializeComponent();
		}

		private void MySceneView_LayerLoaded(object sender, Esri.ArcGISRuntime.Controls.LayerLoadedEventArgs e)
		{
			if (e.LoadError == null && e.Layer.ID == "AGOLayer")
			{
				MySceneView.SetViewAsync(new Camera(new MapPoint(-106.57, 39.01, 14614.24), 281.66, 74.47), new TimeSpan(0, 0, 3), true);
 
				AddGraphics();
			}
		}

		private void AddGraphics()
		{
			Graphic graphic = new Graphic(new MapPoint(-106.981, 39.028, 6000, SpatialReferences.Wgs84));

			// Add a graphic to each graphics layer. It will use the renderer specified in the XAML to render the graphic.
			foreach (GraphicsOverlay gOverlay in MySceneView.GraphicsOverlays)
			{
				gOverlay.Graphics.Add(graphic);
			}
		}

		/// <summary>
		/// Change the Heading of the graphics based on the slider values (0-360).
		/// </summary>
		private void OnHeadingSliderChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			foreach (GraphicsOverlay gOverlay in MySceneView.GraphicsOverlays)
			{
				foreach (Graphic g in gOverlay.Graphics)
				{
					g.Attributes["Heading"] = (sender as Slider).Value;
				}
			}

			// Display the slider Heading value
			txtHeading.Text = String.Format("Heading: {0:0.00}", (sender as Slider).Value.ToString());
		}

		/// <summary>
		/// Change the Pitch of the graphics based on the slider values (0-360)
		/// </summary>
		private void OnPitchSliderChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			foreach (GraphicsOverlay gOverlay in MySceneView.GraphicsOverlays)
			{
				foreach (Graphic g in gOverlay.Graphics)
				{
					g.Attributes["Pitch"] = (sender as Slider).Value;
				}
			}

			// Display the slider Pitch value
			txtPitch.Text = String.Format("Pitch: {0:0.00}", (sender as Slider).Value.ToString());
		}

		/// <summary>
		/// Change the Roll of the graphics based on the slider values (0-360)
		/// </summary>
		private void OnRollSliderChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			foreach (GraphicsOverlay gOverlay in MySceneView.GraphicsOverlays)
			{
				foreach (Graphic g in gOverlay.Graphics)
				{
					g.Attributes["Roll"] = (sender as Slider).Value;
				}
			}

			// Display the slider Roll value
			txtRoll.Text = String.Format("Roll: {0:0.00}", (sender as Slider).Value.ToString());
		}
	}
}
Feedback on this topic?