Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Is there a formula/command for the camera to adjust its position to have the entire object in view?

Author
Message
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 1st Apr 2019 23:25 Edited at: 1st Apr 2019 23:25
For instance, if my object is 10x15 (or even 100X150)how far back or forward should I move the camera, so the entire thing is in view and showing as little "black" as possible? Or are their commands to set the X and Y for the camera?

I see a lot of camera commands, but the instructions are pretty confusing for someone with little knowledge.

Thanks.

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 1st Apr 2019 23:35 Edited at: 1st Apr 2019 23:36
This post has been marked by the post author as the answer.
Have a look here. Madbit has a very simple and elegant solution

I have done some additional work on it here. Either my math or my theory didn't hold up
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 1st Apr 2019 23:45
Thanks Blink!
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 2nd Apr 2019 04:26 Edited at: 2nd Apr 2019 06:24
With your theory Blink I was able to come up with this:


I still need to adjust for objects that have a much larger height than width. But, so far works pretty nice. It "should" also center on objects despite its origin.

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 2nd Apr 2019 04:34
Yes. It's important to remember that GetObjectSizeMaxX/Y/Z and GetObjectSizeMinX/Y/Z do not reflect rotation or scaling of the object.
So say if the object is scaled up by 2 and rotated 45o around Y axis, GetObjectSizeMin/Max values will not change
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 2nd Apr 2019 04:35
Ok, that shouldn't really hurt me. But I will remember in case I am wrong.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 2nd Apr 2019 04:47
Sorry, marked my original questions as answer. Fixed that to mark Blink0K as the answer.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 2nd Apr 2019 06:03
I think;
GetObjectSizeMaxZ(ObjID)-GetObjectSizeMinZ(ObjID)/2
Should read;
(GetObjectSizeMaxZ(ObjID)-GetObjectSizeMinZ(ObjID)/2
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 2nd Apr 2019 06:19
Wow. Thank you, Blink. I owe ya.

You have no idea how many times those order of operations have come back to bite me in my ass.

Login to post a reply

Server time is: 2024-11-23 01:40:10
Your offset time is: 2024-11-23 01:40:10