Jump to content


Photo

Precise 3d Mouse Collisions! 200+ Dl ;d


  • Please log in to reply
54 replies to this topic

#1 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 26 March 2008 - 02:53 AM

  • Precise 3D Mouse Collisions!!!
  • Check whether or not the mouse is actually pointing to a 3d object that is drawn while in d3d mode, used for accurate collision checking, in games like command and conquer: generals and world of war craft!!!
  • Game Maker 7
  • It uses D3D functions, so yes, you need registered
  • This is a .gmk file (Gm7 only)
  • Very easy to use, just download the file, and read the comments
I made one quick change to the code in the example:

3-26-08: I changed the size of the first view so that it would run faster while drawing 3-d models (this is especially useful if you have a lot of models)

I added a sky object to the example, it shows that other objects wont interfere with the detection, no matter what color it is!



Note: Anytime i post updates, that means that i uploaded a new file with the same name, so their is no new link, its always the same one.

Posted Image


Please give me credit if you use this!!
This example can have up to 16,194,277 Objects being checked, but anything more than that will cause objects to overlap (not like anyone would put 16 million objects in their game anyways)

New download link:
Download Here

If The Main Download Link Doesnt Work, Try This Alternate Mirror:
Alternate Mirror

January 31st 2009
- Added a custom model, sky tinting/coloring, fog, and gravity


Enjoy, Dk81584


Edited by dk81584, 31 January 2009 - 09:01 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#2 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3283 posts
  • Version:GM:Studio

Posted 27 March 2008 - 03:56 AM

Great example, very accurate and simple to understand. This could come in very handy.
  • 0

AFK


#3 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 27 March 2008 - 04:31 AM

Great example, very accurate and simple to understand. This could come in very handy.


Thanky You!
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#4 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 28 March 2008 - 03:00 AM

Great job! This may be useful to me ^_^

-hanson
  • 0

#5 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 30 March 2008 - 10:42 PM

Thanks for the replies

Edited by dk81584, 30 March 2008 - 10:57 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#6 Eggie

Eggie

    GMC Member

  • New Member
  • 20 posts

Posted 31 March 2008 - 03:09 PM

Amazing!
  • 0

#7 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 02 April 2008 - 05:14 AM

Amazing!



thnx
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#8 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 03 April 2008 - 06:44 PM

Why are you using make_color() (Old GM function) instead of make_color_rgb()? :)

And just a question about how it works:
Does this in the Draw Event quickly remove the lightning, check the pixel at the mouse, somehow get what model the mouse is pointing at, and then reset lightning back to normal?

Other than that, great example. Except setting the room speed to say 9999, the FPS is down at 50-55, which proves this can be very slow on some computers... fortunately, I have a really fast computer, but then the FPS drop makes this even more amazing(ly slow). 'Cause when I set the room speed in a GM example (Or anything else), it would usually be around 800-890.

Here's my computer's speed and info, just so you know:
  • AMD Athlon™ 64 X2 Dual Core Processor 5000+ 2.60 GHz
  • 2046 MB RAM
  • 32-bit operating system
Also, does this work with textured models?

- Fede-lasse

Edited by Fede-lasse, 03 April 2008 - 07:12 PM.

  • 0

Call me Fede.


#9 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 03 April 2008 - 07:42 PM

Why are you using make_color() (Old GM function) instead of make_color_rgb()? :)

And just a question about how it works:
Does this in the Draw Event quickly remove the lightning, check the pixel at the mouse, somehow get what model the mouse is pointing at, and then reset lightning back to normal?

Other than that, great example. Except setting the room speed to say 9999, the FPS is down at 50-55, which proves this can be very slow on some computers... fortunately, I have a really fast computer, but then the FPS drop makes this even more amazing(ly slow). 'Cause when I set the room speed in a GM example (Or anything else), it would usually be around 800-890.

