Множество примеров Graph3D

This commit is contained in:
miks1965 2017-12-17 01:25:54 +03:00
parent fb75983135
commit 09764ba9d3
43 changed files with 626 additions and 37 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "3";
public const string Build = "0";
public const string Revision = "1596";
public const string Revision = "1597";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=3
%REVISION%=1596
%COREVERSION%=0
%REVISION%=1597
%MINOR%=3
%MAJOR%=3

View file

@ -0,0 +1,10 @@
uses Graph3D;
function ParametricTrajectory(a,b: real; N: integer; fun: real->Point3D) := Partition(a,b,N).Select(fun);
begin
var tr := ParametricTrajectory(0,2*Pi,100,t->P3D(8*cos(t),4*sin(t),0));
Polyline3D(tr);
var b := Sphere(tr.First,1,Colors.Blue);
b.AnimMoveTrajectory(tr.Skip(1),5).Forever.Begin;
end.

View file

@ -0,0 +1,10 @@
uses Graph3D;
begin
var b := Sphere(Origin,1,Colors.Blue);
var (p1,p2,p3,p4) := (P3D(3,0,0),P3D(3,3,0),P3D(0,3,0),P3D(0,0,0));
b.MoveTo(p1);
b.AnimMoveTrajectory(Arr(p2,p3,p4,p1),3).Forever.Begin;
end.

View file

@ -0,0 +1,10 @@
uses Graph3D;
begin
var ss := Cube(0,0,0,1.5,Colors.Red);
var anim := ss.AnimMoveOnX(10).AutoReverse.Forever.AccelerationRatio(0.5,0.5);
//var anim := ss.AnimScale(3).Forever.AutoReverse;
//var anim := ss.AnimRotate(OrtZ,360).Forever.AutoReverse;
//var anim := ss.AnimRotateAt(OrtZ,360,P3D(3,0,0),2).Forever;
anim.Begin;
end.

View file

@ -0,0 +1,11 @@
uses Graph3D;
begin
View3D.ShowGridLines := False;
var disc := Cylinder(0,0,0,0.2,6,Colors.DeepPink);
var r := 5;
foreach var x in Partition(0,2*Pi,12) do
disc.AddChild(Sphere(r*cos(x),r*sin(x),0.2,0.1,Colors.White));
disc.AnimRotate(OrtZ,360,2).AccelerationRatio(1,1).AutoReverse.Forever.Begin;
end.

View file

@ -0,0 +1,7 @@
uses Graph3D;
begin
var ss := Cube(0,0,0,1.5,Colors.Red);
var anim := ss.AnimScale(3).Forever.AutoReverse;
anim.Begin;
end.

View file

@ -0,0 +1,7 @@
uses Graph3D;
begin
var ss := Cube(0,0,0,1.5,Colors.Red);
var anim := ss.AnimRotate(OrtZ,360).Forever.AutoReverse;
anim.Begin;
end.

View file

@ -0,0 +1,8 @@
uses Graph3D;
begin
Cylinder(Origin,6,0.3,Colors.Green);
var ss := Cube(-3,0,0,1.5,Colors.Red);
var anim := ss.AnimRotateAt(OrtZ,360,P3D(3,0,0),2).Forever;
anim.Begin;
end.

View file

@ -0,0 +1,8 @@
uses Graph3D;
begin
var c := Cube(-2,0,0,2,Colors.Beige);
var c1 := Cube(2,0,0,2,Colors.Green);
var a := c.AnimRotate(OrtZ,360,4).Forever * c1.AnimRotate(OrtZ,360,1).Forever;
a.Begin;
end.

View file

@ -0,0 +1,7 @@
uses Graph3D;
begin
var bb := ArrGen(15,i -> Object3D(Box(0.5*i,0,0,0.1,6,2,RandomColor)));
var g := Group(bb).MoveOnX(-5);
g.AnimRotateAt(ortZ,360,P3D(-1,0,0),2).Forever.Begin;
end.

View file

@ -0,0 +1,30 @@
uses Graph3D;
begin
View3D.ShowGridLines := False;
var a := new GroupAnimation;
var p := P3D(9,-3,0);
var sz := 1.3;
var h := 4;
for var n:=3 to 10 do
begin
var pr := Prism(p,n,sz,4,Colors.Beige);
var prw := PrismWireFrame(p,n,sz+0.01,4);
p := p.MoveX(-2*sz-0.3);
a += pr.AnimRotate(OrtZ,360,10).Forever;
a += prw.AnimRotate(OrtZ,360,10).Forever;
end;
p := P3D(9,3,0);
for var n:=3 to 10 do
begin
var pr := Pyramid(p,n,sz,4,Colors.Beige);
var prw := PyramidWireFrame(p,n,sz+0.01,4);
p := p.MoveX(-2*sz-0.3);
a += pr.AnimRotate(OrtZ,360,10).Forever;
a += prw.AnimRotate(OrtZ,360,10).Forever;
end;
a.Begin;
end.

