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.

DarkBASIC Professional Discussion / object screen x, y

Author
Message
takachi
23
Years of Service
User Offline
Joined: 30th May 2003
Location:
Posted: 8th Jul 2003 09:05
the object X and Y commands return only one co-ordinate, how can I find out, for example, bottom right corner and upper left, or get the objects size on the screen?

I'm attempting to create a warcraft-like UI, and I'm uncertain how to track cursor interaction with 3d objects.
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 8th Jul 2003 13:35
You can't. Only possible way is to have hidden objects that you place at the corners of the objects you want tracked. Then you can get screen coords of the hidden objects.

R Tape loading error
takachi
23
Years of Service
User Offline
Joined: 30th May 2003
Location:
Posted: 8th Jul 2003 13:56
YUCK! but i suppose if its the only way... that creates so many difficulties though, like, camera rotation, for example. the 'dummy' objects would have to rotate around the objects they were tracking whenever the camera did... at least its doable.

I had a slightly different idea... thx
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 8th Jul 2003 14:01
I don't understand.

The camera can move around as much as you want.

You only need move the dummy objects when you move the main object. You could 'glue' them to the main object and not even worry about them.

If you still have problems I'll have a play tonight unless someone else has a bright idea.

R Tape loading error
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 8th Jul 2003 14:32
The dummy objects wouldn't remain in the top left and bottom right of the object in relation to the cameras perspective if you didnt rotate them. If you have an object bolted to the top left and bottom right of a cube, and then you move round 90 degrees to look at the object from the side, those dummy objects wont be in the top left and bottom right anymore.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 8th Jul 2003 14:59
Right, I get what you are going on about now! What was I thinking!!

You want to encase an object on screen with an imaginary box and calculate the screen coords of the 4 corners so you can do some sort of fancy cursor.

I really don't think that's possible.



R Tape loading error
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 8th Jul 2003 18:02 Edited at: 8th Jul 2003 18:07
it is possible, after all they do it in commercial games, you have the object position and you can find the distance from the camera, and you know that the size of the rectangle that would bound the shape gets smaller the further the object gets from the camera, it works to a ratio, so all you need to do is work out how much smaller the object gets for every world unit it moves away from the viewpoint, from memory it`s something LIKE (my memory is lousy)

dist apsize(pixels)
2 = 260
3 = 150
4 = 110
5 = 90
6 = 70
7 = 60
etc = etc

so just store whatever values it realy is (those above are best guess) in an array and scale to the object at the size you select from the array as an integer of the distance from the viewpoint, for example if the object is at a distance of 4 and the size is one then the rectangle would be an apparent 110 pixels across in the default screen, so a sprite scaled suitably would be 110 pixels wide, is that the sort of thing you are after? (yes! I know it involves some tiresome work getting the object sizes in the first place but that happens a lot when you code and you only need the range for one model and you can work the rest from relative sizes )

Mentor.

ps: or in simpler terms use a table of numbers to give the on screen size of objects at a set range if you can`t figure what I am ranbling on about, you could measure the relative scales from some code like this...

autocam off
make object cube 1,1
position object 1,0,0,1
position camera 0,0,0
for i=1 to 100
position object 1,0,0,i
repeat
text 0,0,str$(mousex())
text 0,15,str$(mousey())
text 0,30,str$(i)
sync
until spacekey()
wait 200
next i
do
loop

cheers.

The Wendigo
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 9th Jul 2003 05:31
you can actually figure it out mathmatically too. I'm not completely sure on the algorithms, but it is possable. it would be some sizeX/sizeY to distance ratio. I'd be confused with it though as you also have to keep the focus variable in mind of the camera (FOV). As the FOV works differently than I am used to in 3D QBasic programming (stop laughing), I'm not sure how that would properly be written into the equation.

Current Projects: Game Spawn 85%, mini BSP maker 50%, Height Mapper with many features 75%, Space Tactical (Like BC300AD) 15%.
ICERGB
23
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 11th Jul 2003 10:24 Edited at: 11th Jul 2003 10:26
Do it the easy way and flash(hide/unhide) the 3d object-> box collision

Although...
those 3d points are calculatable, unless you move the ground instead of the camera...
ICERGB
23
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 11th Jul 2003 10:30
if: a point to cross >xy and <xy
inc crossed1

Login to post a reply

Server time is: 2026-07-18 07:31:56
Your offset time is: 2026-07-18 07:31:56