Item rendering
This commit is contained in:
@@ -60,8 +60,8 @@ a texture per growth stage:
|
||||
matches always.
|
||||
- A variant sets any of `model`, `textures`, `y`, a turn around the vertical axis of 0, 90, 180 or 270 degrees,
|
||||
clockwise seen from above, `x`, a turn around the east-west axis done before `y`, where 90 tips the model's top to the
|
||||
north, and [`shape`](../resources/models.md#shapes). Like Minecraft's, a model pointing up points north with `"x": 90`
|
||||
and east with `"x": 90, "y": 90`.
|
||||
north, [`uvlock`](../resources/models.md#turning-textures), and [`shape`](../resources/models.md#shapes). Like
|
||||
Minecraft's, a model pointing up points north with `"x": 90` and east with `"x": 90, "y": 90`.
|
||||
- **Each of them comes from the first matching variant that sets it.** So one variant can turn the block and a later one
|
||||
change its textures, and both apply.
|
||||
- What no matching variant sets comes from the block itself.
|
||||
|
||||
@@ -51,6 +51,7 @@ down to 0 is gone.
|
||||
| `tool` | none | Makes it a [tool](tools.md). |
|
||||
| `food` | none | Makes it [edible](food.md). |
|
||||
| `data_textures` | none | Other textures, picked by the stack's `data`, see below. |
|
||||
| `model` | none | A [model](../resources/models.md#item-models) it's drawn with instead of its texture. |
|
||||
| `worn` | none | How it looks worn on a player, see [below](#worn-models). |
|
||||
| `targets_liquids` | `false` | Players holding it aim at liquids, like buckets and fishing rods. Others aim through. |
|
||||
| `components` | none | [Item components](#item-components) and their parameters. |
|
||||
|
||||
@@ -75,14 +75,15 @@ on every face, since `top` and `bottom` default to `#side`.
|
||||
| `faces.*.uv` | `[u1, v1, u2, v2]`, the part of the texture in pixels. Defaults to the part the face covers. |
|
||||
| `faces.*.rotation` | Turns the texture on the face clockwise by 0, 90, 180 or 270 degrees. |
|
||||
| `faces.*.cullface` | Hides the face when the neighbor on that side is a solid block. Only for faces on the block's edge. |
|
||||
| `display` | Where an item drawn with this model is shown, and how, see [Display Transforms](#display-transforms). |
|
||||
|
||||
Faces are only drawn from the front, so a flat plane that should be seen from both sides needs a face each way.
|
||||
|
||||
## Parents
|
||||
|
||||
A model can start from another with `parent`, like Minecraft's. It gets the parent's elements unless it has its own, and
|
||||
the parent's texture defaults, with its own winning. A parent can have a parent too. `models/brass_gear.json` reuses a
|
||||
gear's shape with other textures:
|
||||
the parent's texture defaults and [display transforms](#display-transforms), with its own winning. A parent can have a
|
||||
parent too. `models/brass_gear.json` reuses a gear's shape with other textures:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -184,12 +185,57 @@ they set their own, so one pair of models serves every kind of wood. Parts repla
|
||||
What sets the states is up to the block's [components](../blocks/components.md): the fences' `bworld:fence` sets them
|
||||
from what's beside it, every time something next to it changes.
|
||||
|
||||
## Turning Textures
|
||||
|
||||
A model turned by a variant's or part's `x` or `y` takes its textures with it, so the planks on a turned stair's step
|
||||
run another way than on the block next to it. With `"uvlock": true`, like Minecraft's, each face's texture stays where
|
||||
it would be on an unturned block instead:
|
||||
|
||||
```json
|
||||
"variants": {
|
||||
"facing=1": { "y": 90, "uvlock": true }
|
||||
}
|
||||
```
|
||||
|
||||
A face that shows part of its texture, with `uv`, gets the part turned around the texture's middle, which for a face
|
||||
covering part of the block is the part at its new place.
|
||||
|
||||
## Item Models
|
||||
|
||||
`item_model` draws a block's item with another model, filled in with the block's textures, like Minecraft's
|
||||
`fence_inventory`. Fences use `bworld:fence_inventory`, two posts and the bars between them, since a single post
|
||||
wouldn't look like a fence. It's drawn in slots, in hands and on the ground.
|
||||
|
||||
An item that isn't a block's can be drawn with a model too, with [`model`](../items/index.md#properties) instead of its
|
||||
flat texture, like Create's wrench. The model fills in its texture variables with its own `textures`, since there's no
|
||||
block to give them. The item still needs a `texture`, which the importer takes from the model's `particle`.
|
||||
|
||||
### Display Transforms
|
||||
|
||||
An item drawn with a model is placed like a block's item unless its model says otherwise: turned to show its top and two
|
||||
sides in slots, held up like a block, and small on the ground. A model's `display` places it its own way, in Minecraft's
|
||||
format, so a wrench can lie at an angle in its slot and be held like a tool:
|
||||
|
||||
```json
|
||||
"display": {
|
||||
"gui": { "rotation": [28, -163, 43], "translation": [0.5, 0, 0], "scale": [1.1, 1.1, 1.1] },
|
||||
"firstperson_righthand": { "rotation": [-4.5, 100.25, 10], "translation": [1, 4, 1] }
|
||||
}
|
||||
```
|
||||
|
||||
| Place | Where the item is |
|
||||
| ----------------------- | --------------------------------------------------------------------------------- |
|
||||
| `gui` | In a slot, the 16 pixels of the item's model across the slot. |
|
||||
| `firstperson_righthand` | Held, in first person. |
|
||||
| `ground` | Dropped, spinning. |
|
||||
| `fixed` | Standing on a block with [`item_display`](../blocks/tiledata.md#showing-an-item). |
|
||||
|
||||
Each is `{ rotation, translation, scale }`, all `[x, y, z]` and all around the model's middle: `translation` moves it in
|
||||
pixels, `rotation` turns it in degrees around each axis the way Minecraft's does, and `scale` sizes it. They start from
|
||||
the same places Minecraft's do, so a transform made for Minecraft, like in Blockbench's Display tab, looks the same
|
||||
here. A model gets its parent's transform for each place it doesn't set its own. Minecraft's other places, like third
|
||||
person, aren't used.
|
||||
|
||||
## Lighting
|
||||
|
||||
Faces flat against the block's edge get smooth lighting and ambient occlusion like a full block's. Anything inside the
|
||||
|
||||
Reference in New Issue
Block a user