Jump to content


Photo

Precise 3d Mouse Collisions! 200+ Dl ;d


  • Please log in to reply
53 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

#2 xygthop3

xygthop3

    The one who knocks

  • GMC Member
  • 2888 posts
  • Version:GM5

Posted 27 March 2008 - 03:56 AM

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

#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

#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

#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

#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

#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

#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

#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

#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

#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

#14 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Retired Staff
  • 15416 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

#16 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Retired Staff
  • 15416 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

#18 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Retired Staff
  • 15416 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

#20 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Retired Staff
  • 15416 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

#22 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 24 May 2008 - 10:46 PM

so many downloads :lol:
  • 0

#23 Rexhunter99

Rexhunter99

    GMC Member

  • GMC Member
  • 922 posts

Posted 26 May 2008 - 07:29 AM

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

#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

#25 dk81584

dk81584

    Program Maker

  • New Member
  • 171 posts
  • Version:GM8

Posted 12 June 2008 - 08:42 PM

Bump :whistle:
  • 0

#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

#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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users