in-game radii view for triggers

Discussions about Coding and Scripting
OwYeaW
Experienced
Posts: 81
Joined: Fri Jan 09, 2015 4:24 pm

in-game radii view for triggers

Post by OwYeaW »

yo, i would like to create a function that will show all the triggers' radii (while playing the map)
Image

my plan was to set every trigger's DrawType = DT_Mesh and give them a cylindrical mesh that has their respective collision height and radius value
but to my knowledge a mesh's dimensions can only be adjusted with DrawScale, which adjusts every dimension and keeps the height/radius ratio the same
so by doing this, the mesh probably never really fits the exact radii values

i would like to know if theres a simple and effective method for this

and btw, can anyone explain me why Triggers dont show after the consolecommand "SHOWALL" ?
User avatar
Hellkeeper
Inhuman
Posts: 903
Joined: Tue Feb 25, 2014 12:32 pm
Personal rank: Soulless Automaton
Location: France
Contact:

Re: in-game radii view for triggers

Post by Hellkeeper »

OwYeaW wrote:and btw, can anyone explain me why Triggers dont show after the consolecommand "SHOWALL" ?
They do. I don't know why it doesn't work for you, put a default one and see if it works, maybe the change in DrawType messed with this?
You must construct additional pylons.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: in-game radii view for triggers

Post by JackGriffin »

I have a tool you spawn with in Unreal I simply call the "scanner". What it does is identify any movers you are currently looking at by use of a beep and a small visual bit of light and smoke at the point of the mover you are looking at. I don't like doing it this way, I think it's too crude visually. For a long time I've sought a way to render the wireframe of the mover along with the normal view of the mover but I've never figured out a way to do it. Seems like it would be simple to do since you can see wireframe with just a click in editor but that view is (as far as I know) not usable in normal play. I have a suspicion you will encounter the same issues trying to do something like this.

If anyone has any ideas how to solve this I'm happy to do the actual work for myself and Ow, since they will both be done in the same method. Is there a way to hook some of the view properties you use in editor and bring those into actual gameplay or are they just separate beasts altogether?
So long, and thanks for all the fish
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: in-game radii view for triggers

Post by Barbie »

OwYeaW wrote:can anyone explain me why Triggers dont show after the consolecommand "SHOWALL" ?
Yes, in net play they are not visible - I guess it is a matter of relevance. If you change Trigger's bAlwaysRelevant to True, they are visible.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
OwYeaW
Experienced
Posts: 81
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW »

Hellkeeper wrote:They do. I don't know why it doesn't work for you, put a default one and see if it works, maybe the change in DrawType messed with this?
Barbie wrote:Yes, in net play they are not visible - I guess it is a matter of relevance. If you change Trigger's bAlwaysRelevant to True, they are visible.
im sorry for the confusion, after experimenting with the trigger settings and the SHOWALL command, i found out that only the triggers that have TriggerType = TT_Shoot dont become visible
JackGriffin wrote:I have a tool you spawn with in Unreal I simply call the "scanner". What it does is identify any movers you are currently looking at by use of a beep and a small visual bit of light and smoke at the point of the mover you are looking at. I don't like doing it this way, I think it's too crude visually. For a long time I've sought a way to render the wireframe of the mover along with the normal view of the mover but I've never figured out a way to do it. Seems like it would be simple to do since you can see wireframe with just a click in editor but that view is (as far as I know) not usable in normal play. I have a suspicion you will encounter the same issues trying to do something like this.

If anyone has any ideas how to solve this I'm happy to do the actual work for myself and Ow, since they will both be done in the same method. Is there a way to hook some of the view properties you use in editor and bring those into actual gameplay or are they just separate beasts altogether?
nice, would be great if those editor views van be transported into the game itself
i would like to see that "scanner" from you, would be interesting to read its code
i also had the idea to make a function that shows visual clarity about movers, the best idea seemed to be to draw a wireframe on top of the mover's brush
DrawActor( Actor A, bool WireFrame, optional bool ClearZ, optional float DisplayFOV )
but the wireframe never worked
OwYeaW
Experienced
Posts: 81
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW »

2 years later, does anyone know if drawing a wireframe cylinder with an actor's collision dimensions is possible like in this image:
Image

should be possible in some way right? via the HUD yea?
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: in-game radii view for triggers

Post by PrinceOfFunky »

OwYeaW wrote: Sat Nov 23, 2019 11:11 am 2 years later, does anyone know if drawing a wireframe cylinder with an actor's collision dimensions is possible like in this image:
Image

should be possible in some way right? via the HUD yea?
Not with unrealscript, since lines cannot be drawn on the screen and even if you wanted to display a 3D mesh of a wireframe cylinder you could not stretch its height.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: in-game radii view for triggers

Post by Gustavo6046 »

PrinceOfFunky wrote: Sat Nov 23, 2019 1:54 pm lines cannot be drawn on the screen