View file

@ -0,0 +1,9 @@
uses Graph3D;
begin
var b := Box(0,0,0,6,1,2,Colors.Blue);
var s := Sphere(0,0,2,1,Colors.Green);
var g := Group(b,s);
g.AnimRotateAt(OrtZ,360,P3D(3,0,0),2).Begin;
end.

View file

@ -0,0 +1,10 @@
uses Graph3D;
begin
var s := Box(0,0,0,3,1,2,Colors.Blue);
var an := Animate.Sequence(
s.AnimMoveOnY(5),
s.AnimMoveOnX(5)
);
an.Begin;
end.

View file

@ -0,0 +1,9 @@
uses Graph3D;
begin
var jmp := 0.3;
var time := 0.5;
var c := Box(0,0,2,1,2,4,Colors.Green);
var a := c.AnimMoveOnZ(-0.4,time).AutoReverse.Forever * c.AnimScaleZ(0.95,time).AutoReverse.Forever * c.AnimMoveOnX(1*10,time*10);
a.Begin;
end.

View file

@ -0,0 +1,20 @@
uses Graph3D;
begin
Window.Title := 'Вращение планет';
View3D.ShowCoordinateSystem := False;
View3D.ShowGridLines := False;
View3D.ShowViewCube := False;
View3D.BackgroundColor := Colors.Black;
var s := Sphere(2,0,0,0.5,Colors.Red);
var ss := Sphere(0,0,0,1,Colors.Blue);
Sphere(0,0,0,2,DiffuseMaterial(Colors.Yellow)+SpecularMaterial(32));
var g := Group(s,ss);
g.MoveOn(-7,0,0);
var anim := s.AnimRotateAt(OrtZ,360*100,P3D(-2,0,0),2*100)
* g.AnimRotateAt(OrtZ,360*100,P3D(7,0,0),10*100)
;
anim.Begin;
end.

View file

@ -0,0 +1,27 @@
uses Graph3D;
begin
Window.Title := 'Платоновы тела';
var РисоватьОписанныеСферы := True;
var p := P3D(8,0,0);
var p1 := p;
var h := -4;
Icosahedron(p,2,Colors.Green);
p.Offset(h,0,0);
Dodecahedron(p,2,Colors.Blue);
p.Offset(h,0,0);
Tetrahedron(p,2,Colors.Red);
p.Offset(h,0,0);
Octahedron(p,2,Colors.Magenta);
p.Offset(h,0,0);
Cube(p,2*2/Sqrt(3),Colors.Brown);
p := p1;
if РисоватьОписанныеСферы then
loop 5 do
begin
var s := Sphere(p,2.0,DiffuseMaterial(Colors.Gold.ChangeAlpha(64))+SpecularMaterial(64));
s.BackMaterial := nil;
p.Offset(h,0,0);
end;
end.

View file

@ -0,0 +1,9 @@
uses Graph3D;
begin
var s := Sphere(Origin,1,Colors.Green);
s.AnimMoveOnX(5).WhenCompleted(procedure->s.AnimMoveOnY(5).Begin).Begin;
var s1 := s.Clone;
s1.Color := Colors.Blue;
s1.AnimMoveOnX(-5).WhenCompleted(procedure->s1.AnimMoveOnY(-5).Begin).Begin;
end.

View file

@ -0,0 +1,13 @@
uses Graph3D;
begin
Window.Title := 'a+b+c - последовательное выполнение, a*b - параллельное выполнение';
var s := Box(0,0,0,3,1,2,Colors.Blue);
var p1 := P3D(5,0,0);
var p2 := P3D(5,5,0);
var OrtZ := V3D(0,0,1);
var an := s.AnimMoveTo(p1,1.Sec)*s.AnimScale(1.5,1.Sec) +
s.AnimMoveTo(p2,1.Sec)*s.AnimScale(1,1.Sec) +
s.AnimRotate(OrtZ,90,1.Sec);
an.Begin;
end.

View file

@ -0,0 +1,8 @@
uses Graph3D;
begin
var t := Text3D(0,-7,1,'Начало анимации...',2);
var s := Box(0,0,0,3,1,2,Colors.Blue);
var an := s.AnimMoveTo(P3D(5,0,0),2).WhenCompleted(procedure -> t.Text := 'Конец!');
an.Begin
end.

View file

