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 / draw rectangle with mouse?

Author
Message
Mugen Wizardry
User Banned
Posted: 13th May 2010 21:28
how can i draw a rectangle with the mouse?

i also need to keep it from drawing on the screen.

it needs to only draw it when the mouse button is down.

otherwise, it needs to delete or hide the rectangle

here's what i have:

Mugen Wizardry
User Banned
Posted: 13th May 2010 21:31
this also must be able to "select 3d objects" just by changing their color when the box is over the 3d object
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2010 23:23 Edited at: 13th May 2010 23:23
Quote: "how can i draw a rectangle with the mouse?
i also need to keep it from drawing on the screen."

That's a little contradictory.

Here's the answer to your first question (assuming that I've guessed what you wanted correctly):


The selection within an area is a little more complex.

A way of doing it that immediately comes to my mind would be to generate an object with the shape of the volume selected - note that this is NOT a cube, but is a pyramidal frustum (a pyramid with the top cut off, with the top facing the camera), and it most probably has it's sides parallel to the camera viewing frustum (although I'd have to think about that a little more).

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 14th May 2010 01:06
Or you could check each objects screen co-ords and check if they're within the rectangle area.

My signature is NOT a moderator plaything! Stop changing it!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th May 2010 15:27
Well yes, but I was thinking that'd be very slow, especially if you had a lot of objects, and that it would miss objects where their centre is outside of the selected area.

If you use Sparky's collision instead, then it'd be lightning quick and get all objects that actually touch the frustum object.

Mugen Wizardry
User Banned
Posted: 14th May 2010 15:29
i like IanM's way.

except one thing.

how would i color the selected object?
Mugen Wizardry
User Banned
Posted: 14th May 2010 15:30
i guess i could use sparkys?

but also how would i color the object selected

Login to post a reply

Server time is: 2026-07-25 11:49:05
Your offset time is: 2026-07-25 11:49:05