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
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

I think roll may be inverted in LibEye... consider the following:



Current behaviour VS fixed behaviour:




Seems like using a positive roll value in OrientForRenderOverlay/Player fixes it.
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 »

Hmhmhm... that fixes the issue. I've made adjustments so no minus signs are necessary anywhere. Reorient is supposed to store a view basis, so sign business should not be needed. I updated the file.

I've made an amusing mistake in the opengl one. The vector supposed to point right was pointing left, but I did it correctly for software. Maybe I had my brain on airplane mode.
m8f wrote:Will there be a git repository for libeye? One may want to submodule it.
If there's greater interest.

Aside from that, I'm happy to see several mods making use of this. I'm especially satisfied the ease of use is noted. I was a little afraid the ceremony with the cache resolution, fov, orient would be a bit out there, but I see that hiding all the maths business did the trick well enough.

I worked about 5 times as long making this usable than making it work. x]
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

KeksDose wrote:I was a little afraid the ceremony with the cache resolution, fov, orient would be a bit out there
There's room for improvements for sure, maybe you could group all of those calls into a single function that takes in the necessary arguments to pass to the various subfunctions?

Anyway, current system is fine, don't mistake that as a request. :) I'd settle with whatever we already have now, it's damn easy to use already as it is. =P Good work, and thanks for this amazing library again!
User avatar
Major Cooke
Posts: 8175
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 »

Yes, a git would be very nice.

If there's something I would love, is the ability to scale a projection based on distance like regular sprites. Is there any good way to do that with your code?
User avatar
Major Cooke
Posts: 8175
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 »

Bug report: Saves fail due to cvar_renderer not being transient.
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 »

I'll fix that later, since it's just an example. The projector has a function Distance for the distance of the position you passed in, to your viewpoint. Scale based on that like so:

Code: Select all

proj.ProjectWorldPos((x, y, z));
let scale = 300.0 / proj.Distance();

// Draw stuff, but you gotta know how to scale it yourself.   
Use your wits in determining whether distance can be 0 and proceed with care.
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 »

Made a small update.

1. There's a new function for projectors.

Code: Select all

// ProjectActorPos (Actor, offset, fraction of tic)
// ProjectActorPosPortal (same thing, but is portal aware)
// Example:

override void RenderOverlay (RenderEvent event) {
    proj.OrientForRenderOverlay(event);
    proj.BeginProjection();
    proj.ProjectActorPos(target, (0, 0, 0.5 * target.height), event.fractic);
    let draw_pos = proj.ToScreen();

    // etc.
}

// This projects the actor's interpolated position, so the appearance is smoothed
// when the actor moves. By default, offset is (0, 0, 0), t is 1.     
2. There's now OrientForRenderUnderlay. It does the same thing as for RenderOverlay, but it has a more fitting name, now that RenderUnderlay is a thing (and who knows what can happen that makes future me thank myself for adding a new function).

You may use the strangely named RenderUnderlay to draw things below the hud.

edit: Forgot about software mode. Made an update just now.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

Thanks for the update! Importing into my project right away. :D
User avatar
Major Cooke
Posts: 8175
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 »

KeksDose wrote:strangely named RenderUnderlay
Don't think too hard on it. The name implies going underneath the layer of huds.
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 »

Maybe you'd like to a little harder think about why I called it strangely named, given it has "under" in the name. What other on screen element remains that RenderUnderlay draws over? That's what makes it strangely named.
User avatar
Major Cooke
Posts: 8175
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 »

None. Because it's the very bottom. Hence "underlay". Theoretically you could count the game world itself but I don't.
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 »

On topic: For those who haven't seen it, consider taking a look at the innards of the Sandman from the Guncaster addon (warning, volume). It's the reason this library exists after all, and is a pretty thorough and practical example of implementing a Smart Gun as seen in Aliens, though it's obviously powered up a great deal hmhm

@MC: That'd be nigh useless. Try to think why the name RenderUnderlay forces you to confirm whether it draws above or below weapons. Far from a big deal (even if everybody I talked to about this was surprised it draws over weapons, still), but then again, all I'm saying is "Under" isn't precise enough. I'll have to ask you to take it elsewhere now cuz I'm not willing to go on this worthless tangent any longer.
User avatar
Major Cooke
Posts: 8175
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 stopped caring about the naming stuff after my last post anyway.

So this includes the interpolation we discussed? And, think you're going to put this on github anytime soon? That way viewing the changes is easier.
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 »

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

mc thats why i posted the update

@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.
Post Reply

Return to “Script Library”