collision detection with lots of objects - c#

I have around several hundreds of moving objects within screen at the given time, plus a thousand+ stationary objects. For simplicity, you can think of it as a billiard game with damn lots of balls :) Some of them are stayin still, some others are moving at all sorts of speeds to all sorts of different directions. I need coll detection each time each ball bumps into another ball. What is the best method, considering performance and, well, programming simplicity? I'm talking algorithm only, I guess I can implement it myself, tho suggestions on implementation are welcome as well ;)
Language is C#, XNA 3.1, 2D graphics, target platform is Windows only (if that matters). Thanks in advance for your help!

You might want to take a look at the answers to this question.

Related

Unity3d temperature simulation

I'm writing a monster AI that has some aspects of group mentality for my game. My first question is what would be the best way to make a heatmap in unity for migration patterns and such. I can figure out lots of things on my own, but I would like some steering in the right direction.
Basically, I need a perlin-noise-esque map with hot/cold based on location and season that has fluctuations between different hot and cold zones over time. I don't know if there's a way to do this with just prelin noise, since all I've seen it do is random 2D maps. Any help would be appreciated.
Oh, and I prefer any code in c#, but it's not a necessity.

C# XNA: AI Engine?

I'm developing a game with zombie running around in a swamp. I want AIs to have functionality like "chase this target" or "run away". A major stumbling block is pathfinding. Is there a good pathfinding/AI engine in XNA, or should I roll my own?
Does anyone have any experience with this: http://www.codeplex.com/simpleAI?
you may want to look for A-Star algorithms... here is an article that talks about it in the context of a winform, but mentions XNA.
Roll your own! Seriously.
I take it you're making this game as much for the enjoyment of coding, as you are hoping for fame and riches? Pathfinding is one of the staples of AI, and is a well studied and documented topic. It is an excellent introduction to a field you'll need knowledge of in future game endeavours.
The A* Algorithm (as mentioned by others) is the standard solution to this problem - but try other approaches: line-of-sight, scripted movement, flocking... often you can derive interesting behaviour from combining a few techniques.
For a book on the subject, try AI For Game Developers - not the best in the field, but certainly an accessible introduction for the lay-coder.
Have fun mucking about with the zombies!
http://xnapathfindinglib.codeplex.com/
http://swampthingtom.blogspot.com/2007/07/pathfinding-sample-using.html
To everyone that's suggesting A*: you generally wouldn't put vanilla A* into a game. There are a lot of improvements and extensions for A* including (but not limited to) IDA* and transposition tables, that improve performance with A*-based search.
You might want to use a library to get you started but you may ultimately benefit more from your own custom implementation, using your own data types native to your app, instead of having to marshall data back and forth. But you'll need to profile to be sure.
The XNA Creators club has samples for Chase and Evade and Flocking.
I've just started down the path, but they seem to have some good resources on the creators.xna site.
I'll be using some pathfinding logic in my game, the A* Algorithm seems to be the winner for me.

Transition from 2D to 3D later in game development

