Hello I am starting my journey in the world of GLScene…
I’m using Delphi Rio (10.3.1) and GLScene 1.8.
First I built my own mouse control: zoom and pan, like in AutoCad.
Second I build some routines to draw parts of railpipes for a rollercoaster.
Now I’trying to zoom the whole scene (all visible pipes).
First I tried to get the BoundingBox of several pipes (TGLPipes). But these are stuck at -0.5,-0.5,-0.5 to 0.5.0.5.0.5. Is this not implemented yet?
After that I created a MeshObjects on a GLFreeForm with GLFeedback1.BuildMeshFromBuffer. This will give rouphly x,y, and z coordinates for the bounding boxes.
Now again I’m challenged on how to convert these world coordinates to, projected, view coordinates, not screen!
Bear with me… It’s my first GLScene project.
Kind regards,
DaSteelMan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi for fit scene after GLCamera1.ZoomAll(GLSceneViewer1.Buffer);
you must add GLCamera1.TransformationChanged; far validating the changes
Cheers
EDIT : You can also try : GLCamera.DepthOfView:=2*DCRootWorld.BoundingSphereRadiusUnscaled
Where DCRootWorld is the DummyCube wich is contains all your objets
Last edit: Jerome.D (BeanzMaster) 2019-06-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Jerome.D: ZoomAll zooms out way to much, that is why I was trying to get the size in projection of the view and then adjustdistancetotarget accordingly. I still have to find out how...
@shine world: Thanks for the example of pan. I saw a lot of weird solutions... I have my camera targeted to a DummyCube. Left mousebutton for orbit, right mousbutton for pan. This makes my pan very simple:
PanRatio := 0.128*Camera.DistanceToTarget/Camera.FocalLength;
...
// Berekenen afstand naar vorige punt
dx := mdx - x;
dy := mdy - y;
mdx := x;
mdy := y;
if (ssRight in Shift) then
begin
// Pan
Camera.MoveInEyeSpace(0,-PanRatio*dx,PanRatio*dy);
Camera.MoveTargetInEyeSpace(0,PanRatio*dx,-PanRatio*dy);
end;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes but like i could see BoundingBoxes in DummyCube are not updated when you move a child object. I'll see more deeply where the update of those are made in the GLscene's code
PS: a odd hourglass appears after zoom to fit. I think is cause by the transformationchanged function and should depend of the complexity of the scene
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
My UI start to get shape... I used the bendingcyl demo as a starting point.
Very satisfied the way pan, zoom, dolly-zoom and orbit worked out. Pan thanks to shine world!
I'll start on the zoom to fit now.
This UI demo nicely shows how the camera frustum is shaped. See the second form for this.
What I miss out on:
1) When I start the program the near plane does not fit the sceneviewer. Do I always need to set the cameras SceneScale for this? Or don't I understand the basics?
2) Is there a rule of thumb for a model in meters and camera distance and focal distance? In the UI demo you'll see model can't be set to full screen (without scenescale that is). You can change SceneScale by holding the ALT-key when zooming. Setting SceneScale to 0.12 will show the near plane of the frustum...
3) How can I let a cadencer continue to work when a second form is opened?
4) Is the near plane always connected to focal distance, or can it be set seperately?
The source for my UI demo is attached.
What do you tink about the camera actions?
I solved boundingbox for TGLPipe on a basic level: For every node check for max and min, take radius into account. This whil give you a boundingbox that can be off by +radius
The code to implement in TGLPipe is attached.
functionTGLPipe.AxisAlignedDimensionsUnscaled: TVector;//******************************************************varcount: Integer;locRadius: Single;dMin,dMax: TAffineVector;begin// JJH 12/07/2019// Estimate of GLPipe BoundingBox// Check dimensions for every node and radiuslocRadius:=Radius*TGLPipeNode(Nodes[0]).RadiusFactor;dMin.X:=nodes[0].X-locRadius;dMin.Y:=nodes[0].Y-locRadius;dMin.Z:=nodes[0].Z-locRadius;dMax.X:=nodes[0].X+locRadius;dMax.Y:=nodes[0].Y+locRadius;dMax.Z:=nodes[0].Z+locRadius;forcount:=1tonodes.Count-1dobeginlocRadius:=Radius*TGLPipeNode(Nodes[count]).RadiusFactor;dMin.X:=Min(dMin.X,nodes[count].X-locRadius);dMin.Y:=Min(dMin.Y,nodes[count].Y-locRadius);dMin.Z:=Min(dMin.Z,nodes[count].Z-locRadius);dMax.X:=Max(dMax.X,nodes[count].X+locRadius);dMax.Y:=Max(dMax.Y,nodes[count].Y+locRadius);dMax.Z:=Max(dMax.Z,nodes[count].Z+locRadius);end;Result.X:=(dMax.X-dMin.X)*0.5;Result.Y:=(dMax.Y-dMin.Y)*0.5;Result.Z:=(dMax.Z-dMin.Z)*0.5;Result.W:=0;// AxisAlignedDimensionsUnscaledend;functionTGLPipe.BarycenterAbsolutePosition: TVector;//***************************************************varcount: Integer;locRadius: Single;dMin,dMax: TAffineVector;begin// JJH 12/07/2019// Estimate of GLPipe BarycenterAbsolutePosition// Check dimensions for every node and radiuslocRadius:=Radius*TGLPipeNode(Nodes[0]).RadiusFactor;dMin.X:=nodes[0].X-locRadius;dMin.Y:=nodes[0].Y-locRadius;dMin.Z:=nodes[0].Z-locRadius;dMax.X:=nodes[0].X+locRadius;dMax.Y:=nodes[0].Y+locRadius;dMax.Z:=nodes[0].Z+locRadius;forcount:=1tonodes.Count-1dobeginlocRadius:=Radius*TGLPipeNode(Nodes[count]).RadiusFactor;dMin.X:=Min(dMin.X,nodes[count].X-locRadius);dMin.Y:=Min(dMin.Y,nodes[count].Y-locRadius);dMin.Z:=Min(dMin.Z,nodes[count].Z-locRadius);dMax.X:=Max(dMax.X,nodes[count].X+locRadius);dMax.Y:=Max(dMax.Y,nodes[count].Y+locRadius);dMax.Z:=Max(dMax.Z,nodes[count].Z+locRadius);end;Result.X:=(dMax.X+dMin.X)*0.5;Result.Y:=(dMax.Y+dMin.Y)*0.5;Result.Z:=(dMax.Z+dMin.Z)*0.5;Result.W:=0;// BarycenterAbsolutePositionend;functionTGLPipe.BoundingBox(constAIncludeChilden: Boolean;constAUseBaryCenter: Boolean):THmgBoundingBox;varCurrentBaryOffset: TVector;//**********************************************************begin// JJH 12/07/2019Result:=AABBToBB(AxisAlignedBoundingBox(AIncludeChilden));// DaStr: code not tested...ifAUseBaryCenterthenbeginCurrentBaryOffset:=VectorAdd(AbsoluteToLocal(BarycenterAbsolutePosition),Position.AsVector);OffsetBBPoint(Result,CurrentBaryOffset);end;// BoundingBoxend;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello I am starting my journey in the world of GLScene…
I’m using Delphi Rio (10.3.1) and GLScene 1.8.
First I built my own mouse control: zoom and pan, like in AutoCad.
Second I build some routines to draw parts of railpipes for a rollercoaster.
Now I’trying to zoom the whole scene (all visible pipes).
First I tried to get the BoundingBox of several pipes (TGLPipes). But these are stuck at -0.5,-0.5,-0.5 to 0.5.0.5.0.5. Is this not implemented yet?
After that I created a MeshObjects on a GLFreeForm with GLFeedback1.BuildMeshFromBuffer. This will give rouphly x,y, and z coordinates for the bounding boxes.
Now again I’m challenged on how to convert these world coordinates to, projected, view coordinates, not screen!
Bear with me… It’s my first GLScene project.
Kind regards,
DaSteelMan
For panning the solution is move camera and target dummy box contemporaneously.
I do that using right key pressed:
Like in attached video.
For Zoom to FIT I was unable to get a valid solution at yet.
Last edit: shine world 2019-06-19
Hi to fit you all scene on screen you can try GLCamera1.ZoomAll(GLSceneViewer1.Buffer); but not sure it is working properly
Cheers
Hi for fit scene after
GLCamera1.ZoomAll(GLSceneViewer1.Buffer);
you must add
GLCamera1.TransformationChanged;
far validating the changesCheers
EDIT : You can also try :
GLCamera.DepthOfView:=2*DCRootWorld.BoundingSphereRadiusUnscaled
Where DCRootWorld is the DummyCube wich is contains all your objets
Last edit: Jerome.D (BeanzMaster) 2019-06-19
Jerome there is a fast/simple way to get a DummyCube containing all scene visibible objects ?
What do you mean by "get" ? Copy or retreive all visible object in the DummyCube ?
@Jerome.D: ZoomAll zooms out way to much, that is why I was trying to get the size in projection of the view and then adjustdistancetotarget accordingly. I still have to find out how...
@shine world: Thanks for the example of pan. I saw a lot of weird solutions... I have my camera targeted to a DummyCube. Left mousebutton for orbit, right mousbutton for pan. This makes my pan very simple:
@Jack for fit try this :
i've modified ZoomAll function a little bit, it seems to work well enought
Now for pan, i understand what you searched to do :P
Last edit: Jerome.D (BeanzMaster) 2019-06-20
Super!
Tried the Jerome.D solution :)
I need extra work but seem to be the right way !
Thanks a lot
PS: a odd hourglass appears after zoom to fit.
What mean ?
Last edit: shine world 2019-06-20
Yes but like i could see BoundingBoxes in DummyCube are not updated when you move a child object. I'll see more deeply where the update of those are made in the GLscene's code
PS: a odd hourglass appears after zoom to fit. I think is cause by the transformationchanged function and should depend of the complexity of the scene
hi,
i tried Jerome.D solution,
but did not work on Orthogonal projection in my project..
the panning is neither not work, accept from shine world codes.
regards
tbk
Hi with Orthogonal need somme other calculs. In waiting i've found better solution
Hello,
My UI start to get shape... I used the bendingcyl demo as a starting point.
Very satisfied the way pan, zoom, dolly-zoom and orbit worked out. Pan thanks to shine world!
I'll start on the zoom to fit now.
This UI demo nicely shows how the camera frustum is shaped. See the second form for this.
What I miss out on:
1) When I start the program the near plane does not fit the sceneviewer. Do I always need to set the cameras SceneScale for this? Or don't I understand the basics?
2) Is there a rule of thumb for a model in meters and camera distance and focal distance? In the UI demo you'll see model can't be set to full screen (without scenescale that is). You can change SceneScale by holding the ALT-key when zooming. Setting SceneScale to 0.12 will show the near plane of the frustum...
3) How can I let a cadencer continue to work when a second form is opened?
4) Is the near plane always connected to focal distance, or can it be set seperately?
The source for my UI demo is attached.
What do you tink about the camera actions?
Kind regards,
DaSteelMan
Update.
I solved boundingbox for TGLPipe on a basic level: For every node check for max and min, take radius into account. This whil give you a boundingbox that can be off by +radius
The code to implement in TGLPipe is attached.