Hi
For Zoom all object you must travel the glscene tree and play with the Scale property of all objects
this is a pseudo code
For i:=0 to (CountObjects in GLScene)
begin
if ObjectFound is not a TGLDummyCube and Haven't Child then
ObjectFound.Scale.X := ZoomFactor;
ObjectFound.Scale.Y := ZoomFactor;
ObjectFound.Scale.Z := ZoomFactor;
end
else if (object Have Child) then
begin
Travel into the childs subobjects and set Scale
end;
end;
You must care if your object contains sub-objects because the scalling will be affected more than one time (one for the parent and all other for the child)
For what you want to do the best it will do a Recursive procedure i think
Best regards
Last edit: Jerome.D (BeanzMaster) 2015-10-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That really doesn't sound to be a good idea, bcoz I physically if I change the geometry of each object, how you 'll restore them back, another traversal through the objects?
The best aolution would be: traverse whole objects to obtain the biggst AABB, try to align the viewing frustum with that big AABB, cast a ray into scene from camera calculate the intersection point of AABB, try to position the camera in a way that viewing frustum and AABB in world or modelview(I'm not sure) coordinates align wit tolerance.
This technique should work IMHO but I don't know how to do it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok i understand if you want restore them back you must backup scale values for each object .
But i don't understand what you want to do exactly. It s for an Editing project ?
If i understand you want tou adjust camera settings for view all objects in your scene, i'm right ?
If yes it's possible but i do'nt remember how. I must search in my oldcode. I did a similar thing for a GLScene editor project some years ago.
Can you give more details about your project ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If i understand you want tou adjust camera settings for view all objects in your scene, i'm right ?
Yes, absolutely correct.
If yes it's possible but i do'nt remember how. I must search in my oldcode. I did a similar thing for a GLScene editor project some years ago.
I'll be very grateful if you share any pieces of code related to that I also remember in the old sourceforge site that there was some entry code to start that, but since its gone I have not any clue on how to do it.
Last edit: SBlade 2015-10-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, so i'm not sure but this is what i found in my archives, i just give you some clues
Put a Root DummyCube objet for containing all your Scene's objects
Set this Dummy As your Camera Target
So a possible code will be :
objSize:=YourCamera.TargetObject.BoundingSphereRadius;
if objSize>0 then begin
if objSize<1 then begin
GLCamera.SceneScale:=1/objSize;
objSize:=1;
end else GLCamera.SceneScale:=1;
GLCamera.AdjustDistanceToTarget(objSize0.27);
GLCamera.DepthOfView:=1.5GLCamera.DistanceToTarget+2*objSize;
end;
In a DummyCube you have this property OnVisibilityDetermination: TGLVisibilityDeterminationEvent
An this public function AxisAlignedDimensionsUnscaled: TVector; override;
Check in TGLBaseSceneObject in GLScene.pass you have some Bounding And AxisAligned Functions
In GLCameraController you have this comment
//after AdjustScene the Camera.DepthofView will be modified
//if you want to zoom back in from GUI
//you should use something like //Camera.DepthOfView:=2Camera.DistanceToTarget+2camera.TargetObject.BoundingSphereRadius;
The AABB functions is in GLGeometryBB.pas
I hope this will be helpfull.
BTW : For all. If you are interested i'v many old GLScene sample Code from the old NG so do not hesitate to tell me perhaps i'v what you search :)
Best Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, i'm back so after this post, You gave me the desire to create a new GLScene Editor project. So i'v made some research and i found the TGLCamera have a procedure call ZoomAll and take as parameter a TGLSceneBuffer. I don't test it. but it will be the easiest solution
And you can also check the GLGizmoEx demo :)
Best regards
Last edit: Jerome.D (BeanzMaster) 2015-10-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, Jerome,
It's nice to hear that you've got a desire to create a GLScene Editor. Could it be an advanced version of GLGizmo or something like Sweet Home 3D? In any case you may take a place in the branch of GLScene repository for the project.
PW
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Pavel, yes i think it's possible to make a Gizmo like Sweet Home 3D. I'must see how.
"In any case you may take a place in the branch of GLScene repository for the project."
Thanks cool :) and i'm already figure in it :) (TGLGizmo, TGLHidden and Outline Shader) and i'v some old code like GLPlanet and a not finished game name Damion from the old NG
I'm also begin to convert some Shaders from DA_Stranger to new TGLShader and TGLSLShader component :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i'v some old code like GLPlanet<<
Yes, I know the demo from NG with your participation but it seems that here is more advanced and improved GLScene Space program made by Ivan Lee Herring and updated by me for RAD Studio (see attachment).
PW
Jerome,
Surely, now I've included with code the binary also in ..bin directory. Data about users are in EarthData in EarthLoco.txt file and may be edited manually.Try it.
PW
Is there any example on how to zoom all objects in scene ?
Regards,
Hi
For Zoom all object you must travel the glscene tree and play with the Scale property of all objects
this is a pseudo code
For i:=0 to (CountObjects in GLScene)
begin
if ObjectFound is not a TGLDummyCube and Haven't Child then
ObjectFound.Scale.X := ZoomFactor;
ObjectFound.Scale.Y := ZoomFactor;
ObjectFound.Scale.Z := ZoomFactor;
end
else if (object Have Child) then
begin
Travel into the childs subobjects and set Scale
end;
end;
You must care if your object contains sub-objects because the scalling will be affected more than one time (one for the parent and all other for the child)
For what you want to do the best it will do a Recursive procedure i think
Best regards
Last edit: Jerome.D (BeanzMaster) 2015-10-09
That really doesn't sound to be a good idea, bcoz I physically if I change the geometry of each object, how you 'll restore them back, another traversal through the objects?
The best aolution would be: traverse whole objects to obtain the biggst AABB, try to align the viewing frustum with that big AABB, cast a ray into scene from camera calculate the intersection point of AABB, try to position the camera in a way that viewing frustum and AABB in world or modelview(I'm not sure) coordinates align wit tolerance.
This technique should work IMHO but I don't know how to do it.
Ok i understand if you want restore them back you must backup scale values for each object .
But i don't understand what you want to do exactly. It s for an Editing project ?
If i understand you want tou adjust camera settings for view all objects in your scene, i'm right ?
If yes it's possible but i do'nt remember how. I must search in my oldcode. I did a similar thing for a GLScene editor project some years ago.
Can you give more details about your project ?
Yes, absolutely correct.
I'll be very grateful if you share any pieces of code related to that I also remember in the old sourceforge site that there was some entry code to start that, but since its gone I have not any clue on how to do it.
Last edit: SBlade 2015-10-10
Hi, so i'm not sure but this is what i found in my archives, i just give you some clues
So a possible code will be :
objSize:=YourCamera.TargetObject.BoundingSphereRadius;
if objSize>0 then begin
if objSize<1 then begin
GLCamera.SceneScale:=1/objSize;
objSize:=1;
end else GLCamera.SceneScale:=1;
GLCamera.AdjustDistanceToTarget(objSize0.27);
GLCamera.DepthOfView:=1.5GLCamera.DistanceToTarget+2*objSize;
end;
In a DummyCube you have this property OnVisibilityDetermination: TGLVisibilityDeterminationEvent
An this public function AxisAlignedDimensionsUnscaled: TVector; override;
Check in TGLBaseSceneObject in GLScene.pass you have some Bounding And AxisAligned Functions
In GLCameraController you have this comment
//after AdjustScene the Camera.DepthofView will be modified
//if you want to zoom back in from GUI
//you should use something like //Camera.DepthOfView:=2Camera.DistanceToTarget+2camera.TargetObject.BoundingSphereRadius;
The AABB functions is in GLGeometryBB.pas
I hope this will be helpfull.
BTW : For all. If you are interested i'v many old GLScene sample Code from the old NG so do not hesitate to tell me perhaps i'v what you search :)
Best Regards
Hi, i'm back so after this post, You gave me the desire to create a new GLScene Editor project. So i'v made some research and i found the TGLCamera have a procedure call ZoomAll and take as parameter a TGLSceneBuffer. I don't test it. but it will be the easiest solution
And you can also check the GLGizmoEx demo :)
Best regards
Last edit: Jerome.D (BeanzMaster) 2015-10-12
Hi, Jerome,
It's nice to hear that you've got a desire to create a GLScene Editor. Could it be an advanced version of GLGizmo or something like Sweet Home 3D? In any case you may take a place in the branch of GLScene repository for the project.
PW
Good to hear that.
Hi Pavel, yes i think it's possible to make a Gizmo like Sweet Home 3D. I'must see how.
I'm also begin to convert some Shaders from DA_Stranger to new TGLShader and TGLSLShader component :)
Jerome,
Last edit: Pavel Vassiliev 2015-10-13
Very cool Pavel can you attach the binary. i don't have RAD Studio it's more expensive for me now. I'm using Lazarus/CodeTyphon
Thanks
Jerome,
Surely, now I've included with code the binary also in ..bin directory. Data about users are in EarthData in EarthLoco.txt file and may be edited manually.Try it.
PW
Last edit: Pavel Vassiliev 2015-10-14
Thanks Very nice some things will be very helpfull :)
Hai All
Could anyoneexplain about ZoomAll that using TGLSceneBuffer? I have tried but no luck.
Thank you.
Tbk
Hi Tambok i don t understand whatyou mean exactly. Can you be more precise ?