I'd like to work on a game, but for rapidly prototyping it, I'd like to keep it as simple as possible, so I'd do everything in top-down 2D in GDI+ and WinForms (hey, I like them!), so I can concentrate on the logic and architecture of the game itself.
I thinking about having the whole game logic (server) in one assembly, where the WinForms app would be a client to that game, and if/when the time is right, I'd write a 3D client.
I am tempted to use XNA, but I haven't really looked into it, so I don't know if it won't take too much time getting up to speed - I really don't want to spent much time doing other stuff than the game logic, at least while I have the inspiration. But I wouldn't have to abandon everything and transfer to new platform when transitioning from 2D to 3D.
Another idea is just to get over it and learn XNA/Unity/SDL/something at least to that level so I can make the same 2D version as I could in GDI+, and I won't have to worry about switching frameworks anymore.
Let's just say that the game is the kind where you watch a dude from behind, you run around the gameworld and interact with objects. So the bird's eye perspective could be doable for now.
Thanks.
You should really just bite the bullet and take a look at one of the frameworks you mentioned.
SDL is pretty good, but honestly, if you want to just get down to writing your game, XNA is incredible.
If you are already experienced in C#, you could follow the on-line tutorials, but picking up just a single book on XNA is enough to really get you going.
This too long for a comment but... Your game physics world should pretty much be independent of the type of view you're using to see it. As an example, it's not uncommon for RTS (like say Warcraft III) to offer both a 3D view and a "mini map". If you think about it, Warcraft 1 that was 2D isn't that different from Warcraft 3 (which is fake 3D, but represented using real 3D).
Another example, you're talking about watching some character walking: it's not unlike CounterStrike (well, in CS you are the dude but anyway), where you have both your 3D view and also a minimap. And gameplay aside, I sure can walk around "Dust" (one of the most famous CS map) using only my minimap: I don't need the 3D view to walk around (now of course to aim I can't use the minimap).
In a lot of game the "physics world" is not the same as the "3D world": otherwise people with different configs wouldn't be able to play in a network game.
Another CounterStrike example: I had a really old crappy celeron with a crappy graphic card that was barely enough to run the game, so I modded the game to use "low polygons" models for the characters (this greatly enhanced the rendering speed and hence made the game very playable on my crappy config). And I still could play networked. Why? Because changing the view world doesn't change the physics world.
So the "view" really shouldn't be influencing too much your model because the view is a detail. Now of course you have to somehow decide on what you want: but if the "dude" you mentioned could be followed using a 2D top-down view as well as an isometric view as well as an "FPS-like" 3D view, then by all mean model your "physics" in a way that is completely unrelated to the view. That way you'll be able to start with something simple: 2D view, using pixels (like a CounterStrike or a Warcraft 3 minimap). And later on you can start adding a 3D view.
Now the kind of world you need to use depends on what you want: heck, there are both "2D physics / 3D view games", "3D physics / 2D view games", "2D physics / 2.5D view games" (GIYF if you don't know about the '2.5D' term in videogame development), etc.
My point is: the view is unrelated to the model/physics (once again, otherwise people couldn't be playing networked game of CounterStrike or Warcraft).
I'm not a game programmer, but I know that the difference between modeling physics problems in 2D and 3D is huge.
I agree that it's a good idea to start with 2D, but don't expect to be able to reuse much of that code in the 3D version. 3D is a different animal.

Calculate forces on a box

Story: I am developing a construction tool for wooden boxes. A box consists of a set of boards, each board is represented as 3 3D-vectors, and one placement vector. Each box is visualized using OpenGL.
Now, these boxes will be moved around with forklifts, which will apply some forces on them. I would like to calculate the forces on each board in the box, such that I can see if a given construction is stronger than another, if any board is stressed too much etc.
How should I attack this problem? Are there libraries available I can use? Which books should I read to guide me on this? Can I use existing CAD tools to do the physics experiments?
I am using C# to compute everything, but this is not a requirement (though it would be nice).
Edit: What about libraries such as ODE and Bullet? Won't they be able to answer my question?
Before you can implement any computational devices here, you need some modelling. The problem of forces and stresses over a problem like this, with changing set-ups is a very complex one. What you do in Civil Engineering normally is modelling the building (or in this case the box) and use a finite element program to calculate stresses and forces. You need to make assumptions regarding the resistance of the materials.
In short, get a Civil Engineer or someone very knowledgeable in material physics to help you.
I second tekBlues' answer; you need a real civil engineer to work with on this. In particular, ODE and Bullet cannot help you. Both are designed around the physics simulation needs of video games: simulating the movement of unbreakable rigid bodies composed of primitive shapes very quickly. How they do this is only vaguely related to the workings of Newtonian mechanics. In particular, they don't keep track of forces propagating through a system of objects in any way that's useful to you.
I'm sure software packages exist to do this sort of thing, but I'm not personally familiar with any. Again, you need someone with experience doing engineering simulations.

Newbie at XNA, general questions

As the title points out, I'm relatively new at XNA. However, I've been given a trivial assignment by my boss to see if I can get it done. I have no doubt that I eventually will, but some pointers in the right direction would help.
This isn't a homework assignment, and I'm just looking for a couple of tips and pointers so I don't have to dig too deep into all the documentation just yet ;)
How would I go about adding camera viewpoints to my project?
What would be the best way to handle user input (keyboard in this case)
Best practices/commonly used methods for detecting collision detection between two objects?
Also I must note that I'm coming from a C++ background, and C# is fairly new to me (although I've done some small projects, such as this one, before). Any help on the transition process between those two languages is appreciated as well.
Well, without knowing anything about your project (2D or 3D, for example), I can only point you in the direction of some websites where you can easily find specific information on these topics. Check out this previous question about good XNA blogs, because most of the websites listed there will be good places for you to search for information on whatever you are trying to do (with lots of examples).
As far as moving from C++ to C#, here are a couple resources that might help you with that:
C++ -> C#: What You Need to Know to Move from C++ to C#
C# FAQ for C++ programmers
check out this simple 3d tutorial, access to the different chapters is in the menu bar on the right.
http://www.riemers.net/eng/Tutorials/XNA/Csharp/series1.php
it has simple terrain, keyboard, and camera angle information, all in full code and it takes about 2 hours to get through the whole thing. enjoy

Categories