Sign in to follow this  
pascalosti

c# xna data structures

Recommended Posts

pascalosti    100
I'm not familiar with a scene graph. but here is what im doing:

I want to load a bunch of points that are connected with lines. Then later on there will be some path finding from start point to end point.


Here are 2 I found, but found very difficutl to implement.
http://msdn2.microsoft.com/en-us/library/aa289152(VS.71).aspx

http://www.ziggyware.com/readarticle.php?article_id=130

Share this post


Link to post
Share on other sites
pascalosti    100
I have thought about using List<> but it doesnt take long for it to become a mess.


1: Starting with root, Add all the points to a List<point>

2: create an index (one number for each point)
3: for each point add all lines connected with List<line>
for each line store 2 points it connects to (using index number)

Here it gets messy (travesing)
4: starting with root, check first line -> child point -> first line -> child etc until there are no more children or you hit the destination.
If I hit destination store(Points,length total)

Some of the lines and points should be set to false, but more then likely other children and lines will be using them.

what the graph will likely look like
http://www.leda-tutorial.org/en/unofficial/Pictures/SaarlandAndDual.png

Share this post


Link to post
Share on other sites
TheTroll    883
Reading the site how to make the graph but the baseball game is on and it is late, I will try to read the site when I get up and see if I can come up with something. I have an idea but need to make sure it will work.

theTroll

Share this post


Link to post
Share on other sites
pascalosti    100
I first collect all points (vector2) on the map, make all the points connect with a line. (both stored in seperate List<>'s)

I then collect all the obsticals (squares / four lines). check if any of the of the point lines collide with the obstical lines if yes mark line as false.

draw all the lines that are still true.

thats as far as i got.

Share this post


Link to post
Share on other sites
TheTroll    883
So first we get all points.

Next we connect ALL points with a line?

Then we start deleting the lines where they cross?

Do I have that correct?

theTroll

Share this post


Link to post
Share on other sites
pascalosti    100
http://www.codeplex.com/quickgraph

Im currently trying to get familierized with this library. So you dont have to go on (for now anyways).

But i am still curious what your idea was.


What the graph may look like
Example
objects on the map
4 nodes, (vector2 x, y is being used).

2 obstacles, squares (vectore2 x, y, plus width and height being used)

I now have List<objects>
index 0 nodes index 1 obstacles

Create lines
Run 2 loops for nodes
List<List<line>>[0]add()
// every possible pair of nodes, i only record the vector2's,
//node isnt connected at this time with the line

// do the same with obstacles, each obstacle is made up of 4 lines

// do a collision test, each nodeline against each obstacle
// once a hit is detected the nodeline is made false.

print all the node and squares
print all the nodelines

(and again you dont have to do this, either way thanks for your help)

Share this post


Link to post
Share on other sites
TheTroll    883
My idea was to create a class called Saarland. In the class I would have a vector2 for it's location, it would also have a List<Sarrland> to hold all the ones it was connected to.

You then have a List<Saarland> as your master list. This should give you the ability to do all that you need to do.

theTroll

Share this post


Link to post
Share on other sites
TheTroll    883
Member functions you will most likely need.

AddSaarland(Saarland saar) Adds another Saarland to the list of points to connect to.
AddSaarland(Vector2 point) Adds another Saarland to the list of points to connect to.

RemoveSaarland(Saarland ssar)
RemoveSaarland(Vector2 point)

Overload the ==, != and Equal operators.

DrawLines()

That should be about what you need.

theTroll

Share this post


Link to post
Share on other sites

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