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.

Dark GDK / dbPickObject with several objects

Author
Message
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 20th Dec 2008 19:59
Hey, my cousin asked me to make a meteor-like game today, and i started working on it. But as usually i have a small problem. I want to pick an object that is going twords the ship, but when i am doing that several objects that are in the scene right now stop.
Here's the code i am using:

Any ideas on how i can do it better? Thank you.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 20th Dec 2008 20:14
I *think* sparky's collision has a function similar to dbIntersectObject(), except that rather than you specifying the object to check it checks against all objects and returns the ID of the object it hits. So you can cast a ray from the mouse position and see if it hits anything. Hope that helps.

zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 20th Dec 2008 20:24
hm Any example using sparky's?
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 20th Dec 2008 20:33
I haven't used SC in awhile, but here's how I guess you would do it:

-Start SC with SC_Start().
-Set up all of the objects with SC_SetupObject(). You'll want to set the meteors as spheres and make sure they're all in the same group so you can check collision against all of them.
-Then you can use SC_RayCastGroup( ), giving the group ID of your meteors as a parameter. The old position of the ray can be your camera's/ship's position, and the new position can be obtained via dbPickScreen( dbMouseX( ), MouseY( ), 1000.0f ).

That might sound a bit confusing, if I have any time tonight I'll try to put together a little demo.

zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 20th Dec 2008 21:59
Thanks AndrewT. Hope you will find some time !
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 21st Dec 2008 00:35
If I was you I would download sparkys while you wait for example,
its what everyone uses, as the db commands for collision are'nt very good.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 21st Dec 2008 04:07
Ok, here's some code to demonstrate what I was talking about:



You'll need Sparky's collision (just search it up to find the download) to compile it.

If you have any questions feel free to ask them.

Login to post a reply

Server time is: 2024-11-25 09:31:23
Your offset time is: 2024-11-25 09:31:23