Entities
See a unit or a ship drawn from its .asset entity, with what hangs on its bones and its animations.
entity in an .asset file, Preview entity above it. The preview builds the unit from its model, its halberd on the right hand's bone, playing idle. The bar's first line names the model and its attachment. The state list in the bar goes from State: idle to State: walk, and the halberd moves with the hand.The game builds each unit and ship from an entity in an .asset file. An entity has a mesh,
other entities hung on the mesh’s bones (its skeleton), and states (its animations, such as idle
or walk). Etch draws an entity the same way, in the same preview as a single
mesh.
Preview an entity
Section titled “Preview an entity”-
Open an
.assetfile, for example the base game’sgfx/entities/western_units.asset. -
Click Preview Entity, which shows above each
entity = { … }, for example abovewesterngfx_INFANTRY_1. Or run Etch: Preview Entity… from the Command Palette (Ctrl+Shift+P) and pick the entity from the list:- the entity your cursor is in comes first, under At the cursor, with its states (such as
idle · walk · attack), so Enter previews it; - the others follow under In the file, in the order the file has them;
- each one shows its
pdxmesh, or “clone of” and the entity it copies, and the line it starts on.
Type in the box at the top of the list to filter it by name.
- the entity your cursor is in comes first, under At the cursor, with its states (such as
-
The entity opens beside the editor, in a tab called “Entity: westerngfx_INFANTRY_1”.
The command shows in the Command Palette only while you are in an .asset file.
What an entity is made of
Section titled “What an entity is made of”Etch follows the entity’s keys as the game does:
- Its
pdxmesh = …names apdxmeshblock of a.gfxfile, whosefileis the mesh. Forwesterngfx_INFANTRY_1, the blockwestern_generic_01_type1ininterface/assets/western.gfxhasgfx/models/Units/western_generic_01_type1.mesh. - Its size is the pdxmesh’s
scaletimes the entity’s ownscale. - A
clonemakes it start from the entity it names. What the entity writes itself replaces the clone’s: itspdxmesh, itsscale, a state of the same name, anattachblock of the samename. - Each
attachblock hangs other entities on the bones it names, each at its own scale. In the soldier above,Right_hand_node = "western_halbard"puts a halberd in his right hand. An attached entity moves with its bone.
States
Section titled “States”The list in the bar under the model holds the entity’s states (State: idle, State: walk,
…). The preview starts with the entity’s default_state. Without one, it starts with idle, if
the entity has that state.
- Pick a state to play it, in a loop, on the entity and on everything attached to it. The line at the bottom shows the state, its frame and its speed.
- Click Pause to stop it, and Play to go on from the same frame, or press Space. Bind pose, at the top of the list, shows the entity without an animation.
- If your system is set to reduce motion, a state waits on its first frame, also the one the preview starts with. Click Play or press Space to start it (see Animations).
- The slider beside Play goes to a frame, as in the mesh preview (see Go to a frame). The slider follows the animation of the entity’s own mesh. Everything attached to the entity, such as the soldier’s halberd, shows the same moment.
A state’s animation names one of the animation blocks of the entity’s pdxmesh, by its id.
That block’s type names an animation of an .asset file, and that one’s file is the .anim
file that plays. For the soldier, idle plays polearm_twohanded_idle.anim. An attached entity
with no animation for the state stays on its bone as the bone moves.
A state with time_offset = { 1 0.5 } starts 1 second in, plus a random part of the second
number. Its animation starts at that point, and an event timed before it waits for the next
loop, or never comes in a state that does not loop. The preview starts the state at the first
number.
The animation moves the mesh’s bones by their order, as the game does: joint 1 moves bone 1, joint
2 bone 2, whatever their names. A musket on Left_hand_node, the tenth bone, therefore follows the
tenth joint of rifleman_idle.anim, attack_L_hand. An animation with more or fewer joints than
the mesh has bones does not play in the game: the preview shows that entity in its bind pose and
names the state in the box under the bar.
You turn, move and zoom the model as in the mesh preview. The country colours (the colour boxes, Country and Region), LOD, Snow, Wire, Bones, Diffuse, Normal, Spec and the zoom with Fit model work the same way. Particles shows or hides the state’s smoke, sparks and flashes (see Particles). As there, the country colours, LOD and Snow show only when the model has parts they work on. Bones shows the skeletons of the entity and of everything attached to it that has one. An orange dot marks each bone an attached entity hangs on: point at it to see the bone’s name, then the name of the attached entity.
Where it finds the files
Section titled “Where it finds the files”Etch takes every file from your playset (the game, your mod
and the mods it depends on). It reads the .gfx and .asset files of the game and your mods.
When two of them define the same name, the one loaded later wins. Then it loads the meshes,
textures and animations they name. For the .asset file you have open, Etch uses what is in the
editor, even before you save. When you save an .asset or .gfx file, the open entity previews
draw again.
Most of what an entity uses is defined in the game’s own files, so the entity preview needs the
game folder. Etch finds it through Steam; if it does not, set etch.gamePath (see
Where Etch finds the game). Without the game folder, Etch
says so and draws nothing.
What the bar shows
Section titled “What the bar shows”The bar lists the entity’s name, its mesh file and how many entities hang on it, such as “western_generic_01_type1.mesh and 1 attached”. Then come the same counts (shapes, vertices, triangles, bones), shaders and textures as in the mesh preview, for everything drawn together, and the entity’s scale when it is not 1.
Hover over the bar’s first line to see the attachments: each entity, the bone it hangs on and its mesh file.
A box under the bar lists what Etch could not find or draw:
- a missing pdxmesh, mesh file, animation or attached entity;
- a
cloneloop: an entity that clones another one that clones it back; - an entity that would hang under itself, directly or further down; Etch does not draw it;
- a particle the game cannot start (see Particles);
- an animation that does not fit its mesh: another number of joints than the mesh has bones;
- a texture that is missing.
Particles
Section titled “Particles”A state’s event = { … } blocks (not EU4 events) start particle effects, such as the muzzle
flash of an artillery piece. In western_units.asset, the attack state of
westerngfx_ARTILLERY_1_cannon starts artillery_cannon on the bone cannon_muzzle.
Etch draws these effects while the state plays. The smoke, sparks and flashes come out of the
event’s node at its time, every time the animation comes round to it. Each start is a new
copy of the effect, and the earlier copies play on.
As in the game:
- An event whose
timeis past the end of the animation, or below 0, starts each time the animation starts over. - A state without an animation starts its effects once. With
state_time = 2, they start again every 2 seconds. - With
trigger_once = yes, the event starts only in the state’s first round: the first pass through its animation, or its firststate_timeseconds. A state with neither never starts it. - When you pick another state, the effects and their particles go at once. An event with
keep_particle = yeskeeps its effect, and the particles already out live on. If one of its subsystems (the parts of the effect) would send out particles for ever, the effect stops sending out new ones.
A subsystem with trail = yes draws a band through its particles, from the oldest to the newest,
as wide as the particles are big. With billboard = yes the band faces the camera; otherwise it
lies flat. The base game has no shader effect for trails, so the game draws the band in one flat,
grey colour, solid, whatever the particles’ colour, alpha and texture, and only the side that
faces the camera. Etch draws it the same way. A band that faces the camera shows whole. A flat
band seen from above does not show, except, in the game, for scraps where particles overtake each
other; Etch shows no such scraps. And the game shows no band at all while another part of the same
effect has particles on screen, whether that part comes before or after the trail in the file, so
a trail shows only in an effect of trails, or while its other parts have no particle. Without its
own shader effect, the band is drawn with the last shader the game used, and after the effect’s
particles that shader draws nothing. Etch does the same. A trail whose shader effect your playset’s
gfx/FX/particle.shader has (see Particle effects) shows next to the other parts,
in the game and in Etch. So does a trail without one that comes after it in the file: the game
draws it with that trail’s shader effect, while that trail has particles on screen.
The node is a bone of the mesh, or a named point that the .mesh file stores for this. The
muzzle of vanilla’s muskets is such a point. If the mesh has neither of that name, the effect
starts at the entity’s feet.
Etch draws the effects in its own way: close to the game’s, but not the same (see Differences from the game). While they play, the line at the bottom says how many particles there are, then the effects’ names, for example “particles (approximate, 120 alive): western_musket: musket_muzzle on muzzle at 0.9 s”.
Particles shows only for an entity with effects that Etch can draw. Click it to hide them: the line then says “particles off”, then the names. When none of the state’s effects can be drawn, the line says “particles not drawn”, then the names, and the box under the bar says why (see below).
Pause the animation and drag the frame slider: a frame always shows the same particles, however you got to it. When the preview could not draw for more than a second (its tab was hidden, the computer slept), the animation goes on from where it stopped, as after a pause.
To start a particle, the game needs two definitions:
- A
pdxparticlein a.gfxfile in theinterfacefolder, inside itsobjectTypes = { … }block. The event’sparticle = …uses itsname. The game’s are ininterface/assets/particles.gfx, such aspdxparticle = { name = "siege_cannon" type = "artillery_cannon" scale = 0.8 }. - The effect that its
typenames: aparticle = { name = "artillery_cannon" … }block in an.assetfile. The game’s are ingfx/particles.
So in the game, an event with particle = "siege_cannon" starts the effect artillery_cannon
with the scale 0.8, and so does Etch. The scale makes each particle that many times bigger and
makes it fly the square of the scale as far: at a scale of 2, twice as big and four times as far.
The game reads the scale when it starts, so restart it after you change one; reload assets
keeps the old scale.
The line at the bottom shows the effect and the scale after the name: “siege_cannon
(artillery_cannon, scale 0.8)”. It shows them only when the effect has another name or the
pdxparticle has a scale.
The box under the bar lists an event whose particle the game cannot start:
- No
.gfxfile has apdxparticleof that name. An effect of that name in an.assetfile is not enough. The game’s own message for this beginsCouldn't find particle 3D object. - The
pdxparticlehas notype, or itstypeis not the name of any effect in an.assetfile. The game’s own message for the second beginsCould not find particle effect.
To fix it, add or correct the pdxparticle in your mod’s .gfx file.
Warnings in the files
Section titled “Warnings in the files”Etch also warns you about these two cases in the files, without the preview. Open an .asset
file from a gfx folder, or a .gfx file from an interface folder. A wavy underline marks
each case. The same warning shows in VS Code’s Problems panel (Ctrl+Shift+M), with
“Etch” next to it.
- In the
.assetfile, the underline is under the name inparticle = "…"when no.gfxfile has apdxparticleof that name. Sometimes you wrote the name of the effect instead of the name of thepdxparticle:my_smoke_effectwhere your.gfxfile haspdxparticle = { name = "my_smoke" type = "my_smoke_effect" }. Then the warning tells you the name of thepdxparticleto use, heremy_smoke. - In the
.gfxfile, the underline is undertype = "…"when no.assetfile has an effect of that name. It is undername = "…"when thepdxparticlehas notype.
The warnings update as you type in the open file. For the other files, Etch reads them as they
are saved. So after you add a pdxparticle or an effect in another file, save that file. The
warnings in the open files then update.
Etch also explains the keys inside the effect’s own particle = { … } block when you hover over
them, and warns about mistakes in them: see Particle effects.
Differences from the game
Section titled “Differences from the game”These parts work as in the game:
- when an effect sends out particles, and how many;
- how long they live, how fast and which way they fly;
- how their size, rotation and colour change over their life;
- the picture from the effect’s
texture, and how it blends with what is behind it; - the force blocks (explained in Particle effects) of
type = "planar","point","vortex","friction","turbulence"and"spin". Apointforce with a positiveamountpushes the particles away from itsposition. Aspinforce swings them round its axis,amountradians a second (a full turn is about 6.28), but nothing holds them on the circle: in an effect whose pdxparticlescaleis above 1, or with another force or a start speed, they spiral outwards and soon fly off. With the siege smoke’s scale of 2,amount = 1throws the particles away within a few seconds; - when an event starts its effect, and what happens to it when you pick another state;
- the shape and look of a trail;
- a
childsystemblock inside asubsystem: it takes the keys of a subsystem, and each particle of the subsystem sends out its particles from where it is, while it lives. A child withlocal_space = yessends them out from the effect’s own place instead. A particle that dies stays, unseen, until its children are gone, so it still counts towardsmax_amount; - the order in which the parts of an effect are drawn, which decides what covers what. First come
the effect’s particles that are not trails, subsystem by subsystem in the file’s order. After
each subsystem come its particles’ child systems, parent by parent. The trails come last, in the
same order. A trail without its own shader effect comes only while the effect’s other particles
are not on screen, or after a trail with its own effect (see the trail above).
A subsystem’s
sortchanges the order of its particles, and so the order of their child systems too. Like the game, Etch sorts a little each frame, so the order settles over a few frames after you turn the camera. The game never moves the last particle in its list, which is usually the newest, so that one is drawn last whatever its distance. A subsystem with only two particles is not sorted at all.
These parts differ:
- The exact direction and other chance values of each particle, and the swirl of a
turbulenceforce. Etch picks them by the game’s rule and in the game’s order, but the game starts its sequence from the computer’s clock each time an effect starts, so its own shots differ from each other too and Etch cannot match any one of them. - A trail in a mod that adds its own shader effect for it (see Particle effects). The game draws the band with that effect, and so a trail without its own effect that comes after it. Etch still draws both in grey.
- A trail without its own shader effect that comes before a trail with one, in an effect that runs more than once on screen. The game draws it with the effect of the copy drawn just before, so it can show next to sprites. Etch hides it.
- Where a state with a
time_offsetstarts. The game adds a random part of its second number; Etch starts at the first. - How many particles and effects can be alive. Like the game, Etch starts a new copy of an
event’s effect each time the event comes round, while the earlier copies still play. But once
100,000 particles are alive, or 1,000 effects are running, Etch starts no new copy, and the line
at the bottom says so. The game has no limit, so an effect that sends out particles forever,
started on every loop of its state, keeps growing there. The 1,000 effects matter for an effect
that runs forever but keeps few particles alive, such as one with a low
emissionor a shortlife. - A subsystem or child with
local_space = yes. Etch draws it at the model. The game passes the model’s place togfx/FX/particle.shaderinInstanceWorldMatrix, and the base game’s shader does not use it. So in the game these particles show around the map’s south-west corner, and not at the model. The subsystem’spositionmoves them there, itsxtowards the north and itsztowards the east. Etch warns onlocal_space = yeswhen your playset’sparticle.shaderdoes not useInstanceWorldMatrix. To keep the particles at the model, leavelocal_spaceout, or ship aparticle.shaderwhose vertex shader multiplies the position byInstanceWorldMatrix.
What it doesn’t do
Section titled “What it doesn’t do”- It does not draw particle effects exactly as the game does: see Differences from the game.
- It does not draw an attachment that hangs more than six levels down (an entity on an entity on an entity …). Vanilla’s go three levels down at most.
- It combines an entity with its
cloneby Etch’s own reading: how the game does it is not documented. - It does not change the
.assetfile. - It draws nothing when Etch does not find the game folder.