@ -0,0 +1,13 @@
uses Graph3D;
begin
var b := Box(0,0,0,3,1,2,Colors.Blue);
var s := Sphere(0,0,2,1,Colors.Green);
var g := Group(b,s);
g.MoveOnY(-4);
var g1 := g.Clone;
g.MoveOnY(3);
var gg := Group(g,g1);
gg.MoveOnX(3);
end.

View file

@ -0,0 +1,16 @@
uses Graph3D;
// ошибка!
begin
var b := Box(0,0,0,3,1,2,Colors.Blue);
var s := Sphere(0,0,2,1,Colors.Green);
var b1 := Box(0,-3,0,3,1,2,Colors.Blue);
var s1 := Sphere(0,-3,2,1,Colors.Green);
var g := Group(b,s);
var g1 := Group(b1,s1);
g.AddChild(g1[0]);// он должен отсоединиться от g!
Sleep(1000);
g.MoveOnX(3);
Sleep(1000);
g1.MoveOnY(4);
end.

View file

@ -0,0 +1,9 @@
// Анимация клона
uses Graph3D;
begin
var b := Box(0,0,1,1,3,2,RandomColor);
var b1 := b.Clone;
b1.MoveOn(3,0,0);
b1.AnimRotate(OrtZ,90).Begin;
end.

View file

@ -0,0 +1,14 @@
uses Graph3D;
begin
var s := Sphere(0,0,0,1,Colors.Red);
var c := Cube(0,0,1.5,1,Colors.Blue);
var p := Pyramid(0,0,0.5,4,0.5,1,Colors.LightGreen);
s.AddChild(c);
c.AddChild(p);
var s1 := s.Clone;
s1.MoveOnX(2);
var g := Group(s,s1);
var g1 := g.Clone;
g.MoveOnY(-4);
end.

View file

@ -0,0 +1,26 @@
uses Graph3D;
function ParametricTrajectory(a,b: real; fun: real->Point3D; N: integer) := Partition(a,b,N).Select(fun);
function ParametricCirve3D(a,b: real; fun: real->Point3D; N: integer := 200): SegmentsT;
begin
var tr := ParametricTrajectory(a,b,fun,N);
Result := Polyline3D(tr);
end;
procedure DuplicateByTrajectory(c: Object3D; a,b: real; fun: real->Point3D; N: integer);
begin
c.MoveTo(fun(a));
foreach var p in Partition(a,b,N).Skip(1).Select(fun) do
begin
var c1 := c.Clone.MoveTo(p);
c1.Rotate(OrtZ,3);
(c1 as BoxT).Color := RandomColor;
c := c1;
end;
end;
begin
var c := Cube(0,0,0,0.7,Colors.Green);
DuplicateByTrajectory(c,0,4*Pi,t->P3D(4*cos(t),4*sin(t),0.5*t),40);
end.

View file

@ -0,0 +1,9 @@
uses Graph3D;
begin
var b := Box(0,0,0,3,1,2,Colors.Blue);
var b1 := b.Clone.RotateAt(OrtZ,90,P3D(1.5,0,0)).MoveOnX(-0.5);
b1 := b.Clone.RotateAt(OrtZ,-90,P3D(-1.5,0,0)).MoveOnX(0.5);
View3D.BackgroundColor := Colors.Black;
View3D.ShowGridLines := False;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

View file

@ -0,0 +1,9 @@
uses Graph3D;
begin
//Sphere(0,0,0,2,Materials.Diffuse(Colors.Green)+Materials.Specular(128));
var m := DiffuseMaterial(Colors.Green) + SpecularMaterial(128,30) + EmissiveMaterial(RGB(0,64,0));
Sphere(4,0,0,2,m);
Cube(8,0,0,4,RainbowMaterial);
Cube(0,0,0,4,DiffuseMaterial(Colors.Green) + ImageMaterial('dog.png',0.5,0.5));
end.

View file

@ -0,0 +1,7 @@
uses Graph3D;
begin
var m := ImageMaterial('Cells1.png',0.2,0.2);
var c := Cube(0,0,2,4,m);
c.Rotate(OrtZ,35)
end.

View file

@ -0,0 +1,14 @@
uses Graph3D;
begin
//Lights.AddDirectionalLight(GrayColor(100),V3D(-1,-1,-1));
var p := P3D(-3,3,3);
Sphere(p,0.3,Colors.White);
View3D.ShowGridLines := false;
Cylinder(0,0,0,5,2,True,Colors.Yellow);
Rectangle3D(0,0,-0.01,15,15,OrtZ,OrtX,ImageMaterial('трава.jpg',0.2,0.2));
Sleep(2000);
Lights.AddPointLight(GrayColor(64),p);
Lights.Proba;
//Rectangle3D(0,0,-0.01,15,15,OrtZ,OrtX,Colors.Green);
end.

View file

