Centering first person HUD models

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Centering first person HUD models

Postby Agentbromsnor » Sun Aug 01, 2021 5:44 pm

Hello everybody,

I'm basically trying to wrap my head around how to make 3D weapon models for GZDoom. I've imported my own 3D models in the past, but they were static models so it was quite easy to do (relatively speaking).

I am however thinking of stepping it up a bit, which means trying to make animated weapons and other models. To start off, I'm trying to figure out 3D weapon HUD models.

The thing that I fail to understand is how the angle and rotation of the model works. For example: when dealing with a sprite weapon, it obviously shows up as an image on the screen on the given coordinates, but how does that work in relation to a 3D model? If I make a model inside a modeling program like Blender, and I use a camera to mimic the first person view, how can I make sure that I get the same result in GZDoom? I've tried looking at PK3 files of projects that use 3D weapons in SLADE, but I could never really decypher things.

I know this is a bit of a longwinded question, but there's still relatively little tutorial resources on 3D stuff, so I'm trying to get educated!

Thank you.
User avatar
Agentbromsnor
 
Joined: 28 Mar 2012

Re: Centering first person HUD models

Postby ramon.dexter » Mon Aug 02, 2021 7:52 am

Well, the centrem of rotation and pitch for a model is the model's 0 coordinate. When mapping in <any modelling program>, try to keep the model in the center of the grid. Then, the 0 coordinate of the grid is the centre of rotation&pitch.

When I model in blender, I just try to keep the model in the center, with the handle kept in the very center (0).

As far as I understand when modelling.

Sorry to sound weird, but english is not my native language and explaining these modelling this is little bit hard for me. Hell, it would sound weird even in my native language either.
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Centering first person HUD models

Postby Agentbromsnor » Mon Aug 02, 2021 8:10 am

ramon.dexter wrote:Well, the centrem of rotation and pitch for a model is the model's 0 coordinate. When mapping in <any modelling program>, try to keep the model in the center of the grid. Then, the 0 coordinate of the grid is the centre of rotation&pitch.

When I model in blender, I just try to keep the model in the center, with the handle kept in the very center (0).

As far as I understand when modelling.

Sorry to sound weird, but english is not my native language and explaining these modelling this is little bit hard for me. Hell, it would sound weird even in my native language either.


I wish there was a way to visualize this for me...

If the viewport model is kept at the absolute center, GZDoom will display it properly? How do I know that the player's camera will view the weapon correctly?
User avatar
Agentbromsnor
 
Joined: 28 Mar 2012

Re: Centering first person HUD models

Postby ramon.dexter » Mon Aug 02, 2021 9:15 am

Oh you meant to position it properly in the viewport?

Well, the positioning in the viewport is achieved by defining offsets for the said model in MODELDEF lump. Check it: https://zdoom.org/wiki/MODELDEF

Also, you can check my latest release here:https://forum.zdoom.org/viewtopic.php?f=19&t=59461
Grab it, open the modelpack and check the modeldef file for weapons.

Basically, you have to set the model offsets to position it properly.
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Centering first person HUD models

Postby Agentbromsnor » Mon Aug 02, 2021 11:58 am

ramon.dexter wrote:Oh you meant to position it properly in the viewport?

Well, the positioning in the viewport is achieved by defining offsets for the said model in MODELDEF lump. Check it: https://zdoom.org/wiki/MODELDEF

Also, you can check my latest release here:https://forum.zdoom.org/viewtopic.php?f=19&t=59461
Grab it, open the modelpack and check the modeldef file for weapons.

Basically, you have to set the model offsets to position it properly.


Thank you, I will take a look at that.

Are there any tutorials that cover 3D weapons in GZDoom, I wonder? I found one or two before but they only covered static objects.
User avatar
Agentbromsnor
 
Joined: 28 Mar 2012

Re: Centering first person HUD models

Postby Cherno » Mon Aug 02, 2021 3:17 pm

From the top of my head, there are only three things you must know about using 3D weapon models (other than waht you already know about models in general):
1. They have to have a negative X scale, because they are mirrored for some reason.
2. Overlays from CustomInventories work a bit different: The MODELDEF entry name must be the weapon actor to use it with, but everything else in the entry is as usual.
3. A_OverlayOffset doesn't work like with sprites, it's pretty much useless.
User avatar
Cherno
 
Joined: 06 Dec 2016


Return to Assets (and other stuff)

Who is online

Users browsing this forum: No registered users and 0 guests