Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
tile.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "irrlichttypes.h"
8#include <ITexture.h>
9#include <vector>
10#include <SMaterial.h>
11
26
27// Material flags
28// Should backface culling be enabled?
29#define MATERIAL_FLAG_BACKFACE_CULLING 0x01
30// Should a crack be drawn?
31#define MATERIAL_FLAG_CRACK 0x02
32// Should the crack be drawn on transparent pixels (unset) or not (set)?
33// Ignored if MATERIAL_FLAG_CRACK is not set.
34#define MATERIAL_FLAG_CRACK_OVERLAY 0x04
35#define MATERIAL_FLAG_ANIMATION 0x08
36//#define MATERIAL_FLAG_HIGHLIGHTED 0x10
37#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
38#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
39
40/*
41 This fully defines the looks of a tile.
42 The SMaterial of a tile is constructed according to this.
43*/
45{
46 FrameSpec() = default;
47
48 u32 texture_id = 0;
49 video::ITexture *texture = nullptr;
50};
51
52#define MAX_TILE_LAYERS 2
53
56{
57 TileLayer() = default;
58
62 bool operator==(const TileLayer &other) const
63 {
64 return
65 texture_id == other.texture_id &&
68 has_color == other.has_color &&
69 color == other.color &&
70 scale == other.scale;
71 }
72
76 bool operator!=(const TileLayer &other) const
77 {
78 return !(*this == other);
79 }
80
81 void applyMaterialOptions(video::SMaterial &material) const;
82
83 void applyMaterialOptionsWithShaders(video::SMaterial &material) const;
84
85 bool isTransparent() const
86 {
87 switch (material_type) {
91 return true;
92 }
93 return false;
94 }
95
96 // Ordered for size, please do not reorder
97
98 video::ITexture *texture = nullptr;
99
100 u32 shader_id = 0;
101
102 u32 texture_id = 0;
103
106
109 //0 // <- DEBUG, Use the one below
113
115 bool has_color = false;
116
117 std::vector<FrameSpec> *frames = nullptr;
118
123 video::SColor color = video::SColor(0, 0, 0, 0);
124
125 u8 scale = 1;
126};
127
128enum class TileRotation: u8 {
129 None,
130 R90,
131 R180,
132 R270,
133};
134
Definition tile.h:45
video::ITexture * texture
Definition tile.h:49
u32 texture_id
Definition tile.h:48
FrameSpec()=default
Defines a layer of a tile.
Definition tile.h:56
video::SColor color
Definition tile.h:123
bool operator==(const TileLayer &other) const
Definition tile.h:62
std::vector< FrameSpec > * frames
Definition tile.h:117
bool has_color
If true, the tile has its own color.
Definition tile.h:115
void applyMaterialOptionsWithShaders(video::SMaterial &material) const
Definition tile.cpp:40
u8 scale
Definition tile.h:125
void applyMaterialOptions(video::SMaterial &material) const
Definition tile.cpp:8
TileLayer()=default
u16 animation_frame_count
Definition tile.h:105
u8 material_flags
Definition tile.h:108
video::ITexture * texture
Definition tile.h:98
u32 shader_id
Definition tile.h:100
u16 animation_frame_length_ms
Definition tile.h:104
bool isTransparent() const
Definition tile.h:85
u8 material_type
Definition tile.h:107
u32 texture_id
Definition tile.h:102
bool operator!=(const TileLayer &other) const
Definition tile.h:76
Definition tile.h:139
TileSpec()=default
TileRotation rotation
Tile rotation.
Definition tile.h:145
bool world_aligned
If true, the tile rotation is ignored.
Definition tile.h:143
u8 emissive_light
This much light does the tile emit.
Definition tile.h:147
TileLayer layers[MAX_TILE_LAYERS]
The first is base texture, the second is overlay.
Definition tile.h:149
#define MATERIAL_FLAG_BACKFACE_CULLING
Definition tile.h:29
#define MATERIAL_FLAG_TILEABLE_VERTICAL
Definition tile.h:38
TileRotation
Definition tile.h:128
MaterialType
Definition tile.h:12
@ TILE_MATERIAL_PLAIN_ALPHA
Definition tile.h:24
@ TILE_MATERIAL_OPAQUE
Definition tile.h:19
@ TILE_MATERIAL_LIQUID_TRANSPARENT
Definition tile.h:15
@ TILE_MATERIAL_WAVING_PLANTS
Definition tile.h:18
@ TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT
Definition tile.h:21
@ TILE_MATERIAL_BASIC
Definition tile.h:13
@ TILE_MATERIAL_LIQUID_OPAQUE
Definition tile.h:16
@ TILE_MATERIAL_WAVING_LIQUID_OPAQUE
Definition tile.h:22
@ TILE_MATERIAL_WAVING_LIQUID_BASIC
Definition tile.h:20
@ TILE_MATERIAL_WAVING_LEAVES
Definition tile.h:17
@ TILE_MATERIAL_ALPHA
Definition tile.h:14
@ TILE_MATERIAL_PLAIN
Definition tile.h:23
#define MATERIAL_FLAG_TILEABLE_HORIZONTAL
Definition tile.h:37
#define MAX_TILE_LAYERS
Definition tile.h:52