From 6ec739d45c10c222a134e039d2f28364074129cf Mon Sep 17 00:00:00 2001 From: miks1965 Date: Sun, 17 Jun 2018 17:00:44 +0300 Subject: [PATCH] =?UTF-8?q?Graph3D=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D1=8B=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20(=D0=BA=D0=B0=D0=BC=D0=B5=D1=80=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- .../Key1.pas | 2 +- .../СлучайныйЦвет.pas | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- bin/Lib/Graph3D.pas | 50 +++++++++++++++++-- 6 files changed, 50 insertions(+), 10 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index a1aa77337..5ab853773 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "4"; public const string Build = "0"; - public const string Revision = "1674"; + public const string Revision = "1676"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index dea4e3d96..80fec40ca 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=4 -%REVISION%=1674 +%REVISION%=1676 %COREVERSION%=0 %MAJOR%=3 diff --git a/InstallerSamples/Graph3D/События клавиатуры/Key1.pas b/InstallerSamples/Graph3D/События клавиатуры/Key1.pas index fc2e4b23f..80b195d45 100644 --- a/InstallerSamples/Graph3D/События клавиатуры/Key1.pas +++ b/InstallerSamples/Graph3D/События клавиатуры/Key1.pas @@ -1,4 +1,4 @@ -uses Timers,Graph3D; +uses Graph3D; begin View3D.ShowViewCube := False; diff --git a/InstallerSamples/Graph3D/События мыши/СлучайныйЦвет.pas b/InstallerSamples/Graph3D/События мыши/СлучайныйЦвет.pas index 92a3d40a8..ddce1a505 100644 --- a/InstallerSamples/Graph3D/События мыши/СлучайныйЦвет.pas +++ b/InstallerSamples/Graph3D/События мыши/СлучайныйЦвет.pas @@ -3,7 +3,7 @@ begin var s := Sphere(3,0,1,1); var b := Box(0,2,0.5,3,2,1); - var t := Text3D(-5,0,1,'GraphABC',2); + var t := Text3D(-5,0,1,'Graph3D',2); OnMouseDown += procedure (x,y,mb) -> begin if mb<>1 then exit; var v := FindNearestObject(x,y); diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index f5b4981f5..fb37d0697 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.4.0.1674' +!define VERSION '3.4.0.1676' diff --git a/bin/Lib/Graph3D.pas b/bin/Lib/Graph3D.pas index 7976b5bfc..1ae9abbaa 100644 --- a/bin/Lib/Graph3D.pas +++ b/bin/Lib/Graph3D.pas @@ -40,6 +40,7 @@ type Ray3D = HelixToolkit.Wpf.Ray3D; Line3D = class(Ray3D) end; Plane3D = HelixToolkit.Wpf.Plane3D; + Matrix3D = System.Windows.Media.Media3D.Matrix3D; var hvp: HelixViewport3D; @@ -76,6 +77,9 @@ function operator*(r: real; p: Point3D): Point3D; extensionmethod := p.Multiply( function operator+(p1, p2: Point3D): Point3D; extensionmethod := p3d(p1.X + p2.X, p1.Y + p2.Y, p1.Z + p2.Z); +function operator-(v: Vector3D): Vector3D; extensionmethod := v3d(-v.x,-v.y,-v.z); + + const OrtX = V3D(1, 0, 0); OrtY = V3D(0, 1, 0); @@ -233,11 +237,7 @@ type function Cam: GCamera := hvp.Camera; procedure SetPP(p: Point3D); begin - Cam.Position := p; - //Cam.Ani - {if p<>(0,0,0) then - Cam.LookDirection := Cam.Position.Multiply(-1).ToVector3D - else Cam.LookDirection := V3D(1,0,0);} + Cam.Position := p; end; procedure SetP(p: Point3D) := Invoke(SetPP, p); @@ -256,11 +256,51 @@ type procedure SetD(d: real) := Invoke(SetDP, d); function GetD: real := InvokeReal(()->Cam.Position.DistanceTo(P3D(0, 0, 0))); + procedure MoveOnP(x,y,z: real); + begin + Cam.Position += V3D(x,y,z)//:= P3D(Cam.Position. + end; + procedure MoveOnPV(v: Vector3D); + begin + Cam.Position += v; + end; + procedure AddMoveForceP(x,y,z: real); + begin + hvp.CameraController.ShowCameraTarget := True; + hvp.CameraController.AddMoveForce(x,y,z); + end; + procedure AddRotateForceP(x,y: real); + begin + hvp.CameraController.AddRotateForce(x,y); + end; + procedure RotateP(axis: Vector3D; angle: real); + begin + var look := Cam.LookDirection; + var q := new Quaternion(axis, angle); + var qConjugate := q; + qConjugate.Conjugate(); + + var p := new Quaternion(look.X, look.Y, look.Z, 0); + var qRotatedPoint := q * p * qConjugate; + Cam.LookDirection := V3D(qRotatedPoint.X, qRotatedPoint.Y, qRotatedPoint.Z); + end; + public property Position: Point3D read GetP write SetP; property LookDirection: Vector3D read GetLD write SetLD; property UpDirection: Vector3D read GetUD write SetUD; property Distanse: real read GetD write SetD; + procedure MoveOn(x,y,z: real) := Invoke(MoveOnP,x,y,z); + procedure MoveOn(v: Vector3D) := Invoke(MoveOnPV,v); + procedure AddMoveForce(ForwardForce,RightForce,UpForce: real) := Invoke(AddMoveForceP,RightForce,UpForce,ForwardForce); + procedure AddForwardForce(Force: real := 0.2) := AddMoveForce(Force,0,0); + procedure AddBackwardForce(Force: real := 0.2) := AddMoveForce(-Force,0,0); + procedure AddRightForce(Force: real := 0.2) := AddMoveForce(0,Force,0); + procedure AddLeftForce(Force: real := 0.2) := AddMoveForce(0,-Force,0); + procedure AddUpForce(Force: real := 0.2) := AddMoveForce(0,0,Force); + procedure AddDownForce(Force: real := 0.2) := AddMoveForce(0,0,-Force); + procedure AddRotateForce(RightForce,UpForce: real) := Invoke(AddRotateForceP,RightForce,UpForce); + procedure Rotate(axis: Vector3D; angle: real) := Invoke(RotateP,axis,angle); end; ///!#