fuaZandroX modding reference

Models

Availability

ZandroX only among Zandronum versions. The keywords and the OBJ format come from UZDoom under UZDoom's names, so a UZDoom MODELDEF that uses them loads as written.

Works in netgames. A model only changes what each machine draws. Nothing about it is sent, and every machine reads the same lumps.

Usage

Models are defined in MODELDEF as in Zandronum: a Model block per actor class, with Path, Model, Skin, Scale, Offset, FrameIndex and Frame lines. ForkUnderA draws them on Vulkan and OpenGL alike. This page covers what it adds.

Formats

  • MD2 (and DMD), MD3, and voxels (KVX, from MODELDEF or VOXELDEF), as in Zandronum.
  • OBJ (Wavefront), new: a Model line naming a file ending in .obj. See OBJ models.

Keywords ForkUnderA adds

Each goes on a line of its own inside a Model block and applies to that block's frames.

KeywordWhat it does
UseActorPitchTilts the model by the actor's pitch the way the actor looks. InheritActorPitch, Zandronum's, tilts it the opposite way.
UseActorRollThe same as InheritActorRoll, under UZDoom's name.
DontCullBackFacesDraws the back faces of a model whose actor is not in the Normal render style. Has no effect on weapon (HUD) models.
ForceCullBackFacesHides the model's back faces in every render style, weapon models included.
NoPerPixelLightingLights the model with one light for the whole actor instead of per pixel. Use it for models converted from voxels, whose faces' normals make per-pixel light look patchy.

Back faces

A model drawn in the Normal render style draws both sides of every face. In any other style (Translucent, Add, a faded Alpha…) its back faces are hidden, so the far side of a see-through model does not show through its near side. DontCullBackFaces and ForceCullBackFaces change that, as the table above says.

Dynamic lights on models

Dynamic lights (GLDEFS point, pulse, flicker and sector lights) light a model per pixel, by the direction each light comes from, as UZDoom does. Zandronum lit a model with one colour for the whole actor. A model is lit per pixel unless:

  • its MODELDEF block says NoPerPixelLighting;
  • it is a voxel;
  • its actor is fullbright, in the Shadow style, or has +NODYNAMICLIGHTING;
  • the player turned dynamic lights off (r_lights 0) or turned them off on sprites (r_light_sprites 0).

The lights a model takes are found from the actor's Radius, or its RenderRadius when that is larger. Give a model much wider than its actor a RenderRadius that covers it, so lights near its edges reach it.

Weapon models are lit the same way.

Wide models

A model can be far wider than the actor it stands on, such as a bridge on a 16-radius actor. Zandronum and UZDoom decide whether to draw an actor from its centre, so such a model vanished whole once its centre left the view. ForkUnderA measures how far each model reaches, from its vertices and its MODELDEF placement, and draws the actor while any of that is in view. Nothing needs setting for this.

DECORATE's RenderRadius property can widen that reach, never narrow it. A negative RenderRadius hides the actor, as in UZDoom.

actor BridgeSlab
{
	Radius 16
	Height 8
	RenderRadius 400
	+NOGRAVITY
	States
	{
	Spawn:
		BRDG A -1
		Stop
	}
}

OBJ models

  • An OBJ has one frame and does not animate. FrameIndex takes 0 for it, and Frame takes any name.
  • Each usemtl starts a surface, drawn with the graphic of that name in the model's Path folder. When the folder has none, the texture of that name is used. .mtl files are not read. Skin and SurfaceSkin replace the materials as for MD3, surfaces counted from 0 in the order of their first usemtl. Faces before the first usemtl form a surface of their own.
  • At most 32 surfaces are drawn. A file with more draws the first 32 and says so in the console.
  • Normals come from the file's vn lines. A face without them gets its own, smoothed across the faces of a smoothing group (s).
  • Faces of more than four corners are split into triangles. A face with a corner that is not in the file is left out, and the console says how many were.
  • The model is laid out as UZDoom lays it out, so an OBJ placed for UZDoom (Scale, Offset, AngleOffset) looks the same here.

Errors

  • A Model block for an actor class that does not exist is skipped with a warning. UZDoom stops loading.
  • A keyword ForkUnderA does not know is printed in the console and skipped.
  • A model or skin file that is not found is printed in the console.
  • A FrameIndex or Frame line naming a sprite that does not exist stops the game from loading.

Settings

  • r_use_models: draw models (default on). Off draws the actors' sprites instead.
  • r_interpolate_model_frames: blend between a model's frames (default on).

Examples

A column replaced by an OBJ, lit per pixel, and a translucent MD3 that shows its back faces:

// MODELDEF
Model Column
{
	Path "models/column"
	Model 0 "column.obj"
	Scale 1.0 1.0 1.0
	FrameIndex COLU A 0 0
}

Model BurningBarrel
{
	Path "models/barrel"
	Model 0 "barrel.md3"
	Skin 0 "barrel.png"
	DontCullBackFaces
	UseActorPitch
	FrameIndex FCAN A 0 0
	FrameIndex FCAN B 0 1
	FrameIndex FCAN C 0 2
}

A voxel-converted model kept on its actor's single light:

// MODELDEF
Model TechLamp
{
	Path "models/lamp"
	Model 0 "lamp.obj"
	NoPerPixelLighting
	FrameIndex TLMP A 0 0
}

Not supported: IQM and Unreal (UE1) models, and these UZDoom keywords: #include, Animation, BaseFrame, CorrectPixelStretch, Fix-Rotating, ModelsAreAttachments, ScaleWeaponFOV, UseRotationCenter and ViewModelFOV. Plain MD2 models are lit as MD3 models are; UZDoom swaps their normals' y and z.

To make a flat model, such as a floor ring, draw under the monsters standing on it, see FUAMODEL.

Implementation notes