Jump to content
  • Advertisement
  • entries
    743
  • comments
    1924
  • views
    584148

Collision Detection

Sign in to follow this  
Aardvajk

168 views

Collision detection is now working flawlessly. Here is a new demo. The player slides very nicely along walls at any angle now.

The trick was to seperate out the X and Z movement into single steps, which was pretty trivial, so I could do the same style of collision response I've used in 2D games in the past. I believe this is called "seperated axis" collision response or something. Who cares. It works really well.

I'm starting to think about writing some kind of editor to put single horizontal plane levels together. There really is no need to be restricted to orthagonal tiles (ooh, get me using the posh words [smile]) any more.

I figure I could put together levels consisting of arbitrary rectangular shapes on the horizontal plane that could even be extended upwards to arbitrary heights, then maintain a vector of the horizontal rectangle areas for fast searching. The collision system I've developed tonight would work just as well with a vector of arbitrary rectangles as it would with a grid-based map (better in some ways, since anchoring to walls on collision would be simpler) and would allow for very flexible environments within the single plane constraint.

Probably have to write the editor with Direct3D so will have to roll out some kind of simple GUI. Actually, the next thing I really need to suss out is how to draw flat GUI elements on top of a 3D screen, which I guess will just be a case of rendering quads but setting the projection matrix up differently first or something. I'll figure it out.

I'm aware there are probably perfectly good free third party editors available, but I find there is nothing like projects like these to cement my understanding of stuff.

So no screenys tonight, since there have been no graphical changes to last nights progress. If you need a screeny fix, may I heartily recommend Milkshake's journal since the graphics are gorgeous and there is some very innovative stuff going on over there at the moment with some very ambitious procedurally generated environments.

That is all (for now).

[EDIT] So I lied about screenshots.



I decided to have a quad per floor tile instead of one big texture for the floor. I've also added a ceiling and changed the fog colour to black. Don't know why really. Just messing about.
Sign in to follow this  


4 Comments


Recommended Comments

I'm not going to spoil the surprise, but on drawing "2D" images onto the screen, here's a small tip : D3DXMatrixOrtho... (or, consequentely, leave the projection matrix out). Also, ID3DXSprite exists to take care of all things orthogonal.

Looking good too. To me, the black fog kinda looks like the player is carrying a lantern.

Share this comment


Link to comment
Cheers. I thought I remembered something about orthagonal projections. I guess I need to disable z-testing as well for that. I'll have a play about with that later. Want to try to get a crosshair up first as a nice simple experiment.

Regarding lanterns, I like how simple all this lighting stuff seems with Direct3D. I've only used directional lights so far, but I'm guessing that if I created a point light and kept moving it to the player's position every frame, then disabled the directional light, it would actually be like the player was carrying a lantern.

Groovy.

[EDIT] Actually, that doesn't seem to work too good. The point light seems to light stuff on a vertex basis, so the light pattern is sort of blocky and looks weird when you move. It also appears to travel straight though the geometry.

Guess I was expecting quite a lot really. [smile]

Share this comment


Link to comment
Quote:
Original post by EasilyConfused
Actually, that doesn't seem to work too good. The point light seems to light stuff on a vertex basis, so the light pattern is sort of blocky and looks weird when you move. It also appears to travel straight though the geometry.

Guess I was expecting quite a lot really. [smile]


Yeah, the D3D lights are vertex-based and don't take occlusion into account. If you want a nicer solution, you're almost certainly going to have to roll out your own lighting system. If you want to avoid shaders and remain in the realm of vertex-based lighting, then it's mostly a matter of tesselating your tiles (ie. one quad currently should be made of 4 or 12 quads) and doing some fairly simple calculations per vertex to figure out brightness against a given light. Since you're using a tile-based map format, checking for occluded objects shouldn't be too too bad. All of that said, I haven't tried it myself yet. I'll let you know how dynamic lights go on my end. [smile]

Share this comment


Link to comment
Quote:
Original post by HopeDagger
Quote:
Original post by EasilyConfused
Actually, that doesn't seem to work too good. The point light seems to light stuff on a vertex basis, so the light pattern is sort of blocky and looks weird when you move. It also appears to travel straight though the geometry.

Guess I was expecting quite a lot really. [smile]


Yeah, the D3D lights are vertex-based and don't take occlusion into account. If you want a nicer solution, you're almost certainly going to have to roll out your own lighting system. If you want to avoid shaders and remain in the realm of vertex-based lighting, then it's mostly a matter of tesselating your tiles (ie. one quad currently should be made of 4 or 12 quads) and doing some fairly simple calculations per vertex to figure out brightness against a given light. Since you're using a tile-based map format, checking for occluded objects shouldn't be too too bad. All of that said, I haven't tried it myself yet. I'll let you know how dynamic lights go on my end. [smile]


Yeah, I guess I can sort of see how you could roll your own lighting system out like that. I'm not really worried to be honest. Just thought the built in light might be a free effect.

I reckon I'm going to write either a single horizontal plane dungeon game or a flying around in space game first. I like the space game idea in some ways since the environments are simple and collision detection can just be distance based.

Share this comment


Link to comment

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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!