Here's my computer's speed and info, just so you know:

  • AMD Athlon™ 64 X2 Dual Core Processor 5000+ 2.60 GHz
  • 2046 MB RAM
  • 32-bit operating system
Also, does this work with textured models?

- Fede-lasse


Yes, it does work with textured models, and yes, it does reset lighting, that way it can get the true color of the model, and yes, it does use make_color_rgb and yes, it does run above normal speed, which is a good thing, that means that it is not slow, if it was slow, then it would run beloew 30 fps, but it doesnt.

And i too am running a really good computer also

  • Processor - Core 2 quad (SLACR)
  • Ram - 2gb ram OCZ GOLD/800mhz
  • VGA - xfx GeFORCE 8400GS
  • Motherboard - Nforce 650i Ultra
  • Sound - Creative Sound Blaster Audigy SE 24-bit
Dont believe me, look at my specs



Posted Image

Posted Image


Edited by dk81584, 03 April 2008 - 07:48 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#10 GisleAune

GisleAune

    GMC Member

  • New Member
  • 278 posts

Posted 04 April 2008 - 05:36 PM

This is just AMAZING


11 / 10. This is really good stuff, may help many people with thier newB questions,
  • 0
Taming the mighty Ogre3D...

Sorry, my avatar can't be grasped by mere mortals.

#11 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 04 April 2008 - 05:57 PM

dk81584:
I am not saying it is going below 30 FPS, but what I'm saying, is that it goes way below the FPS I normally have when setting it to 9999 in any other GM example, even if it is a 3D example.

- Fede-lasse

Edited by Fede-lasse, 04 April 2008 - 05:57 PM.

  • 0

Call me Fede.


#12 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 05 April 2008 - 06:11 AM

dk81584:
I am not saying it is going below 30 FPS, but what I'm saying, is that it goes way below the FPS I normally have when setting it to 9999 in any other GM example, even if it is a 3D example.

- Fede-lasse


Ther really isnt much else you can do besides changing the size of the first and second views, that way it cuts down on the pixels being drawn, but his in turn, of course... will cause bad display results that will look horribly choppy, but as long as it runs 30 fps or above, its ok with me.
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#13 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 05 April 2008 - 05:08 PM

What about the audience? :GM123:

- Fede-lasse
  • 0

Call me Fede.


#14 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17266 posts
  • Version:GM:Studio

Posted 05 April 2008 - 10:03 PM

Don't want to rain on your parade but you don’t explain where the actual mouse to object detection code is... I've been hunting up and down your code for the last 10 minutes and I am still mystified...

Edited by icuurd12b42, 05 April 2008 - 10:04 PM.

  • 0

#15 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 08 April 2008 - 04:42 AM

Don't want to rain on your parade but you don’t explain where the actual mouse to object detection code is... I've been hunting up and down your code for the last 10 minutes and I am still mystified...





if your talking about when it detects what object is at the mouse,
that is in the draw event, under the first action, it checks the first view for obejcts that have a unique color id
and returns if any objects were at the mouse. if that did not help, i will have to comment further on my code -.-
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#16 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17266 posts
  • Version:GM:Studio

Posted 08 April 2008 - 04:54 AM

Don't want to rain on your parade but you don’t explain where the actual mouse to object detection code is... I've been hunting up and down your code for the last 10 minutes and I am still mystified...





if your talking about when it detects what object is at the mouse,
that is in the draw event, under the first action, it checks the first view for obejcts that have a unique color id
and returns if any objects were at the mouse. if that did not help, i will have to comment further on my code -.-



Would it possible for it to detect sprites that I have tilted up using the d3d fuctions? Like the monters/barrels in the 3d example?
  • 0

#17 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 08 April 2008 - 06:39 AM

.....

Edited by dk81584, 24 May 2008 - 10:47 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#18 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17266 posts
  • Version:GM:Studio

Posted 08 April 2008 - 07:29 AM

Don't want to rain on your parade but you don’t explain where the actual mouse to object detection code is... I've been hunting up and down your code for the last 10 minutes and I am still mystified...





