File Exchange

image thumbnail

Doom 1.3

version (4.36 KB) by Joerg Buchholz
Fly through a 3D scene like in a first-person shooter in god mode


Updated 20 Dec 2005

View License

Editor's Note: This file was a File Exchange Pick of the Week

Does the key combination WASD sound familiar to you? Did you ever look over the shoulder of your half-grown son, when he played his latest ego-shooter? Would you expect him to intuitively explore 3D data in Matlab much faster than you could ever do - with your good old 'zoom', 'pan', and 'rotate' buttons?

The next-generation engineer will use the 3D control scheme he has grown up with:

Mouse : Look up/down/left/right

'w' : Move forward
's' : Move backward
'a' : Move left
'd' : Move right
'Space' : Move up
'Ctrl' : Move down
'Shift' : Accelerate movement
'm' : Toggle up/down
'q' : Toggle mouse motion capture
'Esc' : Close figure

z = peaks;
surf (z)
axis off

Cite As

Joerg Buchholz (2021). Doom 1.3 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (20)



Thank you for the reply Joerg! The "q" key was helpful.
Widening the FOV made a great improvement: camva(30).
I also went in the code and modified a few parameters to make it more smooth for me: angle_step=5e-5, step_size=0.05, acceleration=30.
Great work!

Joerg Buchholz

Anael, I cannot currently check this under OSX. Did you try to press "q" twice before you move your mouse? What happens with very small mouse movements? Do you see the 3D object move?


Sounds great! But my axes disappear (or shift away?) as soon as i drag the mouse into the figure. It becomes an empty grey window...
P.S. using OSX with Windows keyboard config in matlab.

Danny Sale

As a "next generation" engineer who has grown up with this scheme, I found this the most intuitive way to visualize 3D objects. Excellent work and a very creative idea. Thank you!


Great work!
Another key to rotate the camera around its principal axis would be pretty awesome!

Kenneth Eaton


Did you fail to notice that this was a Pick of the Week? It would seem to make you look bad to give it such a poor rating, especially with no explanation why. John at least tried it out and had good critiques, which the author then incorporated into his code (to his credit).

Reza Zahiri Azar

Nice function. It would have been nice to include rotation as well.


Francesco Pilla


Jörg Buchholz

There is a German paper called "Matlab Goes doom" ( throwing a bit of light upon the mathematical background of doom...

Jörg Buchholz

Marc, thanks alot for the drawnow idea. I implemeted it in version 1.3 and uploaded it.

John, thank you for your helpful problem analysis. Could you please try out version 1.3 ("will be published within the next 2-3 business days.") and tell me if your problem persists?

If you cannot reach me via (because your mail server is not RFC 2821 compliant) should accept mail from your server.

One more question: Why does ALT-TAB not work for you to make the figure window active?


Marc Lätzel

I had also problems with touching the mouse and the whole window froze, adding a
drawnow (or a disp(' ')) at the end of the mouse_moved function helped.

John D'Errico

Joerg - I tried to respond to your e-mail, but it bounces
with the error: Client host rejected: Access denied.

I've also tried doom with many different variations of mouse sensitivity, but any touch of the mouse causes unrecoverable problems. And I can't make the figure window active without mousing onto it. Only if the mouse
cursor randomly happens to lie in the space of the figure
when created, then I click the mouse button with absolutely no mouse movement does doom work, and then just barely (way too slow). One touch of the mouse at any time and doom lives up to its name, even at the absolute minimum mouse sensitivity.

Jörg Buchholz

thank you very much for your improvement suggestion. I just implemented an initial "bring the figure into focus" into version 1.2 and uploaded it, so it "will be published within the next 2-3 business days."

Workaround until then: Whenever the mouse cursor is outside the figure you can press "q" twice to position it into the center of the figure. (And you can always use ALT-TAB to bring the figure into focus.)

John D'Errico

I fail to see what is so impressive here. Its not at all easy to use, way too sensitive to the mouse. Since I need to mouse into the window to bring the figure into focus, as soon as I do, the axes disappear completely out of the figure window. Once this happens, the figure appears to be irretrievably lost.

Jörg Buchholz

it's on my to-do-list...

Terry Eldridge

Wow! This makes analyzing 3D plots I've created (e.g., antenna patterns, refracting RF rays) much faster! Thanks!

Now for a request: is there a way you might be able to incorporate a rotation command about the camera location (possibly through another 'toggle' button which lets the mouse movement control the rotation)? You mentioned in your description 'zoom', 'pan' and 'rotate', and now I'm hoping you can include the 'rotate'part!

- -

It doesn't work for MATLABR11 :(

Jörg Buchholz


a mouse capture toggle key is a helpful suggestion; I just implemented it and uploaded version 1.1.

But I do not have the slightest idea how to get the information from Matlab that the user pressed 'a' and 's' simultaneously.


Jean-Yves Tinevez

Works great and fun. Easy to edit (to translate to french keyborad e.g.) and well documented. Would it be possible to be able to account for the pressing of 2 keys simultaneously ? E.g. strafe left + move backward. A key to switch mouse capture on/off would also be a plus.

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!