@ -0,0 +1,18 @@
uses Graph3D;
begin
var p := PrismWireFrame(Origin,13,3,5);
var pp := p.Points;
foreach var x in pp do
p.AddChild(Sphere(x,0.1,Colors.Gray));
var m := 'A';
foreach var x in pp do
begin
var b := Text3D(x.Move(0.3,0.3,0.4),m,0.5);
p.AddChild(b);
Inc(m);
end;
var p1 := p.Clone;
p1.MoveOnX(-5);
p1.AnimRotate(OrtZ,360,10).Forever.Begin;
end.

View file

@ -0,0 +1,12 @@
uses Graph3D;
begin
View3D.ShowGridLines := False;
View3D.ShowViewCube := False;
View3D.ShowCoordinateSystem := False;
var w := 1;
for var x := -5 to 5 do
for var y := -5 to 5 do
for var z := -4 to 6 do
Cube(x*w,y*w,z*w,w*0.96,RandomColor)
end.

View file

@ -0,0 +1,23 @@
uses Graph3D;
begin
//view3d.ShowCameraInfo := True;
View3D.ShowGridLines := False;
View3D.ShowViewCube := False;
View3D.ShowCoordinateSystem := False;
var l := new List<SphereT>;
//Invoke(()->begin
var w := 1;
for var x := -5 to 5 do
for var y := -5 to 5 do
for var z := -5 to 5 do
l.Add(Sphere(x*w,y*w,z*w,w*0.5,RandomColor));
//end);
foreach var x in l do
x.AnimMoveOn(Random,Random,Random).AutoReverse.Forever.Begin;
//Print(Milliseconds);
end.

View file

@ -0,0 +1,16 @@
uses Timers,Graph3D;
begin
View3D.ShowViewCube := False;
var s := Box(0,0,0,3,1,2,Colors.Blue);
OnKeyDown := k ->
case k of
Key.Left: s.MoveOn(1,0,0);
Key.Right: s.MoveOn(-1,0,0);
Key.Up: s.MoveOn(0,-1,0);
Key.Down: s.MoveOn(0,1,0);
Key.X: s.Rotate(OrtX,10);
Key.Y: s.Rotate(OrtY,10);
Key.Z: s.Rotate(OrtZ,10);
end;
end.

View file

@ -0,0 +1,8 @@
uses Graph3D;
begin
var l := Lego(-4,-1,0 ,8,4,1,Colors.Green);
Lego(-2,0,0.4,4,2,1,Colors.Blue);
Lego(-1,0,0.8,2,1,1,Colors.Red);
Lego(-1,1,0.8,2,1,1,Colors.Yellow);
end.

View file

@ -0,0 +1,6 @@
uses Graph3D;
begin
var p := Pyramid(0,0,0,5,2,5,Colors.Red);
p.AnimRotate(OrtZ,360,5).Begin
end.

View file

@ -0,0 +1,32 @@
uses Graph3D;
function MultipleClones(c: Object3D; N: integer): GroupT;
begin
var g := Group(c);
loop N-1 do
begin
c := c.Clone;
c.MoveOnX(-1.5);
if c is ObjectWithMaterial3D then
(c as ObjectWithMaterial3D).Color := RandomColor;
g.AddChild(c);
end;
Result := g;
end;
begin
var b := Box(0,0,2,14.5,1,4,Colors.Orange);
var c := Cube(6.75,0,4.5,1,RandomColor);
var c1 := Cone(6.75,0,5,1.5,0.4,RandomColor);
var g := MultipleClones(c,10);
var gp := MultipleClones(c1,10);
var gg := Group(g,b,gp);
var g1 := gg.Clone.MoveOnY(6);
var g2 := gg.Clone.MoveOnY(-6);
gg.Rotate(OrtZ,90);
var g3 := gg.Clone.MoveOnX(-6);
gg.MoveOnX(6);
var ggg := Group(gg,g1,g2,g3);
ggg.Save('Замок.xaml');
//ggg.AnimRotate(OrtZ,360,10).Forever.begin;
end.

View file

@ -1 +1 @@
!define VERSION '3.3.0.1596'
!define VERSION '3.3.0.1597'

View file