if your talking about when it detects what object is at the mouse,
that is in the draw event, under the first action, it checks the first view for obejcts that have a unique color id
and returns if any objects were at the mouse. if that did not help, i will have to comment further on my code -.-



Would it possible for it to detect sprites that I have tilted up using the d3d fuctions? Like the monters/barrels in the 3d example?


first of all, it uses colors to detect where the object is, so you would have to modify the code a little bit, and have a second sprite that was white and blank with the outline of your origional sprite, something like this :
Posted Image

and then you would draw the blank sprite in the first view with the unique color rotated to whatever direction you wanted it

and then to display it in the 3d world with textures, do the same, only for the second view (view[1]) and draw it with a texture

I hope that made some sense, if not, i will try to upload an example as soon as possible.



Somewhat... I was thinking of doing a paralax type game, side view by flipping the sprites and placing the camera off the ground instead of fooling arround in 2d. It would be a mouse based game to click and move and pick up things either on the floor or on bushes... Like King Quest/Space Quest but with 3d perspective using 2d sprites and some 3d models... If I could use your example, it would make my life easier. I would not mind you taking a shot at an example though.

I'm basically thinking of making a hyped up engine like this one

http://www.adventuregamestudio.co.uk/

Edited by icuurd12b42, 08 April 2008 - 07:55 AM.

  • 0

#19 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 10 April 2008 - 08:00 AM

.....

Edited by dk81584, 24 May 2008 - 10:46 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#20 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17266 posts
  • Version:GM:Studio

Posted 10 April 2008 - 09:04 AM

Sounds like a good idea, the only thing that you would really have a problem with would be comparing the z-values of the objects, to the y value of the mouse when u want to move something, and making the objects move sideways according to the cameras point of view, becaise in d3d it switcheds x, with y axis, so it might be kinda hard doing that, but that would be the only real issue that you would really have if you wanted to design anything like what you were talking about, i haven't been able to start on an example, been busy with other stuf...... But i will get around to it eventually -.-



Well, if you have the time, here is an example of the setup.

Download AdventureEngine.gmk
  • 0

#21 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 14 April 2008 - 06:14 AM

.....

Edited by dk81584, 24 May 2008 - 10:46 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#22 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 24 May 2008 - 10:46 PM

so many downloads :lol:
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#23 Rexhunter99

Rexhunter99

    GMC Member

  • GMC Member
  • 924 posts
  • Version:GM:Studio

Posted 26 May 2008 - 07:29 AM

This is absolutely fantastic so of course there are tonnes of downloads!!!
  • 0

Posted Image EpicZen, Games, Tutorials and more!


#24 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 28 May 2008 - 03:09 AM

This is absolutely fantastic so of course there are tonnes of downloads!!!


Glad too know that this is useful for people :)
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#25 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 12 June 2008 - 08:42 PM

Bump :whistle:
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#26 Boffel Production

Boffel Production

    TWP Developer

  • New Member
  • 350 posts

Posted 12 June 2008 - 09:44 PM

WOW, very nice done. Few and easy codes, even I can handle it :P

Perhaps I will do my online game 3d when im finished with the 2d version ;)

But it will take time to get into 3d again, worked to much with online coding :whistle: both good and bad
  • 0

#27 hasser

hasser

    GMC Member

  • New Member
  • 537 posts

Posted 12 June 2008 - 10:21 PM

download link doesn't work, could you add a mirror? this looks interesting.
  • 0

#28 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 13 June 2008 - 02:53 AM

download link doesn't work, could you add a mirror? this looks interesting.



Uploaded an alternate link to media fire, that should work :whistle:
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#29 hasser

hasser

    GMC Member

  • New Member
  • 537 posts

Posted 14 June 2008 - 04:08 PM

thanks I checked it out and it was prettey cool! Nicely commented too, although I dont understand why you need the 3d array...

why dont you have one array with 2 values per index which has :

