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.

Code Snippets / 3d Object Selection

Author
Message
Jason Clogg
21
Years of Service
User Offline
Joined: 16th Mar 2003
Location:
Posted: 26th Mar 2003 14:10
He is my function to perform 3d object selection. It works for all camera rotations.

The first code is the function source and should be added to your project.



Seems to run resonably fast, even for a few hundred objects.

Cheers,

Jason
Jason Clogg
21
Years of Service
User Offline
Joined: 16th Mar 2003
Location:
Posted: 26th Mar 2003 14:13
The 2 sections of code appear to have merged. I will post them invividualy

First the Function



Jason Clogg
21
Years of Service
User Offline
Joined: 16th Mar 2003
Location:
Posted: 26th Mar 2003 14:13
Now the sample project



Cheers,

Jason

Superbeest
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: Netherlands
Posted: 26th Mar 2003 15:39
Very nice. Mind if I use it in one of my games? I'll put you in the credits then.

By steel will thy flesh divide
Jason Clogg
21
Years of Service
User Offline
Joined: 16th Mar 2003
Location:
Posted: 26th Mar 2003 16:24
Feel free. Good to see it's of use to someone.

Superbeest
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: Netherlands
Posted: 26th Mar 2003 16:34
Thnx your the best

By steel will thy flesh divide
delorme
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 7th Apr 2003 22:12
Hello

Apparently in 1280 by 1024 the code function no correctly.
Can you tell me why?

Sorry for my english.

Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 9th Apr 2003 04:14
can that be written in DB Classic?
delorme
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 9th Apr 2003 14:42
No in db classic the vector3 doesn't exits



Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 9th Apr 2003 15:38
Excellent Jason

@Rich

- Can you make this a sticky as this feature is requested very often.

Current Project: Retro Compo. Entry.
delorme
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 9th Apr 2003 19:53
What's a sticky ????

Sorry for my english.



deathAngel
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 10th Apr 2003 10:50
Jason Clogg, Thanks man! This is a perfect code. i've been looking for something like this for a long time but all i found was for objects with the same size.

Jason can i use it in my project i'll put you in the credits.

(Sorry for the bad English)

Dmitry K
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Russia
Posted: 10th Apr 2003 13:05
Hmm. I am also want to be in the credits. This code based on my snippet.
http://www.realgametools.net/forums/index.php?board=8;action=display;threadid=10236
http://www.realgametools.net/forums/index.php?board=3;action=display;threadid=11626

UberTuba
21
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Brittania
Posted: 11th Apr 2003 13:42
sweet!! me too. Perfect for my rts game!

Life is a terminal disease.
You never survive it.
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 11th Apr 2003 22:16
@delorme

A sticky is a topic which always stays at the top of the forums - these are used for important announcements or issues which come up often.

Current Project: Retro Compo. Entry.
deathAngel
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 12th Apr 2003 09:14
DMiTR0S thank you as well. I see you have done allot of work on your code, wich Jason used to make this own. maybe whitout you this wasn't possible.

I will also put you in the credits. but the firs beta of my project will be out not sooner then few months.
i'll post a linke and more information about it when i'll be closer
to finshe the first beta.

(Sorry for the bad English)

delorme
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 12th Apr 2003 09:42
@Rob K
Thank's for your explain

@DMiTR0S
Your code is code in 1024*768 but work not correctly in 1280*1024 can you help me so that the code work correctly in 1280*1024

Sorry for my english.



deathAngel
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 12th Apr 2003 11:35 Edited at: 12th Apr 2003 11:46
delorme it works on 1280x1024, but you have to change 4 lines of code
in Function ProjectMouse(Dist#): (==> means change to) :-s

px#=(((dist#*.8)+.8)*2)/screen width()
==> px#=(((dist#*.752)+.752)*2)/screen width()

py#=(((dist#*.6)+.6)*2)/screen height()
==> py#=(((dist#*.599)+.599)*2)/screen height()

X#=(mx#*px#)-((dist#*.8)+.8)
==> X#=(mx#*px#)-((dist#*.752)+.752)

Y#=((dist#*.6)+.6)-(my#*py#)
==> Y#=((dist#*.599)+.599)-(my#*py#)

delorme
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 12th Apr 2003 16:42
Ok VERY THANK'S x-d

For DMiTROS
in 1280*1024 the value is

DKAspectratio#=1.5
not 1.33333333333
...
DKCameraspaceX#=(-0.8321*DKNMouseX#*DKAspectratio#)*DKMaxY#
not -1.0

Thank's for your help

Dmitry K
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Russia
Posted: 12th Apr 2003 17:06 Edited at: 12th Apr 2003 18:17
AspectRatio#=(Screen Width()*1.0)/(Screen Height()*1.0)

delorme
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 13th Apr 2003 10:47
Still thank's DMiTROS

with regard to the ratio i had guessed. But can you explain me the usage of the matrix in the code and why inverse

View Matrix4 DKMatView
r#=Inverse Matrix4(DKMatView, DKMatView)

A#

Sorry for my english,
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 13th Apr 2003 16:34
How does this work? I need to make a system like that for DBC. If you know the screen height and width and the distance of the 'eye' of the camera to the imaginary screen which the view is pasted on, then you should be able to work where the mouse is pointing to in 3D space, am I right?



Why the hell'd you ask me for crying out loud!?!

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 13th Apr 2003 17:02
I think that is the way that the camera syste works in DB. It says on the help file for the camera FOV that the default value for the FOV is 3.14/2.905. Do you know what the values in this equation stand for ('.' means the dot product of the values right?)?

Why the hell'd you ask me for crying out loud!?!

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM

Login to post a reply

Server time is: 2024-04-23 09:48:44
Your offset time is: 2024-04-23 09:48:44