@ -442,6 +442,11 @@ type
end;
public
constructor(model: Visual3D);
begin
CreateBase0(model, 0, 0, 0);
end;
property X: real read GetX write SetX;
property Y: real read GetY write SetY;
property Z: real read GetZ write SetZ;
@ -540,6 +545,18 @@ type
function AnimRotate(v: Vector3D; angle: real; seconds: real := 1) := AnimRotate(v.x, v.y, v.z, angle, seconds);
function AnimRotateAt(axis: Vector3D; angle: real; center: Point3D; seconds: real := 1): MyAnimation;
function Clone: Object3D := Invoke&<Object3D>(CloneT);
procedure SaveP(fname: string);
begin
var f := new System.IO.StreamWriter(fname);
XamlWriter.Save(Model,f);
f.Close()
end;
procedure Save(fname: string); virtual := Invoke(SaveP,fname); // надо её сделать виртуальной!
class function Load(fname: string): Object3D := Invoke&<Object3D>(()->begin
var m := XamlReader.Load(new System.IO.FileStream(fname,System.IO.FileMode.Open)) as Visual3D;
Result := new Object3D(m);
end);
end;
ObjectWithChildren3D = class(Object3D) // model is ModelVisual3D
@ -1247,6 +1264,11 @@ type
protected
function CreateObject: Object3D; override := new SphereT(X, Y, Z, Radius, Material.Clone);
public
constructor();
begin
CreateBase(NewVisualObject(1), 0, 0, 0, Colors.Blue);
end;
constructor(x, y, z, r: real; m: Gmaterial);
begin
CreateBase(NewVisualObject(r), x, y, z, m);
@ -1423,6 +1445,26 @@ type
function Clone := (inherited Clone) as TruncatedConeT;
end;
CylinderT = class(TruncatedConeT)
private
procedure SetR(r: real);
begin
BaseRadius := r;
TopRadius := r;
end;
function GetR: real := Radius;
protected
function CreateObject: Object3D; override := new CylinderT(X, Y, Z, Height, Radius, (model as TruncatedConeVisual3D).ThetaDiv - 1, Topcap, Material.Clone);
public
constructor(x, y, z, h, r: real; ThetaDiv: integer; topcap: boolean; m: GMaterial);
begin
var a := NewVisualObject(h, r, r, ThetaDiv, topcap);
CreateBase(a, x, y, z, m);
end;
function Clone := (inherited Clone) as CylinderT;
property Radius: real read GetR write SetR;
end;
TeapotT = class(ObjectWithMaterial3D)
private
procedure SetVP(v: boolean) := (model as MeshElement3D).Visible := v;
@ -2349,13 +2391,17 @@ function TruncatedConeAux(x, y, z, height, baseradius, topradius: real; sides: i
const maxsides = 37;
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material) := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
///--
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material): TruncatedConeT := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
function TruncatedCone(x, y, z, height, baseradius, topradius: real; c: Material) := TruncatedCone(x, y, z, height, baseradius, topradius, True, c);
///--
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; topcap: boolean; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, topcap, c);
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, True, c);
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material): TruncatedConeT := TruncatedCone(x, y, z, height, radius, radius, topcap, c);
///--
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material): CylinderT := Invoke&<CylinderT>(()->CylinderT.Create(x, y, z, height, radius, maxsides, topcap, c));
function Cylinder(x, y, z, height, radius: real; c: Material) := Cylinder(x, y, z, height, radius, True, c);
///--
function Cylinder(p: Point3D; height, radius: real; topcap: boolean; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, topcap, c);
function Cylinder(p: Point3D; height, radius: real; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, True, c);
@ -2368,10 +2414,8 @@ function Cone(p: Point3D; height, radius: real; c: Material) := TruncatedCone(p.
function Teapot(x, y, z: real; c: Material): TeapotT := Invoke&<TeapotT>(()->TeapotT.Create(x, y, z, c));
function Teapot(p: Point3D; c: Material) := Teapot(p.x, p.y, p.z, c);
function BillboardText(x, y, z: real; text: string; fontsize: real): BillboardTextT := Invoke&<BillboardTextT>(()->BillboardTextT.Create(x, y, z, text, fontsize));
function BillboardText(p: Point3D; text: string; fontsize: real) := BillboardText(P.x, p.y, p.z, text, fontsize);
function BillboardText(x, y, z: real; text: string) := BillboardText(x, y, z, text, 12);
function BillboardText(p: Point3D; text: string) := BillboardText(P.x, p.y, p.z, text, 12);
function BillboardText(x, y, z: real; text: string; fontsize: real := 12): BillboardTextT := Invoke&<BillboardTextT>(()->BillboardTextT.Create(x, y, z, text, fontsize));
function BillboardText(p: Point3D; text: string; fontsize: real := 12) := BillboardText(P.x, p.y, p.z, text, fontsize);
function CoordinateSystem(arrowslength, diameter: real): CoordinateSystemT := Invoke&<CoordinateSystemT>(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
function CoordinateSystem(arrowslength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
@ -2385,10 +2429,10 @@ function Text3D(p: Point3D; text: string; height: real) := Text3D(p.x, p.y, p.z,
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material) := Invoke&<RectangleT>(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c));
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c);
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material) := Rectangle3D(x, y, z, l, w, normal, v3d(1, 0, 0), c);
function Rectangle3D(x, y, z, l, w: real; c: Material) := Rectangle3D(x, y, z, l, w, v3d(0, 0, 1), v3d(1, 0, 0), c);
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, v3d(1, 0, 0), c);
function Rectangle3D(p: Point3D; l, w: real; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, v3d(0, 0, 1), v3d(1, 0, 0), c);
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material) := Rectangle3D(x, y, z, l, w, normal, OrtX, c);
function Rectangle3D(x, y, z, l, w: real; c: Material) := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c);
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c);
function Rectangle3D(p: Point3D; l, w: real; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c);
/// Загружает модель из файла .obj, .3ds, .lwo, .objz, .stl, .off
function FileModel3D(x, y, z: real; fname: string) := Invoke&<FileModelT>(()->FileModelT.Create(x, y, z, fname));
@ -2437,12 +2481,12 @@ begin
//var m := MaterialHelper.CreateMaterial(Brushes.Green,100,100);
//m.AmbientColor := Colors.Red;
//m.Color := Colors.Green;
var bi := new System.Windows.Media.Imaging.BitmapImage(new System.Uri('dog.png',System.UriKind.Relative));
var b := new ImageBrush(bi);
//var bi := new System.Windows.Media.Imaging.BitmapImage(new System.Uri('dog.png',System.UriKind.Relative));
//var b := new ImageBrush(bi);
//b.ViewportUnits := BrushMappingMode.Absolute;
b.Viewport := Rect(0,0,0.2,0.3);
b.TileMode := System.Windows.Media.TileMode.Tile;
Cube(6,-4,0,4,MaterialHelper.CreateMaterial(b));
//b.Viewport := Rect(0,0,0.2,0.3);
//b.TileMode := System.Windows.Media.TileMode.Tile;
//Cube(6,-4,0,4,MaterialHelper.CreateMaterial(b));
Sphere(2,-4,0,2,MaterialHelper.CreateMaterial(Brushes.Green,0.4,100,255));
Sphere(-2,-4,0,2,MaterialHelper.CreateMaterial(Brushes.Green,0.6,100,255));
Sphere(-6,-4,0,2,MaterialHelper.CreateMaterial(Brushes.Green,0.8,100,0));
@ -2460,6 +2504,27 @@ begin
end;
procedure Proba := Invoke(ProbaP);
procedure ProbaP2;
begin
//var c := new CubeVisual3D();
//var c := new IcosahedronVisual3D();
//c.Length := 1;
//c.Material := Colors.Green;
//hvp.Children.Add(c);
//var ex := new HelixToolkit.Wpf.XamlExporter();
//ex.Export(c,new System.IO.FileStream('cube.xaml',System.IO.FileMode.Create));
//XamlWriter.Save(c,new System.IO.StreamWriter('www1.xaml'));
var c1 := XamlReader.Load(new System.IO.FileStream('cube.xaml',System.IO.FileMode.Open)) as CubeVisual3D;
hvp.Children.Add(c1);
{var imp := new HelixToolkit.Wpf.ModelImporter();
imp.Load('a.xaml',nil,False);}
end;
procedure Proba2 := Invoke(ProbaP2);
procedure WindowTypeSetLeftP(l: real) := MainWindow.Left := l;
procedure WindowType.SetLeft(l: real) := Invoke(WindowTypeSetLeftP, l);

