Jump to content
  • Advertisement
Sign in to follow this  
ruiner333

[.net] Direct3d Sprite collision

This topic is 5056 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've checked google already and haven't come up with a solution. I'm using Direct3d Sprites for 2d games. With Directdraw I can easily get at the pixel data of a sprite to do pixel perfect collision detection but with direct3d im at a loss as to where to start. All Im doing is working with a gui for now. I have some irregular buttons and I want to test if the mouse was actually clicked in a non-transparent region. How do I actually get at the pixel data for a point that Im testing? Or is there a simpler method?
            device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);

            // Create our texture
            spriteTexture = TextureLoader.FromFile(device, @"button.tga");

            using (Surface s = spriteTexture.GetSurfaceLevel(0))
            {
                SurfaceDescription desc = s.Description;
                textureSize = new Rectangle(0, 0, desc.Width, desc.Height);
            }
            sprite = new Sprite(device);

(p.s. forgive my engrish. I slept through grammar class.)

Share this post


Link to post
Share on other sites
Advertisement
Not unless you do it yourself. You can either choose to grab the suface level of your sprites and test them in your own code or you can use some other shaped bounding shape that makes more sense in for your application.

Share this post


Link to post
Share on other sites
I'm not sure but i think its possible, but its a lot more trouble than its worth. I dont think I have played a commercial game that did per-pixel collision. And its a really bad idea to be using the video data for game logic.

Share this post


Link to post
Share on other sites
Hmm...

Per-pixel collision seems like it would be difficult and slow.

You have the exact rectangle where you are drawing your sprite. I assume it's not sufficient that you be able to test if another items overlaps this rectangle?

Share this post


Link to post
Share on other sites
Well, I have concave gui buttons right now. And yes I did take calculus and college algebra in high school but its been 7 years since I looked at that stuff so doing bounds checking on a concave poly made me go crosseyed. I can always push myself and learn it again but it was so easy to check in directdraw if you had crossed their rectangular bounds box, create a rect of the region that had overlapped, and check the bitmap array at [x,y] for what color was in that pixel.

If Im stuck with bounds box which I will need to learn soon anyway. Could someone reccomend an article online (or book if there is a really good one) that really goes into it in laymans terms until I start remembering all my algebra?

[Edited by - ruiner333 on September 13, 2004 2:14:35 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!