Level and screen projections (now with resize handling)

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Level and screen projections (now with resize handling)

Post by Apeirogon »

I seen that, what I mean is that IMO license terms must be available from the "front page" of the library.

And about comments, just comment what result of reorient/deproject/etc. functions, to make it clear what they do and which you must override to add some explosions and music to it.
User avatar
Cherno
Posts: 1309
Joined: Tue Dec 06, 2016 11:25 am

Re: Level and screen projections (now with resize handling)

Post by Cherno »

EDIT: I found the solution.I somply changed the camera's CameraFOV property and wit works flawlessly now, and I can even remove the cam texture.

Hello,

first of all, thanks for this library. Most of the math is beyond my understand but I can see that is must have been a ton of work.

I am using a camera texture to view the world from an almost isometric overhead projection (fov 18). Think the old game Desert Strike. However, is seems like the library will only use the "real" viewport fov. If I use the isometric cam as a real viewport via ChangeCamera so it replaces the player's view, stuff gets drawn correctly at an actor's screen position (like a target indicator). However, when drawing teh camera texture above it, it uses the narrow fov of 18 so I wonder how this could be solveD? I see no way to make the library use a specific fov in it's computations.
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm
Contact:

Re: Level and screen projections (now with resize handling)

Post by KeksDose »

Odd, cuz it sounds like you'd just wanna set CacheFov(18). I guess having no camera texture at all is better, though.
Cherno wrote:Most of the math is beyond my understand but I can see that is must have been a ton of work.
I appreciate the notion. Maths is my job though, so it was a cinch.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: Level and screen projections (now with resize handling)

Post by kodi »

I was wondering if I could suggest a feature that may be out of scope for the library: A function that efficiently rotates pitch and angle arguments supplied to it. I'm using libeye for cursor aiming and would like to make some weapons with randomized spread 8-)
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm
Contact:

Re: Level and screen projections (now with resize handling)

Post by KeksDose »

Can be arranged. Dunno if outta scope (audience groans pun) but I only gave it the name libeye to have a food pun on ribeye steaks.

nice smartgun btw haha
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: Level and screen projections (now with resize handling)

Post by kodi »

Can be arranged
Much appreciated!!!
but I only gave it the name libeye to have a food pun on ribeye steaks.
I had not realized this, and I almost think I was better off for it :mrgreen:
nice smartgun btw haha
Hah, thanks. It's quite satisfying to use against zombiemen.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Level and screen projections (now with resize handling)

Post by Major Cooke »

I can see from the bounding box example that checking for something in the frustrum is possible, but I'm wondering if this can be used to also affect things?

I've been told some examples like frustrum culling for Minecraft-esque blocks may help with performance when there's thousands of actors. Naturally, the idea is to ignore all actors that have the INVISIBLE or 'None' RenderStyle property, or sprite/frame of TNT1 A.

But at the same time this does seem like it's heavily going to be subject to UI rules which means it'll be next to impossible.
User avatar
Night Falls
Posts: 47
Joined: Mon Mar 09, 2020 4:32 pm
Location: A hole in the bottom of the sea

Re: Level and screen projections (now with resize handling)

Post by Night Falls »

Is there any way I could make it so the free aim is from the perspective of a camera instead of the player or get the world coordinates of where the cursor is pointing?
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm
Contact:

Re: Level and screen projections (now with resize handling)

Post by KeksDose »

Yea! It'll depend on what you wanna do, but in general, directions you get from the cursor will be from the perspective of what you describe in the "Orient" functions. By proj.OrientForPlayer(some_player_info); you tell the projector "I want a player actor to be the perspective". You can instead use proj.Reorient(camera.pos, (camera.angle, camera.pitch, camera.roll)); and the projector will now assume that the camera is the perspective. All you need is the actor reference of the camera you wanna use.

In the free aim example, you also have this line: cursor_mo = data.hitactor; where data is the result of a line trace. You can use vector3 hit_pos = data.hitlocation; to get the world point the cursor is pointing at in that situation, from the camera view, and the tracer flags decide for which actors or map lines it'll stop. This line trace has to be done cuz the projector by itself really just gives you the direction of such a world position. Then you can do some maths to fire projectiles or bullets from the player towards that location or sth...
User avatar
Night Falls
Posts: 47
Joined: Mon Mar 09, 2020 4:32 pm
Location: A hole in the bottom of the sea

Re: Level and screen projections (now with resize handling)

Post by Night Falls »

