Sign in to follow this  

[.net] Direct3d Sprite collision

This topic is 4843 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
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
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

This topic is 4843 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this