Archived

This topic is now archived and is closed to further replies.

benryves

Gloom and Doom: Doom-style Clipping

Recommended Posts

benryves    1999
I''m working on a Doom-Esque engine in DirectX 8: Floors must be flat, walls can only go upright &c. It''s not doing to badly, but I''ve hit one big obstacle: clipping. I can tell if I''ve hit a wall, that''s easy enough. However, if I want to slide along a wall, what do I do? So far, if I hit a wall, I then check the new X component first and if that works move to that new X: I then try the new Y coord and if that works use that value. It works fine with orthogonal walls, yes, but not with walls at an angle: can anyone help? It''s being written in (don''t laugh) Visual Basic 6. If you want to see a "demo", then download one from: http://www.silver2.net/~nindoja/calc83plus/EngineDemo.zip It''s about 600k so far.

Share this post


Link to post
Share on other sites
emptyhead    178
Very nice demo!

Just project you velocity vector to the plane of the wall, and you will have correct sliding for all types of walls.

V''=V+N*t
t=(V.N)/(N.N)


V = the velocity vector
V''= the new velocity
N = the normal to the wall
(. = the dot product)

Hope that helps




:wq!

Share this post


Link to post
Share on other sites
benryves    1999
Sounds like a good idea... I'll try it tonight when I get back to my PC.

Just as an indication, what system specs do you have, and hence what sort of frame rate?
I get 60FPS (max on my monitor), at 1280x1024 with a P4 2.4GHz & a Radeon9000 64MB.

[edited by - benryves on September 4, 2003 7:30:55 AM]

Share this post


Link to post
Share on other sites
benryves    1999
Now onto another post (sorry)... but each vector (such as the wall normal, velocity &c) has a .x, .y and .z component. However, the DirectX formulae for dot product returns a Single.

Do I use that dot product and use it against the .x, .y and .z separately?

Share this post


Link to post
Share on other sites
OneBitWonder    122
quote:
Just as an indication, what system specs do you have, and hence what sort of frame rate?
I get 60FPS (max on my monitor), at 1280x1024 with a P4 2.4GHz & a Radeon9000 64MB


Do you have v-sync enabled? If you do you might want to disable it so you can see how fast it can "really" go.

Share this post


Link to post
Share on other sites
benryves    1999
Okay, new question: how do you calculate the normal of the wall? It only needs to use "D3DVERTEX2", seeing as all it has is a ".x1,.y1" and a ".x2,.y2" (walls are flat-topped).

I''ve never known how dot or cross products really work, and so cannot really fully understand the maths behind it (a sin, I know).

Share this post


Link to post
Share on other sites
benryves    1999
Okay: New approach! Seeing as I couldn''t work it out, I devised a new approach: work out the "slope" of a wall, by doing an "x1-x2" for the x component and a "y1-y2" for the y component, then normalising them and multiplying those to my existing x and y "moving" vector.

Ok, I need to flip the x or y from time to time to ensure that the X component is facing the X direction (and the same for the Y), else I''d slip backwards up the wall.

This works brilliantly for single walls, and gives great results. The only problem is with "double-hit" walls, such as:


__
/|
__/_____
|/------
/|
/||
||



There are two walls there, the arrow shows the direction of movement: my collision detection detects 2 hit walls. For some reason, this makes me "lock" onto the corner. Any ideas?

Share this post


Link to post
Share on other sites