Skip to content

Commit 1952e37

Browse files
authored
Merge pull request #34 from ABTSoftware/SciChart_v8_Dev
Merged recent fixed from the v8 Dev branch
2 parents e136a3a + f7e4d35 commit 1952e37

2 files changed

Lines changed: 9 additions & 18 deletions

File tree

Sandbox/CustomerExamples/3DScatterChart_DragPointModifier/DragPointYAxisModifier3D.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,28 @@ private Vector3 GetCoordVector(Vector3D pointVector)
5050

5151
private double GetYDrag(Point endPoint, Vector3 coordVector)
5252
{
53-
// 1.Create a plane at the highlighted point using its position and camera forward vector
54-
// 2.Calculate a ray using the camera and mouse x,y position
55-
// 3.Intersect the ray with the plane giving a point in world space
56-
57-
// Repeat 1,2,3 using the start point and actual mouse point
58-
// Calculate the Y delta using 2 positions in world space
59-
6053
if (Viewport3D == null || coordVector == null) return double.NaN;
6154

55+
// Project 3D point to screen, cast a ray through that screen pixel,
56+
// find where the ray intersects a plane perpendicular to the camera
57+
// passing through the original 3D point, and return the Y of that intersection.
6258
var camera = Viewport3D.GetWorld().GetMainCamera();
63-
var pointPlane = new TSRPlane(camera.m_Fwd, coordVector);
64-
6559
var rayStart = new TSRVector3();
6660
var rayDirection = new TSRVector3();
6761
var rayEnd = new TSRVector3();
68-
6962
var viewport = new TSRViewPort
7063
{
7164
Width = Convert.ToUInt32(Viewport3D.ViewportSize.Width),
7265
Height = Convert.ToUInt32(Viewport3D.ViewportSize.Height)
7366
};
7467

75-
int iScreenX = 0;
76-
int iScreenY = 0;
77-
float fDepth = 0.0f;
78-
camera.TransformIntoScreenCoords(viewport, coordVector, out iScreenX, out iScreenY, out fDepth);
79-
camera.ComputeRay(viewport, (int)iScreenX, (int)endPoint.Y, rayStart, rayDirection);
68+
camera.TransformIntoScreenCoords(viewport, coordVector, out var screenX, out var screenY, out var depth);
69+
camera.ComputeRay(viewport, (int)screenX, (int)endPoint.Y, rayStart, rayDirection);
8070
rayEnd.x = rayStart.x + rayDirection.x;
8171
rayEnd.y = rayStart.y + rayDirection.y;
8272
rayEnd.z = rayStart.z + rayDirection.z;
8373

74+
var pointPlane = new TSRPlane(camera.m_Fwd, coordVector);
8475
var endVector = pointPlane.Split(rayStart, rayEnd);
8576
return endVector.y;
8677
}

Sandbox/CustomerExamples/3DScatterChart_DragPointModifier/MainWindow.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
<s3D:ModifierGroup3D>
5858
<s3D:MouseWheelZoomModifier3D />
5959
<s3D:OrbitModifier3D ExecuteOn="MouseRightButton" />
60-
<local:TestWorldScreenCoordModifier3D/>
61-
<local:DragPointYAxisModifier3D PointDragStart="OnPointDragStart"
60+
<local:DragPointYAxisModifier3D ExecuteWhen="Ctrl"
61+
PointDragStart="OnPointDragStart"
6262
PointDragDelta="OnPointDragDelta"
6363
PointDragEnd="OnPointDragEnd"/>
6464

@@ -75,7 +75,7 @@
7575

7676
<TextBlock Foreground="Gray"
7777
Margin="0,5"
78-
Text="SHIFT+LMB to test world-screen coords transformation (see Output in Debug mode)"/>
78+
Text="RMB+Drag to rotate the chart around"/>
7979
</StackPanel>
8080

8181
<TextBlock x:Name="pointInfo"

0 commit comments

Comments
 (0)