Thanks! I've been poking around different things and can't figure out how to get the actor reference of the camera though.

Edit: Nevermind, just had to use worldthingspawned
User avatar
Night Falls
Posts: 47
Joined: Mon Mar 09, 2020 4:32 pm
Location: A hole in the bottom of the sea

Re: Level and screen projections (now with resize handling)

Post by Night Falls »

KeksDose wrote:Yea! It'll depend on what you wanna do, but in general, directions you get from the cursor will be from the perspective of what you describe in the "Orient" functions. By proj.OrientForPlayer(some_player_info); you tell the projector "I want a player actor to be the perspective". You can instead use proj.Reorient(camera.pos, (camera.angle, camera.pitch, camera.roll)); and the projector will now assume that the camera is the perspective. All you need is the actor reference of the camera you wanna use.

In the free aim example, you also have this line: cursor_mo = data.hitactor; where data is the result of a line trace. You can use vector3 hit_pos = data.hitlocation; to get the world point the cursor is pointing at in that situation, from the camera view, and the tracer flags decide for which actors or map lines it'll stop. This line trace has to be done cuz the projector by itself really just gives you the direction of such a world position. Then you can do some maths to fire projectiles or bullets from the player towards that location or sth...
I got it all figured out and it works great! There was one other thing I had to do which is change

Code: Select all

po.LineTrace(
				cursor_ang,
				25000.13376669,
				cursor_vang,
				TRF_THRUBLOCK | TRF_THRUHITSCAN,
				offsetz: player.viewheight,
				data: data);	
to

Code: Select all

			camera.LineTrace(
				cursor_ang,
				25000.13376669,
				cursor_vang,
				TRF_THRUBLOCK | TRF_THRUHITSCAN,
				offsetz: player.viewheight,
				data: data);
The only issue is that the actor used as the pointer and the on-screen pointer are usually a short distance apart depending on the angle I'm pointing. If I can't get them totally in sync it'd be fine to just only have the actor mouse pointer since it's more accurate anyways.
Thanks for your help and code! This was exactly what I needed for my project.
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm
Contact:

Re: Level and screen projections (now with resize handling)

Post by KeksDose »

Looking good! I think the offset is due to the tracer being fired from offsetz: player.viewheight still. Try offsetz: camera.cameraheight, or maybe even plain 0?
User avatar
Night Falls
Posts: 47
Joined: Mon Mar 09, 2020 4:32 pm
Location: A hole in the bottom of the sea

Re: Level and screen projections (now with resize handling)

Post by Night Falls »

Thanks!
Though I honestly don't understand a lot of the math going on getting the hit location, I think the offset was just because the camera was looking down at an angle, and also because the cursor actor is in a 3D space and the HUD cursor is in a 2D space, so they didn't line up perfectly (the offset increased the further it got from the center of the screen).

Setting the offsetz to -10 got the two cursors close enough together, and with the way the aiming works in my mod the 3D space offset thing doesn't really affect the gameplay, so it's fine if it does that. I just set the in-world cursor to be invisible.

Weirdly though, switching offsetz to camera.viewheight made the in-world cursor invisible and the player's rotation (done by having him face the cursor) got all funky. Since I've just got it set to -10 it's not a problem though.
User avatar
Rachael
Posts: 13530
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Level and screen projections (now with resize handling)

Post by Rachael »

Apeirogon wrote: Tue Jul 30, 2019 11:59 am Please add license terms in original post aka "can I use/modify/share it".
And also more comments to code, so users can "poke it with greasy fingers" more freely.
KeksDose wrote: Sat Aug 03, 2019 7:34 am @Apeirogon: There aren't any terms except a gentlemen's agreement to leave a note with a text image intact. You may do whatever you like with it then.

If you're unsure about something, feel free to ask here. I can't hope to cover every possible question with comments.
The "gentlemen's agreement to leave a note with a text image intact" actually makes this incompatible with the GPL - if say someone wanted to use this in a GPL-compatible project, since the GPL does not allow additional restrictions beyond the restrictions already given in the license itself - this means that this cannot be used inside said project.

Would you consider a GPL exception in this case (which would remove the stipulation of requiring the text image)? Or possibly dual-licensing it as GPLv2>(or later)/BSD/MIT?
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm
Contact:

Re: Level and screen projections (now with resize handling)

Post by KeksDose »

It's been a while, so sure, I'm leaning towards it if it's appreciated.
Post Reply

Return to “Script Library”