Can people please let me know (via blog comments) if they are having problems with either…
- my latest “Air Legends” release?
- 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…
January 30th, 2007 at 12:18 am
“Zero works fine for mee too” … Funny: I also used “CIRCLE_NUM_POINTS” to set the ‘number of vertices’ parameter and it worked.
January 30th, 2007 at 12:22 am
Downloaded and tested: “CIRCLE_NUM_POINTS + 1″ works ok …
January 30th, 2007 at 3:32 am
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.
January 30th, 2007 at 12:42 pm
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!
January 30th, 2007 at 2:44 pm
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!
January 31st, 2007 at 5:29 am
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.
January 31st, 2007 at 5:30 am
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.
January 31st, 2007 at 7:00 am
cool.