View file

@ -123,14 +123,19 @@ namespace VisualPascalABC
string[] delimer = new string[1];
delimer[0] = Environment.NewLine;
string[] StackItemsData = StackTraceData.Split(delimer, StringSplitOptions.RemoveEmptyEntries);
foreach (string StackItemData in StackItemsData)
try
{
StackTraceItem StackTraceItem = new StackTraceItem();
foreach (string StackItemData in StackItemsData)
{
StackTraceItem StackTraceItem = new StackTraceItem();
string str = StackItemData.TrimStart(' ');
int beg = str.IndexOf(' ');
int end = str.IndexOf(") ");
if (end == -1)
end = str.IndexOf(")");
if (end == -1)
end = str.Length-1;
StackTraceItem.FunctionName = str.Substring(beg + 1, end - beg);
if (end + 1 < str.Length)
{
@ -156,6 +161,15 @@ namespace VisualPascalABC
}
StackTrace.Add(StackTraceItem);
}
}
catch (Exception e)
{
StackTraceItem StackTraceItem = new StackTraceItem();
StackTraceItem.FunctionName = "Исключение при формировании стека исключений. Проверьте код RunManager.cs";
StackTrace.Add(StackTraceItem);
//e = e;
}
RunnerManagerUnhanledRuntimeException(id, ExceptionType, ExceptionMessage, StackTraceData, StackTrace);
waitSpecialMessageText = "";
return true;

