Skip to content

Commit

Permalink
Add coordinate system and viewcube into ViewportCore
Browse files Browse the repository at this point in the history
  • Loading branch information
holance committed Dec 28, 2018
1 parent ace5fce commit 26b9efb
Show file tree
Hide file tree
Showing 4 changed files with 481 additions and 273 deletions.
6 changes: 4 additions & 2 deletions Source/Examples/SharpDX.Core/CoreTest/CoreTestApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public CoreTestApp(Form window)
viewport.StartRendering += Viewport_OnStartRendering;
viewport.StopRendering += Viewport_OnStopRendering;
viewport.ErrorOccurred += Viewport_OnErrorOccurred;
viewport.CoordinateSystemLabelColor = new Color4(1, 1, 0, 1);
options.Viewport = viewport;
AssignViewportOption();
InitializeScene();
Expand Down Expand Up @@ -170,8 +171,6 @@ private void InitializeScene()
groupSphere.AddChildNode(groupPoints);
groupSphere.AddChildNode(groupLines);

var viewbox = new ViewBoxNode();
viewport.Items.AddChildNode(viewbox);
var imGui = new ImGuiNode();
viewport.Items.AddChildNode(imGui);
imGui.UpdatingImGuiUI += ImGui_UpdatingImGuiUI;
Expand Down Expand Up @@ -318,6 +317,7 @@ private void Window_MouseMove(object sender, MouseEventArgs e)
else if (!io.WantCaptureMouse)
{
cameraController.MouseMove(new Vector2(e.X, e.Y));
viewport.MouseMove(new Vector2(e.X, e.Y));
}
}

Expand All @@ -341,6 +341,7 @@ private void Window_MouseUp(object sender, MouseEventArgs e)
switch (e.Button)
{
case MouseButtons.Left:
viewport.MouseUp(new Vector2(e.X, e.Y));
break;
case MouseButtons.Right:
cameraController.EndRotate(new Vector2(e.X, e.Y));
Expand Down Expand Up @@ -374,6 +375,7 @@ private void Window_MouseDown(object sender, MouseEventArgs e)
switch (e.Button)
{
case MouseButtons.Left:
viewport.MouseDown(new Vector2(e.X, e.Y));
break;
case MouseButtons.Right:
cameraController.StartRotate(new Vector2(e.X, e.Y));
Expand Down
14 changes: 13 additions & 1 deletion Source/HelixToolkit.SharpDX.Core/Controls/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,22 @@ public sealed class CameraController
/// <value> The minimum field of view. </value>
public float MinimumFieldOfView = 10.0f;

private Vector3 modelUpDirection = Vector3.UnitY;
/// <summary>
/// Gets or sets the model up direction.
/// </summary>
public Vector3 ModelUpDirection = new Vector3(0, 1, 0);
public Vector3 ModelUpDirection
{
set
{
modelUpDirection = value;
if (Viewport != null)
{
Viewport.ModelUpDirection = value;
}
}
get => modelUpDirection;
}

/// <summary>
/// Gets or sets the move sensitivity.
Expand Down
Loading

0 comments on commit 26b9efb

Please sign in to comment.