Yes, they can! Just use Bresenham's line algorithm and single pixel textures. (See the bottom of this post for an easier way!)

You may also want to use an ellipse drawing algorithm.

  1. You'd have to find the center of the trigger, using a perspective transform. Same for the top and bottom:

    Code: Select all

    Top3D = Trigger.Location + vect(0,0,1) * Trigger.CollisionHeight
    Bottom3D = Trigger.Location - vect(0,0,1) * Trigger.CollisionHeight
    
    Project these, as close to the player's real perspective as possible. I cannot help much with the projection, but basically, multiply a rotation matrix (which should be formed from the Z-Y-X – yaw, pitch, and roll – angles of the Viewer, but negative, so it is transformed back into screen coordinates) by a perspective matrix.
  2. Then, you want to find the width of the cylinder in the screen.

    Code: Select all

    ScreenWidth = Trigger.CollisionRadius / Depth
    
    Depth is the depth of the cylinder's center, which is found when the aforementioned point is projected into screen space. The reason for not using VSize is that VSize would likely distort this depth at the horizontal edges of the screen.
  3. Finally in this setup, you want to find the height of the edge ellipses on the screen. You might want to try using the absolute value of a dot product, more specifically between the up (for the top ellipsis) and down (for the bottom ellipsis) unit vectors, and the ViewRotation of the viewer.
    Image
Then, for the two lines at the sides, just use the Bresenham algorithm to draw them with a tiny texture (1x1 or, maybe better at higher screen resolutions, 2x2). For the ellipses, use this Bresenham-like algorithm, which basically divides the ellipsis in four quadrants, and plots along only one of the curves, but in such a way that each plotted point in the curve is actually plotted four times (mirroring it into the other quadrants), taking advantage of the ellipsis' symmetry.



...also, instead of manually projecting, one can very simply use the canvas to draw several sprite actors (forming vertical lines and ellipses), whose DrawScales are set to VSize(SpriteActor.Location - Viewer.Location). Try to make the vertical lines perpendicular to the viewer's ViewRotation!
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: in-game radii view for triggers

Post by PrinceOfFunky »

Gustavo6046 wrote: Sat Nov 23, 2019 3:01 pm
PrinceOfFunky wrote: Sat Nov 23, 2019 1:54 pm lines cannot be drawn on the screen

Yes, they can! Just use Bresenham's line algorithm and single pixel textures. (See the bottom of this post for an easier way!)
Well, yes you can use projections but drawing pixels is surely not optimized for unrealscript, it will make the gameplay slower :/
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: in-game radii view for triggers

Post by Gustavo6046 »

Pffft, use Canvas and draw client-side only. Spawn the actors in the client/standalone game (i.e. inside a netmode!=NM_DedicatedServer check) with Role=ROLE_Authority and RemoteRole=None, just to make sure the server won't even bother taking care of it. :)

As I said, use the Canvas' DrawActor method. Better yet, use DrawClippedActor to make sure it only draws roughly where you know the cylinder is (do only one projection calculation – the cylinder center –, then find the "rough" (the word is heuristic) screen space boundaries, and use those to tell the Engine to only iterate on these pixels when drawing your sprite actor over 100 times).
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
OwYeaW
Experienced
Posts: 81
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW »

Gustavo6046 wrote: Sat Nov 23, 2019 3:01 pm
PrinceOfFunky wrote: Sat Nov 23, 2019 1:54 pm lines cannot be drawn on the screen

Yes, they can! Just use Bresenham's line algorithm and single pixel textures. (See the bottom of this post for an easier way!)

You may also want to use an ellipse drawing algorithm.

  1. You'd have to find the center of the trigger, using a perspective transform. Same for the top and bottom:

    Code: Select all

    Top3D = Trigger.Location + vect(0,0,1) * Trigger.CollisionHeight
    Bottom3D = Trigger.Location - vect(0,0,1) * Trigger.CollisionHeight
    
    Project these, as close to the player's real perspective as possible. I cannot help much with the projection, but basically, multiply a rotation matrix (which should be formed from the Z-Y-X – yaw, pitch, and roll – angles of the Viewer, but negative, so it is transformed back into screen coordinates) by a perspective matrix.
  2. Then, you want to find the width of the cylinder in the screen.

    Code: Select all

    ScreenWidth = Trigger.CollisionRadius / Depth
    
    Depth is the depth of the cylinder's center, which is found when the aforementioned point is projected into screen space. The reason for not using VSize is that VSize would likely distort this depth at the horizontal edges of the screen.
  3. Finally in this setup, you want to find the height of the edge ellipses on the screen. You might want to try using the absolute value of a dot product, more specifically between the up (for the top ellipsis) and down (for the bottom ellipsis) unit vectors, and the ViewRotation of the viewer.
    Image