View file

@ -442,6 +442,11 @@ type
end;
public
constructor(model: Visual3D);
begin
CreateBase0(model, 0, 0, 0);
end;
property X: real read GetX write SetX;
property Y: real read GetY write SetY;
property Z: real read GetZ write SetZ;
@ -540,6 +545,18 @@ type
function AnimRotate(v: Vector3D; angle: real; seconds: real := 1) := AnimRotate(v.x, v.y, v.z, angle, seconds);
function AnimRotateAt(axis: Vector3D; angle: real; center: Point3D; seconds: real := 1): MyAnimation;
function Clone: Object3D := Invoke&<Object3D>(CloneT);
procedure SaveP(fname: string);
begin
var f := new System.IO.StreamWriter(fname);
XamlWriter.Save(Model,f);
f.Close()
end;
procedure Save(fname: string); virtual := Invoke(SaveP,fname); // надо её сделать виртуальной!
class function Load(fname: string): Object3D := Invoke&<Object3D>(()->begin
var m := XamlReader.Load(new System.IO.FileStream(fname,System.IO.FileMode.Open)) as Visual3D;
Result := new Object3D(m);
end);
end;
ObjectWithChildren3D = class(Object3D) // model is ModelVisual3D
@ -1079,7 +1096,7 @@ type
var el: Object3D := Element;
sb.Completed += (o, e) -> begin
rottransform.Rotation := new AxisAngleRotation3D();
el.RotateAt(rot.Axis, angle, center); // переходит в основную матрицу
el.RotateAt(rot.Axis, angle, center); // переходит в основную матрицу. Проблема - оно должно переходить не после всей анимации, а после данной. Потому и ошибка!!!
end;
da := AddDoubleAnimByName(sb, angle, seconds, ttname, AxisAngleRotation3D.AngleProperty, wait);
@ -1247,6 +1264,11 @@ type
protected
function CreateObject: Object3D; override := new SphereT(X, Y, Z, Radius, Material.Clone);
public
constructor();
begin
CreateBase(NewVisualObject(1), 0, 0, 0, Colors.Blue);
end;
constructor(x, y, z, r: real; m: Gmaterial);
begin
CreateBase(NewVisualObject(r), x, y, z, m);
@ -1423,6 +1445,26 @@ type
function Clone := (inherited Clone) as TruncatedConeT;
end;
CylinderT = class(TruncatedConeT)
private
procedure SetR(r: real);
begin
BaseRadius := r;
TopRadius := r;
end;
function GetR: real := Radius;
protected
function CreateObject: Object3D; override := new CylinderT(X, Y, Z, Height, Radius, (model as TruncatedConeVisual3D).ThetaDiv - 1, Topcap, Material.Clone);
public
constructor(x, y, z, h, r: real; ThetaDiv: integer; topcap: boolean; m: GMaterial);
begin
var a := NewVisualObject(h, r, r, ThetaDiv, topcap);
CreateBase(a, x, y, z, m);
end;
function Clone := (inherited Clone) as CylinderT;
property Radius: real read GetR write SetR;
end;
TeapotT = class(ObjectWithMaterial3D)
private
procedure SetVP(v: boolean) := (model as MeshElement3D).Visible := v;
@ -2349,13 +2391,17 @@ function TruncatedConeAux(x, y, z, height, baseradius, topradius: real; sides: i
const maxsides = 37;
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material) := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
///--
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material): TruncatedConeT := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
function TruncatedCone(x, y, z, height, baseradius, topradius: real; c: Material) := TruncatedCone(x, y, z, height, baseradius, topradius, True, c);
///--
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; topcap: boolean; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, topcap, c);
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, True, c);
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material): TruncatedConeT := TruncatedCone(x, y, z, height, radius, radius, topcap, c);
///--
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material): CylinderT := Invoke&<CylinderT>(()->CylinderT.Create(x, y, z, height, radius, maxsides, topcap, c));
function Cylinder(x, y, z, height, radius: real; c: Material) := Cylinder(x, y, z, height, radius, True, c);
///--
function Cylinder(p: Point3D; height, radius: real; topcap: boolean; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, topcap, c);
function Cylinder(p: Point3D; height, radius: real; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, True, c);
@ -2368,10 +2414,8 @@ function Cone(p: Point3D; height, radius: real; c: Material) := TruncatedCone(p.
function Teapot(x, y, z: real; c: Material): TeapotT := Invoke&<TeapotT>(()->TeapotT.Create(x, y, z, c));
function Teapot(p: Point3D; c: Material) := Teapot(p.x, p.y, p.z, c);
function BillboardText(x, y, z: real; text: string; fontsize: real): BillboardTextT := Invoke&<BillboardTextT>(()->BillboardTextT.Create(x, y, z, text, fontsize));
function BillboardText(p: Point3D; text: string; fontsize: real) := BillboardText(P.x, p.y, p.z, text, fontsize);
function BillboardText(x, y, z: real; text: string) := BillboardText(x, y, z, text, 12);
function BillboardText(p: Point3D; text: string) := BillboardText(P.x, p.y, p.z, text, 12);
function BillboardText(x, y, z: real; text: string; fontsize: real := 12): BillboardTextT := Invoke&<BillboardTextT>(()->BillboardTextT.Create(x, y, z, text, fontsize));
function BillboardText(p: Point3D; text: string; fontsize: real := 12) := BillboardText(P.x, p.y, p.z, text, fontsize);
function CoordinateSystem(arrowslength, diameter: real): CoordinateSystemT := Invoke&<CoordinateSystemT>(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
function CoordinateSystem(arrowslength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
@ -2385,10 +2429,10 @@ function Text3D(p: Point3D; text: string; height: real) := Text3D(p.x, p.y, p.z,
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material) := Invoke&<RectangleT>(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c));
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c);
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material) := Rectangle3D(x, y, z, l, w, normal, v3d(1, 0, 0), c);
function Rectangle3D(x, y, z, l, w: real; c: Material) := Rectangle3D(x, y, z, l, w, v3d(0, 0, 1), v3d(1, 0, 0), c);
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, v3d(1, 0, 0), c);
function Rectangle3D(p: Point3D; l, w: real; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, v3d(0, 0, 1), v3d(1, 0, 0), c);
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material) := Rectangle3D(x, y, z, l, w, normal, OrtX, c);
function Rectangle3D(x, y, z, l, w: real; c: Material) := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c);
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c);
function Rectangle3D(p: Point3D; l, w: real; c: Material) := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c);
/// Загружает модель из файла .obj, .3ds, .lwo, .objz, .stl, .off
function FileModel3D(x, y, z: real; fname: string) := Invoke&<FileModelT>(()->FileModelT.Create(x, y, z, fname));
@ -2437,12 +2481,12 @@ begin
//var m := MaterialHelper.CreateMaterial(Brushes.Green,100,100);
//m.AmbientColor := Colors.Red;
//m.Color := Colors.Green;
var bi := new System.Windows.Media.Imaging.BitmapImage(new System.Uri('dog.png',System.UriKind.Relative));
var b := new ImageBrush(bi);
//var bi := new System.Windows.Media.Imaging.BitmapImage(new System.Uri('dog.png',System.UriKind.Relative));
//var b := new ImageBrush(bi);
//b.ViewportUnits := BrushMappingMode.Absolute;
b.Viewport := Rect(0,0,0.2,0.3);
b.TileMode := System.Windows.Media.TileMode.Tile;
Cube(6,-4,0,4,MaterialHelper.CreateMaterial(b));
//b.Viewport := Rect(0,0,0.2,0.3);
//b.TileMode := System.Windows.Media.TileMode.Tile;
//Cube(6,-4,0,4,MaterialHelper.CreateMaterial(b));
Sphere(2,-4,0,2,MaterialHelper.CreateMaterial(Brushes.Green,0.4,100,255));
Sphere(-2,-4,0,2,MaterialHelper.CreateMaterial(Brushes.Green,0.6,100,255));
Sphere(-6,-4,0,2,MaterialHelper.CreateMaterial(Brushes.Green,0.8,100,0));
@ -2460,6 +2504,27 @@ begin
end;
procedure Proba := Invoke(ProbaP);
procedure ProbaP2;
begin
//var c := new CubeVisual3D();
//var c := new IcosahedronVisual3D();
//c.Length := 1;
//c.Material := Colors.Green;
//hvp.Children.Add(c);
//var ex := new HelixToolkit.Wpf.XamlExporter();
//ex.Export(c,new System.IO.FileStream('cube.xaml',System.IO.FileMode.Create));
//XamlWriter.Save(c,new System.IO.StreamWriter('www1.xaml'));
var c1 := XamlReader.Load(new System.IO.FileStream('cube.xaml',System.IO.FileMode.Open)) as CubeVisual3D;
hvp.Children.Add(c1);
{var imp := new HelixToolkit.Wpf.ModelImporter();
imp.Load('a.xaml',nil,False);}
end;
procedure Proba2 := Invoke(ProbaP2);
procedure WindowTypeSetLeftP(l: real) := MainWindow.Left := l;
procedure WindowType.SetLeft(l: real) := Invoke(WindowTypeSetLeftP, l);

Binary file not shown.