How can you do Ray Casting in Minetest?
- Me Me and Me
- Member
- Posts: 56
- Joined: Sun Jul 03, 2016 21:08
- In-game: MeMeandMe2 Regulus
- Location: Vulcan, in the leftmost star of Orion's Belt
How can you do Ray Casting in Minetest?
Hi! I'm trying to make a beam-like gun in minetest,
and I know in some game engines you use "Ray Casting" to emit the beam.
So I was wondering, is there an easy way to do that in minetest?
Thanks, Me Me and Me.
and I know in some game engines you use "Ray Casting" to emit the beam.
So I was wondering, is there an easy way to do that in minetest?
Thanks, Me Me and Me.
I Love Formspecs!
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: How can you do Ray Casting in Minetest?
If you search for raycast lua_api, you'll see there's a function called minetest.raycast
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How can you do Ray Casting in Minetest?
Do you mean like a laser-beam? If so then that is not really what ray-casting means in game-engine terms. `minetest.raycast` is generally used to detect objects or nodes that intersect an imaginary line (or ray) which may be useful to tell if your gun has actually 'hit' anything but will not emit any kind of beam.Me Me and Me wrote:Hi! I'm trying to make a beam-like gun in minetest,
and I know in some game engines you use "Ray Casting" to emit the beam.
AFAIK it should be possible to project some sort of beam using particle effects.
- Me Me and Me
- Member
- Posts: 56
- Joined: Sun Jul 03, 2016 21:08
- In-game: MeMeandMe2 Regulus
- Location: Vulcan, in the leftmost star of Orion's Belt
Re: How can you do Ray Casting in Minetest?
Thanks stu, I'll use particles for the beam in my gun mod.stu wrote: Do you mean like a laser-beam? If so then that is not really what ray-casting means in game-engine terms. `minetest.raycast` is generally used to detect objects or nodes that intersect an imaginary line (or ray) which may be useful to tell if your gun has actually 'hit' anything but will not emit any kind of beam.
AFAIK it should be possible to project some sort of beam using particle effects.
I Love Formspecs!
Re: How can you do Ray Casting in Minetest?
particles may not work as there's no `yaw` and `pitch` value for particles, so you can't make a `line` that follows an arbitrary 3d vector. You'll have to get really smart with mesh entities to do it, or use a bajillion particles.Me Me and Me wrote:Thanks stu, I'll use particles for the beam in my gun mod.
-
- Member
- Posts: 1482
- Joined: Fri Apr 19, 2013 16:19
- GitHub: twoelk
- IRC: twoelk
- In-game: twoelk
- Location: northern Germany
Re: How can you do Ray Casting in Minetest?
no beacons possible that may guide me home from far away? - sigh, no working pharus of Alexandria then
Re: How can you do Ray Casting in Minetest?
Beacons are vertical, so you can use particles. But a beam that isn't vertical isn't easy to make with a particle.twoelk wrote:no beacons possible that may guide me home from far away? - sigh, no working pharus of Alexandria then
- sorcerykid
- Member
- Posts: 1847
- Joined: Fri Aug 26, 2016 15:36
- GitHub: sorcerykid
- In-game: Nemo
- Location: Illinois, USA
Re: How can you do Ray Casting in Minetest?
It would be great if there was a way to do light beams in Minetest, but the engine doesn't support it. Even using an entity, the beam itself won't be luminescent because only nodes can serve as light sources. There is no dynamic lighting in Minetest, only-stationary.
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How can you do Ray Casting in Minetest?
Oh, I was not aware of this limitation. I have not done much with particles and was actually thinking about how you used them for lightning, of course that is rather different to a linear directional beam.sofar wrote:particles may not work as there's no `yaw` and `pitch` value for particles, so you can't make a `line` that follows an arbitrary 3d vector. You'll have to get really smart with mesh entities to do it, or use a bajillion particles.
I still wonder if you did project enough particles continuously with the right velocity that it could appear like a straight beam due to persistence of vision. You'd have to try it I guess. And yes, doing this with entities would be very cumbersome and probably would not work too well in multiplayer.
I would also like a way to draw 3d lines in the world space that might be managed in a similar way to particles, however, I think the best we could hope for is 'glow' for the time being. I think that dynamic lighting will not be making it into MT 0.5.0 =)sorcerykid wrote:It would be great if there was a way to do light beams in Minetest, but the engine doesn't support it. Even using an entity, the beam itself won't be luminescent because only nodes can serve as light sources. There is no dynamic lighting in Minetest, only-stationary.
Re: How can you do Ray Casting in Minetest?
Particles can't emit light, but they can appear to be `lit` to max light values, which is what the lightning mod uses to make the lightning bolt appear brightly in the sky. This can be used to create effects that at least have some illusion of creating light.sorcerykid wrote:It would be great if there was a way to do light beams in Minetest, but the engine doesn't support it. Even using an entity, the beam itself won't be luminescent because only nodes can serve as light sources. There is no dynamic lighting in Minetest, only-stationary.
I then add a `fire` node at the impact site that actually does emit light. Good enough for lightning, and the method may be usable by other mods to do similar things.
Re: How can you do Ray Casting in Minetest?
Trivial with a particle generator and some simple math that calculates the proper 3d vector and puts it in velocity, and calculate the speed value such that the particles disappear right at the target. However, the amount of particles needed to get a good visual may be problematic, and cause the client to drop FPS.stu wrote: I still wonder if you did project enough particles continuously with the right velocity that it could appear like a straight beam due to persistence of vision. You'd have to try it I guess. And yes, doing this with entities would be very cumbersome and probably would not work too well in multiplayer.
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How can you do Ray Casting in Minetest?
Yeah, that's kinda what I was thinking about. In theory though, particles should be really inexpense in terms of client FPS, sadly I realise that this is not quite the case for MTE right now.sofar wrote:Trivial with a particle generator and some simple math that calculates the proper 3d vector and puts it in velocity, and calculate the speed value such that the particles disappear right at the target. However, the amount of particles needed to get a good visual may be problematic, and cause the client to drop FPS.
-
- Member
- Posts: 1482
- Joined: Fri Apr 19, 2013 16:19
- GitHub: twoelk
- IRC: twoelk
- In-game: twoelk
- Location: northern Germany
Re: How can you do Ray Casting in Minetest?
didn't irrlicht have something like spotlight?
Re: How can you do Ray Casting in Minetest?
Sorry a bit OT, but what would be your advice for having fireworks arrows light briefly the neighborhood? I'd like to use them in mines (I believe they may be better balance-wise than torch arrows). Maybe create a temporary glowing node? Can I create for instance a glowing air node or something like that?
My game? It's Minefall.
Re: How can you do Ray Casting in Minetest?
with this merge: https://github.com/minetest/minetest/pull/6072stu wrote: Yeah, that's kinda what I was thinking about. In theory though, particles should be really inexpense in terms of client FPS, sadly I realise that this is not quite the case for MTE right now.
it should be possible, likely, to do this entirely client side, which would significantly increase the amount of particles you could generate if you needed more than 1 particle spawner. And you'd get zero-latency visuals.
I tested an early CSM particle PR and easily could do 2k particles per second I think.
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: How can you do Ray Casting in Minetest?
That helps when you need to modify spawner positions a lot, but that is not the reason particles are slow in most cases. The reason is we use a scene node *per particle*. This causes a large amount of calls to the GPUsofar wrote:with this merge: https://github.com/minetest/minetest/pull/6072
it should be possible, likely, to do this entirely client side, which would significantly increase the amount of particles you could generate if you needed more than 1 particle spawner. And you'd get zero-latency visuals.
I tested an early CSM particle PR and easily could do 2k particles per second I think.
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How can you do Ray Casting in Minetest?
Well yeah, that ought to do it :D Although it does beg the question, why we don't use Irrlicht's built-in support for particle systems, IParticleSystemSceneNode & friends?rubenwardy wrote:The reason is we use a scene node *per particle*. This causes a large amount of calls to the GPU
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: How can you do Ray Casting in Minetest?
Because the pr was sloppily made and should never have been merged
Who is online
Users browsing this forum: No registered users and 11 guests