Railgun effect...
Blitz3D Forums/Blitz3D Programming/Railgun effect...
| ||
This is probably a simple one, but something I need to look into anyway since off the top of my head I'm not sure what to do. Basically, what I want is code to create, from point A to point B, a railgun effect in the style of Quake III, Red Faction, etc...which feature a texturable beam. |
| ||
Are you sure you meant railgun? They only shoot a projectile, with no beam fx. I think you meant a Plasma gun? however, I think there are several methods to create this effect more or less effeciently. I don't know how they are doing this, but I would maybe try to use a string of overlapping X-quads, containing a glow texture in additional blendmode. A helper pivot could be used with some Random x/y-addition to get some kind of ziczac line from the string parts. An easier solution, that is maybe looking much better, would be to take some photos of flashes (weather) and create an animated texture with them, then use a simple geometry mesh with it. EG. a noncapped, flipmeshes cylinder. Did you check out the archives? Maybe there's already some kind of plasma beam effect there. |
| ||
Actually if you've ever played a game with a railgun (at least any I've seen), you'd see that they show a beam effect from origin to impact. However, I don't actually have a railgun in my game, but I want the traditional railgun effect for my particle beam rifle and another similar weapon. I think I may have found what I was after in the code archives, with a little tweaking. My only concern will be keeping it from getting culled when the origin is out of view... |
| ||
of course I know the gun from quake etc. I don't remember how it was called, but a real railgun works with magnetism to accelerate a projectile, no beam there, AFAIK. |
| ||
a realistic railgun in a game would be boring, as you'd see nothing but the aftereffects. Plasma, on the other hand, is nice and colorful! ;) |
| ||
In a game that I was creating I used a laser rifle that fired nice, ruby beams. While experimenting on the beams I found that I could get a beam from origin to point of impact by scaling the beam (in this case, my beam was mesh) along the z axis. |
| ||
Kevin, that's basically what I'm thinking...except I'm concerned beams that originate outside the players view (enemy snipers) won't appear cuz blitz will cull the whole mesh. I'm not sure, I'll try it out and see how it works. |
| ||
Ha HA!! Lemme have a crack at this...wish I'd seen this post sooner. It's time for bed atm. =( |
| ||
Chroma, would be interested in what you come up with ;-) |
| ||
Chroma: That's great, I'm going to try checking out the simple method right now and see if my fears are correct (not rendering beam if you can't see the source)... Edit: Well, it actually seems to render as long as any part of the beam is in the viewport! Yay... |
| ||
..except I'm concerned beams that originate outside the players view (enemy snipers) won't appear cuz blitz will cull the whole mesh Use MeshCullBox(), new to v1.98, to define a cull box that surrounds the whole mesh and it will not get culled if any part of that box is in view. |
| ||
Cool, I didn't know about that command, but now I'm not sure I need it. They seem to show up just fine even if you can't see the origin. If I notice problems later on though, I'll be sure to try that... However, that will certainly help out with my player meshes (I was having problems with that)! |
| ||
You're right, you shouldn't need MeshCullBox for static objects, as Blitz already calculates those, and recalculates them when you scale. It just doesn't calculate them on animated entities, because it can't "predict" how far your models will move away from their original pose. But when you scale an object, you're explicitly telling B3D how the bounding box will be affected and it can "make a note". |
| ||
As I see...it will be very helpful with the animated meshes in my game then. What are the parems for MeshCullBox? I've never seen it mentioned before... |
| ||
MeshCullBox mesh,x#,y#,z#,width#,height#,depth# |
| ||
Simple enough, thanks! |
| ||
One last question, I'm adding a glow sprite to the origin and impact of the beams, and I'm not sure which way would be faster: Using blitz built in sprites OR creating a quad and manually pointing it at the camera each frame. Or would both methods be about the same speed? |
| ||
Try this Orc. It's not optimized (loads the laser model everything shot hehe). I made a custom model for the beam. You can change the size of it in the CreateRG() function (X and Y axis) where it resizes the rg/mesh with ScaleMesh. (ScaleMesh rg\mesh,.7,.7,1) http://webzoom.freewebs.com/zamagames/RailGun.zip |
| ||
That's exactly the way I figured out to do it :-) Though I like your fade effect better than the alpha method I'm using...never thought to scale it down... I bet Boiled Sweets would like to take a look at this... |
| ||
An alpha fade with a really high decay rate might look cool. |
| ||
Yeah but it sticks around too long that way and you can go walking through it and stuff...doesn't look too good (it's a first person shooter BTW). I think the scaling method will look better for my purposes. |