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.

Newcomers AppGameKit Corner / Place a 3d object on Screen coordinates

Author
Message
Green7
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: Switzerland
Posted: 14th Aug 2017 12:43
How would you manage to keep a 3d object in the upper right corner of your window or screen, no matter what the resolution is? lets say: always 50 from the upper bound and 50 from the left bound...
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Aug 2017 01:05
Make it a sprite?

It may be more suitable.

Depends on what you are trying to do.

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 16th Aug 2017 16:14 Edited at: 16th Aug 2017 16:19
Try this :

Get the 3D Point from these commands (and don't move the camera after this) :

WantedX = Get3DVectorXFromScreen(50,50)
WantedY = Get3DVectorYFromScreen(50,50)
WantedZ = Get3DVectorZFromScreen(50,50)

(you may need to add camera coordinates if not at 0,0,0, as explained is the example in the documentation..)

And multiply the WantedZ coord by the distance (for the wanted size on screen) you want and apply WantedX , WantedY, WantedZ to your object.

Documentation with example : https://www.appgamekit.com/documentation/Reference/3D/Get3DVectorXFromScreen.htm
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 21st Aug 2017 21:08 Edited at: 21st Aug 2017 21:08
This worked for me. The code is from Hendron not my own.



Green7
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: Switzerland
Posted: 22nd Aug 2017 13:35
thx, will test!
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 22nd Aug 2017 20:10
@Golelorn, I been trying to get that calculation right for weeks, my code had an offset when a low y value was passed in I gave up and decided to live with it, your (Hendron's) code works perfect, thanks for (re)posting it.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 22nd Aug 2017 21:09
Yea, I wish I was smart enough to figure that out lol

Login to post a reply

Server time is: 2024-11-25 00:00:33
Your offset time is: 2024-11-25 00:00:33