array[0,0] = colour of object
array[0,1] = id of object

since you can store a colour as a number, just look at "string(make_colour_rgb(x,y,z))", couldn't you use that?
  • 0

#30 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 15 June 2008 - 05:46 PM

thanks I checked it out and it was prettey cool! Nicely commented too, although I dont understand why you need the 3d array...

why dont you have one array with 2 values per index which has :

array[0,0] = colour of object
array[0,1] = id of object

since you can store a colour as a number, just look at "string(make_colour_rgb(x,y,z))", couldn't you use that?


thats a good idea, ill work on it later when im not busy.
  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#31 GrayAvocado

GrayAvocado

    A big bad Wolf

  • GMC Member
  • 1226 posts

Posted 11 July 2008 - 10:40 AM

Awww! This uses excute string.
  • 0

#32 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 15 July 2008 - 04:32 PM

it has to, how else would it check to see if the variable exists?
seeing as how you cant use a variable_local_array_exists, so it has to be in a string mode, or
else you would get errors with variables that didint exist..
______________________________________ ^ SEE THE TYPO! xD

Edited by dk81584, 15 July 2008 - 04:33 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#33 aqbyhd

aqbyhd

    GMC Member

  • New Member
  • 78 posts

Posted 22 October 2008 - 04:55 PM

im a dumbass i don't even get it?

it doesn't even draw the cone or anything i just don't get it.
  • 0

#34 Seperoth

Seperoth

    GMC Member

  • New Member
  • 121 posts

Posted 25 October 2008 - 12:06 AM

WOW!!! :GM7:
Nice example! Very well-commented and easy to understand!

I'll propably use this in a project :GM063:
  • 0
I am an in the GM Quiz!

#35 theweirdn8

theweirdn8

    Unrivaled Legend

  • GMC Member
  • 4108 posts
  • Version:GM8.1

Posted 06 December 2008 - 04:55 PM

ITs not working.
  • 0

[My milkshake brings all the boys to the yard]


2h2fg3c.png


#36 theweirdn8

theweirdn8

    Unrivaled Legend

  • GMC Member
  • 4108 posts
  • Version:GM8.1

Posted 04 January 2009 - 11:56 PM

EMERGENCIA!
EMERGENCY
DO NOT USE THIS.
Once you use this, your fps will be lower than scum. I thought my problem was my coding,but it was this. This lowers fps. The double views in 3d is not going to work out. I repeat,do not use this.Sorry,but if you are making a game that needs a good fps, i suggest you edit this alot.
  • 0

[My milkshake brings all the boys to the yard]


2h2fg3c.png


#37 briantrlov

briantrlov

    GMC Member

  • GMC Member
  • 610 posts

Posted 24 January 2009 - 04:19 AM

i hope hardcoregamer is rong i want to use this SOOO BAD but i dont know how, this would be the freaking backbone of my game, i wouldnt mind some help i need it to work so when i hover over a npc it says there name and level i beg of you to help me with this until i get it, ill give you a cookie :)
  • 0
Posted Image

#38 Potado

Potado

    GMC Member

  • New Member
  • 401 posts

Posted 24 January 2009 - 04:35 AM

yess! this would be perfect for my game! Too bad it's not in GM6!!!!!!!!!
  • 0

#39 Bouncy Ball

Bouncy Ball

    GMC Member

  • GMC Member
  • 116 posts

Posted 24 January 2009 - 05:40 AM

this works perfectly well on my pc so i do not know what hardcoregamer is talking about
  • 0

#40 theweirdn8

theweirdn8

    Unrivaled Legend

  • GMC Member
  • 4108 posts
  • Version:GM8.1

Posted 25 January 2009 - 01:43 AM

THe screen is drawn twice. Don't you get it. Thats 2 times the drawing events=lag. Also use phantom107's engine.
  • 0

[My milkshake brings all the boys to the yard]


2h2fg3c.png


#41 §-«»-§

