January 29th, 2007 by Sharky

kick it on GameDevKicks.com 

Can people please let me know (via blog comments) if they are having problems with either…

  1. my latest “Air Legends” release?
  2. or my Collision Detection sample code?

I’ve had one report of a problem with “Air Legends” crashing after choosing from the menu screen.  Works fine for myself & some others.

Also Ultrahead alerted me to a problem he was having running my Collision Detection sample code (v1.0.0.1).

While it worked fine for me, a crash was occuring on the DrawIndexedPrimitives lines that actually draws the spheres. I wish I could understand why it would crash. My code for rendering the spheres was taken pretty much straight from an XNA help file example. 

While investigating the problem I ended up changing the code a little.

  • I had been using a LineList, but in retrospect a LineStrip seems simpler, and perfect for a list of connected lines. Once again, I based my code on the XNA help file example.

I’ve just uploaded a new version (v1.0.0.2). I’ll be interested to hear if it also gives anyone grief. 

If it does please do let me know. And as a work-around if it also fails, I’m guessing that changing these lines of code…

device.DrawIndexedPrimitives(
    PrimitiveType.LineStrip,
        0, // vertex buffer offset to add to each element of the index buffer
        0, // minimum vertex index
        CIRCLE_NUM_POINTS + 1, // number of vertices. If this gets an exception for you try changing it to 0. Seems to work just as well.
        0, // first index element to read
        CIRCLE_NUM_POINTS); // number of primitives to draw

to…

device.DrawIndexedPrimitives(
    PrimitiveType.LineStrip,
        0, // vertex buffer offset to add to each element of the index buffer
        0, // minimum vertex index
        0, // number of vertices. If this gets an exception for you try changing it to 0. Seems to work just as well.
        0, // first index element to read
        CIRCLE_NUM_POINTS); // number of primitives to draw

…will probably solve the problem (much like the solution Ultrahead found with my original code). The “number of vertices” parameter seems to be quite optional. Zero works fine for me too.  Kinda bugs me though. I hate this uncertainty.

Meanwhile, I should really get on with Part 2 of the tutorial, perhaps even some Battlefield 2142…  ;)

Average Rating: 4.7 out of 5 based on 217 user reviews.

8 Responses to “”

  1. Ultrahead Says:

    “Zero works fine for mee too” … Funny: I also used “CIRCLE_NUM_POINTS” to set the ‘number of vertices’ parameter and it worked.

  2. Ultrahead Says:

    Downloaded and tested: “CIRCLE_NUM_POINTS + 1″ works ok … :)

  3. Sharky Says:

    Good to hear. Thanks for the feedback.

    I can’t remember where exactly, but in the XNA help I saw a statement suggesting that the parameter is for optimization in some way.

    So Zero seems fine, but perhaps it is sub-optimal!

    I’m glad that “CIRCLE_NUM_POINTS + 1″ is working then. Best of both worlds I guess.

    ;)

  4. dastle Says:

    Hey, your collision detection tutorial is quite neat. I’ve been wanting to add the ability to do collision detection for bones in my animation library, and was wondering if I could get permission to use some of your code.

    Thanks!

  5. Sharky Says:

    Absolutely! By all means, go for it! I have no problems with anyone using any code or snippets published on this blog. Feel free to change it too.

    If you plan to share your code too, I suppose a courtesy code comment with a link to my blog would be nice – but only if you are feeling super generous.

    ;)

    I figure I’ve left plenty of room for improvement.

    Actually, I’m tempted to make more of a reusable component out of it, so it’s a bit more plug-and-play for people.

    Thanks!

  6. dastle Says:

    Thanks, I’ll be sure to add a shout-out if I can successfully incorporate it.

    My project is at http://www.codeplex.com/animationcomponents, and since it’s a pretty ambitious undertaking, it may be a bit before I can get collisions working.

  7. dastle Says:

    Oh yeah, if you are in the mood to spend a lot of time on it and think others can help, I might even suggest turning it into a codeplex project.

  8. Sharky Says:

    cool.

Leave a Reply