Then, for the two lines at the sides, just use the Bresenham algorithm to draw them with a tiny texture (1x1 or, maybe better at higher screen resolutions, 2x2). For the ellipses, use this Bresenham-like algorithm, which basically divides the ellipsis in four quadrants, and plots along only one of the curves, but in such a way that each plotted point in the curve is actually plotted four times (mirroring it into the other quadrants), taking advantage of the ellipsis' symmetry.



...also, instead of manually projecting, one can very simply use the canvas to draw several sprite actors (forming vertical lines and ellipses), whose DrawScales are set to VSize(SpriteActor.Location - Viewer.Location). Try to make the vertical lines perpendicular to the viewer's ViewRotation!
im trying to understand this, so what you basically say is; i should spawn many actors with a 1x1 sprite texture, have these drawn on the client's canvas using an algorithm to create the illusion of a 3 dimensional octagonal cylinder?
now im thinking; how many actors need to be spawned just to "draw" one octagonal cylinder? wouldnt that just be way too much?
and would the shape look nice and tight?

i might have understood it totally wrong but these are the questions im wondering about
Chris
Experienced
Posts: 134
Joined: Mon Nov 24, 2014 9:27 am

Re: in-game radii view for triggers

Post by Chris »

What is the purpose? Are you looking to do this locally to test maps? If so; the draw line functions and various other useful functions are all there in the render interface, it's just not visible to the canvas. They can easily be imported through custom opcodes.
If you are however looking to do it on-line, just forget about it.
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: in-game radii view for triggers

Post by papercoffee »

a similar question (thanks for reviving this thread btw...)
Is it possible to make only one actor to show its radi-view... say a moving actor?
Like something a player holds in his hands?

My idea is if a player is picking up a certain object, an actor gets attached to the player and can be seen from his teammates. When they step into that radius the actor reacts with points for the team.
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: in-game radii view for triggers

Post by Feralidragon »

There's a way to draw something close to that kind of cylinder in-game, without resorting to drawing 1 pixel at a time (which is super heavy on the CPU, since it's not what a CPU is meant to do), or going native, or anything else, and it will work everywhere.

Just create a cylinder mesh, and give it a simple texture so that the edges are rendered as something close to a wireframe.
You can even get creative and not limit it to a wireframe view, and have some gradients instead, or procedural textures, whichever you like.
Then all you have to do is to render it in the canvas in the same position as any other actor.

From there, since what you want is for the cylinder to reflect what essentially is a given radius and height, which may and will vary independently from one another, and since Drawscale alone doesn't cut it, since you cannot affect different axis differently (to stretch the cylinder), there's a second step to the cylinder mesh creation: make it so that the cylinder is animated, with the first frame where the cylinder bases (circles) are collapsed onto one another, like a thin pancake or a circular sheet, and the second frame with them set apart to a specific value.

By doing the above, in UScript you can then affect the mesh height with AnimFrame (where 0.0 is height=0 and 0.5 is max height) and the radius with Drawscale, although the calculation of AnimFrame will need to take the Drawscale into account (so you calculate the Drawscale directly from the radius, then you calculate AnimFrame using the given height and considering the previously calculated Drawscale).

If you import it as a vertex mesh, you're limited to the bounding box of the mesh itself, meaning that the max height would be 256uu at most, but this limitation is only applied to the source mesh file (*_d.3d), and in the import directives you may set whichever scale you want in whichever axis you want, independently, and so here you can set the Z axis to 2000x or so (a ludicrously high value) to ensure that the max height is enough to always work within the maximum map area (the max distance from any one point to another within the mapping area is about 113.511uu, so by setting the Z scale to 1000x for a 256uu mesh, you get a mesh 128.000uu long [not 256.000uu since the Z axis needs to be doubled, due to one less bit used in the Z-axis], which is enough to cover all possible heights to render).

Using the same exact principle, you can create 3D lines instead, and then render them together however you want.
This is essentially how in my gore mode, things like guts and such, are able to stretch and compress and look more "gooey", they're just cylinders using a mix of Drawscale and AnimFrame to scale the mesh in 2 different sets of axis independently.
OwYeaW
Experienced
Posts: 81
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW »

awesome, thats brilliant Feralidragon

so i guess im going for a cylinder mesh with 16 sides, probably textured and translucent
sadly i dont have 3dmax anymore so i might need someone else to make this for me, unless theres some easy and quick way to create this model?

also Feralidragon; is there some example code that i can look at? for example maybe in one of your mods?
Chris wrote: Tue Nov 26, 2019 6:56 pm What is the purpose? Are you looking to do this locally to test maps? If so; the draw line functions and various other useful functions are all there in the render interface, it's just not visible to the canvas. They can easily be imported through custom opcodes.
If you are however looking to do it on-line, just forget about it.
i will use this for one of the features in a new servermod for BT
basically i want to give players the ability to see shoot triggers (and potentially also triggereddeaths etc)
its a client sided menu with settings

here is a preview of the current feature: https://streamable.com/sibli
Post Reply