in-game radii view for triggers

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

in-game radii view for triggers

Post by OwYeaW » Sat Nov 25, 2017 5:11 am

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
Masterful
Posts: 735
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 » Sat Nov 25, 2017 1:18 pm

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: 3766
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: in-game radii view for triggers

Post by JackGriffin » Sat Nov 25, 2017 2:06 pm

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: 1727
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: in-game radii view for triggers

Post by Barbie » Sat Nov 25, 2017 4:15 pm

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
Average
Posts: 71
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW » Sat Nov 25, 2017 4:57 pm

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
Average
Posts: 71
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW » 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?

User avatar
PrinceOfFunky
Godlike
Posts: 1088
Joined: Mon Aug 31, 2015 10:31 pm

Re: in-game radii view for triggers

Post by PrinceOfFunky » Sat Nov 23, 2019 1:54 pm

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
Inhuman
Posts: 831
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Finite
Contact:

Re: in-game radii view for triggers

Post by Gustavo6046 » 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!

User avatar
PrinceOfFunky
Godlike
Posts: 1088
Joined: Mon Aug 31, 2015 10:31 pm

Re: in-game radii view for triggers

Post by PrinceOfFunky » Sun Nov 24, 2019 1:43 pm

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
Inhuman
Posts: 831
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Finite
Contact:

Re: in-game radii view for triggers

Post by Gustavo6046 » Sun Nov 24, 2019 2:18 pm

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).

OwYeaW
Average
Posts: 71
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW » Tue Nov 26, 2019 3:10 am

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: 124
Joined: Mon Nov 24, 2014 9:27 am

Re: in-game radii view for triggers

Post by Chris » 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.

User avatar
papercoffee
Godlike
Posts: 9411
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 » Tue Nov 26, 2019 9:27 pm

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: 5122
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 » Wed Nov 27, 2019 2:19 am

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
Average
Posts: 71
Joined: Fri Jan 09, 2015 4:24 pm

Re: in-game radii view for triggers

Post by OwYeaW » Wed Nov 27, 2019 1:07 pm

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