#### Archived

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

# Gloom and Doom: Doom-style Clipping

This topic is 5371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 on other sites
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 on other sites
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 on other sites
H''mmm... well, I understand what it is that it will do, but I cannot work out how to implement that in VB.

Any bright ideas?

##### Share on other sites
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 on other sites
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 on other sites
At 320x200 it goes up to 300FPS in windowed mode.
It peaks at about 59/60 fps at 1280x1024.

##### Share on other sites
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 on other sites
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?

• 10
• 18
• 14
• 18
• 15