§-«»-§

    GMC Member

  • New Member
  • 83 posts

Posted 25 January 2009 - 09:11 PM

This is absolutely brilliant. I'm not sure how well it would scale in a larger project, because of the whole drawing two screens thing, but the concept behind it is very clever. One question, though -- since the background has a color of 192,192,192, wouldn't there be false alarms for an object given that color value if the player points the mouse somewhere with no object? Or am I missing something here?
  • 0

#42 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 25 January 2009 - 10:26 PM

I did tests. No fps drop.
  • 0

#43 Caniac

Caniac

    The #1 Caniac

  • New Member
  • 2622 posts

Posted 26 January 2009 - 01:35 AM

this RULES.
this is so epic! I love it!
no complaints here, and the fps seemed fine to me.
  • 0

#44 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 26 January 2009 - 03:58 AM

Actually couldnt you make this faster by decreasing the view size? That would decrease the qaulity though =(
  • 0

#45 Pie Person!

Pie Person!

    GM 6+ Lover

  • GMC Member
  • 1973 posts

Posted 27 January 2009 - 03:34 AM

I haven't had a chance to download this until now. It is a wonderful example! You've gone the extra mile by implementing a sky dome and lighting, and you've also used lots of commenting. I haven't explored the code completely yet, but I have no findings of vectors and other junk like that. I've always thought about making some thing like this.

Good work!
  • 0
Cool.

#46 theweirdn8

theweirdn8

    Unrivaled Legend

  • GMC Member
  • 4108 posts
  • Version:GM8.1

Posted 27 January 2009 - 12:58 PM

Add alot of objects, and then change from 1 view to the other.
  • 0

[My milkshake brings all the boys to the yard]


2h2fg3c.png


#47 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 31 January 2009 - 07:07 PM

been awhile , didn't even know anyone was still interested in this, but if you want the fps not to drop so much on a graphically challenged machine, then change the actual size of the first view (the one it uses to get the color of the object from) to a smaller value, and then make it stretch it, it wont matter on quality because you dont even see the first screen, and the background is black, and all colors start out with a R,G,B value of 1,1,1 so that they never are the same as the background, and then increase color value starting from the left to the right, red adds one, when it goes over 255 blue adds one and red goes back to 1, this way it can support up to 254*254*254 objects all at once, but that seems liek a rediculous number of objects to put into a game, but the way it is it will never draw the same color twice, and sorry i didnt respond at all, been really busy with other stuff. but like i said, don't make the first view super huge, or else it will slow it down, because it has to draw more pixels the bigger the first one is, and it doesnt matter the quality of the first view because you never see it.

-Modified it once more, changed view size, and added a couple of extra things
-Fog, Sky coloring/tinting, gravity, and a custom model

Heres new link (http://ifile.it/gaprik4)

Edited by dk81584, 31 January 2009 - 09:03 PM.

  • 0
Signature removed due to size restriction violation. The old signature is placed in the About Me section of the user's profile.

#48 superjoebob

superjoebob

    YM2612

  • New Member
  • 1515 posts

Posted 20 December 2009 - 01:59 AM

Sir, you have filled in a massive hole in 3d game making for me, thank you. You have created a wonderful thing here.
  • 0

Game Maker user since the beginning
Online Music Portfolio - High-Res Wallpaper
I speak before I think.
Posted Image

Posted ImagePosted Image


#49 Novice_helper

Novice_helper

    GMC Member

  • New Member
  • 64 posts

Posted 20 December 2009 - 04:15 AM

Sweet! Very useful and works very well!
  • 0

#50 Grak

Grak

    GMC Member

  • New Member
  • 120 posts

Posted 29 March 2010 - 01:02 PM

This is really incredible. Would you mind posting some of the older versions as well? It's difficult to look around all the extra code with the fog color and other settings to find how this works.
  • 0
"A wise man washes his hands after he pees. A wiser man doesn't pee on his hands."




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users