Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Mogthew

Member Since 20 Feb 2007
Offline Last Active Apr 24 2012 07:31 PM

Posts I've Made

In Topic: Quaternion Object Rotation

17 March 2012 - 01:56 AM

How do you render the objects - are you converting them back into Euler angles and then using glRotatef with them? AFAIK your general idea is correct, if you want to represent a bunch of rotations, you make them, and then combine then (and you're right, order matters).

I think that the order you multiply them by should be the same order as the one you render them in, for example if you're multipling x * y * z, then when you convert to Euler angles you should rotate around the X axis, then Y then z.

I'm still trying to get my head around Quaternions, but I _think_ this is correct. It's how they're being represented in my game at the moment anyway, and I'm doing a space themed game too ;p

In Topic: Super fast collision detection

14 December 2010 - 11:37 AM

Yes, all ships have the same width / height, which makes this work. I'm not entirely sure how you manage to do "one comparison per object if you're lucky", how is this achieved? The sorting doesnt take too long, the memory is initialized at start up and then only modified at a later time, it's not created or deleted.

Again, the code you posted is specific to check for object vs object collisions, there's nothing there that shows how to cull the object collision pairs down.

Could you explain further?

In Topic: Super fast collision detection

09 December 2010 - 10:33 AM

Quote:
Original post by Atrix256
"As for the vsync, that's a good point, i'd not thought of that. Most systems these days use LCD's so yeah. Maybe 60fps should be my goal. "

For the record vsync existed before LCD's, there's nothing special about LCD's and vsync... it was on CRT's too :P


Haha, I know that :p My point was simply that LCD's have a default VSYNC of 60. whereas CRT's where higher, and therefore 60fps should be perfectly sufficient.

@Net-Ninja,

I didn't realise you could do that (with the sqrt) but I've been using the separate axis idea for a bit.

The current operation works like this:

Sort the list of ships by their X values.
Get a bullet.
Get the index of the minimum X value, using a binary search, that will collide with the bullet
Get the index of the maximum X value, using a binary search, that will collide with the bullet

Using the two indices in the array, do a brute force comparison between the two array indices

Code looks like this:

double width = baddies[0].getClipBoundsWidth();
double height = baddies[1].getClipBoundsHeight();


int xMinIndex = BSearch.min(xSort, (int)locationX, (int)width);
int xMaxIndex = BSearch.max(xSort, (int)locationX, (int)width);

if(xMinIndex == -1)
return null;
if(xMaxIndex < 0)
xMaxIndex = xMinIndex;

//System.out.println("Searching between " + xMinIndex + " and " + xMaxIndex);

for(int x = xMinIndex;x <= xMaxIndex;++x)
{
if(baddies[xPtrs[x]].dgetY() + width > locationY && baddies[xPtrs[x]].dgetY() - width < locationY)
{
return baddies[xPtrs[x]];
}
}


return null;


FYI: I use java to do spikes, if they look promising I port them into my game. I have a simple framework set up to do tests on multiple different collisions detection schemes and report the results.

Also, I found that the collision detection like this was bound by calls to getX() and getY(), so I extracted the xvalues into an array (which is what the bsearch operates on).

In Topic: Super fast collision detection

07 December 2010 - 04:08 PM

Hmm, alot of excellent suggestions. I'll definitely go and look at either setting up a grid or making some sort of tree.

As for the vsync, that's a good point, i'd not thought of that. Most systems these days use LCD's so yeah. Maybe 60fps should be my goal.

I've considered grids and spatial hashing, but haven't tried to implement. That'll be my goal now I think.

Thanks for all the suggestions, I should be able to get where I want to go now :D

In Topic: Super fast collision detection

07 December 2010 - 03:46 PM

I probably should've mentioned, but it's for a 2d game. Can you still use a binary space partition for 2d stuff?

My knowledge of BSP tree's is veery limited, but if it's the next step I guess I don't have much choice.

EDIT: In this game, there's no closed areas. It's totally open, basically a gigantic flat area. Are BSP tree's still applicable?

PARTNERS