How to make beam light flow along with GUI's border?
by Nabarro · in Torque 3D Professional · 07/21/2010 (1:23 pm) · 3 replies
We want to make beam light flow along with the GUI's border. For example, we have made one GuiWindowCtrl object, and we want to make one shining beam light flow along with the window control's border. How to do this? Does there exist any resources can be taken for reference?
Thank you very much.
Thank you very much.
#2
As for the GuiBeamLightBorderCtrl, how to implement the rendering and animation? Could you please give some code examples here? Thank you very much.
07/22/2010 (3:16 am)
Thanks, Rene,As for the GuiBeamLightBorderCtrl, how to implement the rendering and animation? Could you please give some code examples here? Thank you very much.
#3
Depends a little on what you're after.
Simplest case is you create a texture with a beam-like gradient and then simply render the four edges of the rectangle as four sliding UV windows, i.e. you animate the X component of the texture coordinates to slide over the texture and thus give the impression of animation. With each side starting in the texture where the last side left off, this gives you a seamless animation and the beam texture can be pretty much anything you want.
Something a little more involved could use a shader instead of a simple texture.
A wholly different solution is to bastardize the particle system for this and create a stream of particles along a rectangular path. However, I'm not too familiar with Torque's particle system so I'm not sure what it would take to get it to do that. The good thing about a particle solution is that you could do all sorts of nice animation effects this way.
This is all beyond a trivial whip-it-up-in-a-second example so unfortunately you'd have to do some code digging on your own :)
For the texture-based stuff, GFX is definitely your first stop. Build a primitive array with four quads made of triangles based on your animated UV coordinates. GFXDrawUtil::drawBitmapStretchSR can serve as a template on how to do this kind of stuff.
07/22/2010 (3:35 am)
Depends a little on what you're after.
Simplest case is you create a texture with a beam-like gradient and then simply render the four edges of the rectangle as four sliding UV windows, i.e. you animate the X component of the texture coordinates to slide over the texture and thus give the impression of animation. With each side starting in the texture where the last side left off, this gives you a seamless animation and the beam texture can be pretty much anything you want.
Something a little more involved could use a shader instead of a simple texture.
A wholly different solution is to bastardize the particle system for this and create a stream of particles along a rectangular path. However, I'm not too familiar with Torque's particle system so I'm not sure what it would take to get it to do that. The good thing about a particle solution is that you could do all sorts of nice animation effects this way.
This is all beyond a trivial whip-it-up-in-a-second example so unfortunately you'd have to do some code digging on your own :)
For the texture-based stuff, GFX is definitely your first stop. Build a primitive array with four quads made of triangles based on your animated UV coordinates. GFXDrawUtil::drawBitmapStretchSR can serve as a template on how to do this kind of stuff.
Associate Rene Damm
Interesting problem.
Cheapest solution might be to get away with some texture-based animation, but personally, what I would maybe do here is create a new GuiBeamLightBorderCtrl class and implement the animation and rendering in code and then simply make an object of this class the child of a GuiWindowCtrl so it renders over the border of the window.
If the clip rect of the GuiWindowCtrl becomes a problem (i.e. you want to render outside the area of the GuiWindowCtrl), then simply package the two classes as siblings in a GuiControl with the GuiBeamLightBorderCtrl being the second child after the window (so it gets rendered on top). Then the GuiControl can be made large enough to give more room for the effect.
Just my two cents. Maybe someone has a radically simpler solution.