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.
User avatar
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Centering first person HUD models

Post by Agentbromsnor »

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
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Centering first person HUD models

Post by ramon.dexter »

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
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Re: Centering first person HUD models

Post by Agentbromsnor »

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
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Centering first person HUD models

Post by ramon.dexter »

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: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
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Re: Centering first person HUD models

Post by Agentbromsnor »

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: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
Cherno
Posts: 1321
Joined: Tue Dec 06, 2016 11:25 am

Re: Centering first person HUD models

Post by Cherno »

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.

Return to “Assets (and other stuff)”