"Beam" weapon question

Started by
9 comments, last by helix 21 years, 7 months ago
I''m doing a FPS style demo and I want to have a laser beam looking weapon effect. I am creating a ID3DXMesh using the function D3DXCreateCylinder. First of all, does this sound reasonable so far? Second, I''m wondering how to do the positioning. How do you position the start and end points for a beam like this that you want to travel in the direction the camera is aiming so it looks good from the player''s point of view? Currently, it looks pretty bad. Here''s what I am doing for the start and end point: D3DXVECTOR3 pos = m_pCamera->GetPos(); D3DXVECTOR3 end = pos + (m_pCamera->GetDir() * INFINITY); Basically, the camera''s position for the start and the camera''s direction scaled to "infinity" (a large number so the beam will be longer than the room) added to the start position. Sound good? I guess I''m just curious if anyone has moved the ray down and over a few units or something like that to make it look better.
Advertisement
Might want to move it down like you said. Right now it might look like it''s coming out of your own eyes like superman''s heat vision.
-Madgap
Yeah, my only concern is that collisions along that beam may not appear to be accurate if I move the starting position for the effect away from the real starting pos.
I think if you move the beam down just enough so it doesn''t screw up the view, it won''t look so far off in the distance where it is striking objects, so it shouldn''t matter.

You might only need to move it a few inches by scale, which doesn''t make a lot of difference when you are firing at objects 40 feet away.

Give it a try, see how it turns out, and tweak it.
It's not what you're taught, it's what you learn.
I moved it down slightly and yeah, it does look a lot better. I''ll know if it''s going to work once I fix a few bugs. :D
got any sort of demo? this sounds interesting!

--SuperRoy

[ www.Google.com ][ FlipCode IOTD ]
[ Email Me ][ WhitespaceUnlimited ]
Sup guys?
Well, I have one big bug to fix before it''s presentable. I''ll post a link or I can email you the url when it''s done.

I''m proud of it because I didn''t know anything about directx before I started.
Well, I have to work on a specific demo to send to a prospective employer so I won''t be able to finish this one as soon as I had hoped. So I''ll post what I have for now for those who are interested.

http://www.users.qwest.net/~beoch/demo-2.4.zip
You linked with the debug libs (d3dx8d.lib) so it wouldn''t run. Something to keep in mind, not everyone has the debug version installed.

But you did include the source so I recompiled.

Problems I found:
If you flip upside down, the left and right get reversed...
also firing up or down the beam is messed up...I think it''s cause you just move the starting point down and don''t rotate that point with the view...Didn''t look at the code to confirm this.
Looks like you tried to make a swirl effect around the beam, but it doesn''t follow it, don''t know how to explain it...looks like it''s coming out of your eyes sometimes.

Good job for one of your first DX apps.

My specs in case you want to know..
P4 @ 1.9ghz
Windows XP pro
512 megs of ram
Geforce3


hmm, that''s wierd about the debug lib, I thought I had the release version installed. That would explain some things... Thanks for pointing that out.

I plan on limiting your movement so you can''t flip over. And the weapon is the unfinished part of my demo. I haven''t gotten that working quite right yet... Thanks for the comments.

This topic is closed to new replies.

Advertisement