Luanti 5.11.0-dev
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
27
28// Material flags
29// Should backface culling be enabled?
30#define MATERIAL_FLAG_BACKFACE_CULLING 0x01
31// Should a crack be drawn?
32#define MATERIAL_FLAG_CRACK 0x02
33// Should the crack be drawn on transparent pixels (unset) or not (set)?
34// Ignored if MATERIAL_FLAG_CRACK is not set.
35#define MATERIAL_FLAG_CRACK_OVERLAY 0x04
36#define MATERIAL_FLAG_ANIMATION 0x08
37//#define MATERIAL_FLAG_HIGHLIGHTED 0x10
38#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
39#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
40
41/*
42 This fully defines the looks of a tile.
43 The SMaterial of a tile is constructed according to this.
44*/
46{
47 FrameSpec() = default;
48
49 u32 texture_id = 0;
50 video::ITexture *texture = nullptr;
51};
52
58#define MAX_TILE_LAYERS 2
59
62{
63 TileLayer() = default;
64
68 bool operator==(const TileLayer &other) const
69 {
70 return
71 texture_id == other.texture_id &&
74 has_color == other.has_color &&
75 color == other.color &&
76 scale == other.scale;
77 }
78
82 bool operator!=(const TileLayer &other) const
83 {
84 return !(*this == other);
85 }
86
87 void applyMaterialOptions(video::SMaterial &material) const;
88
89 void applyMaterialOptionsWithShaders(video::SMaterial &material) const;
90
92 bool isTransparent() const
93 {
94 // see also: the mapping in ShaderSource::generateShader()
95 switch (material_type) {
100 return true;
101 }
102 return false;
103 }
104
105 // Ordered for size, please do not reorder
106
107 video::ITexture *texture = nullptr;
108
109 u32 shader_id = 0;
110
111 u32 texture_id = 0;
112
115
118 //0 // <- DEBUG, Use the one below
122
123 std::vector<FrameSpec> *frames = nullptr;
124
129 video::SColor color = video::SColor(0, 0, 0, 0);
130
132 bool has_color = false;
133
134 u8 scale = 1;
135};
136
137enum class TileRotation: u8 {
138 None,
139 R90,
140 R180,
141 R270,
142};
143
Definition tile.h:46
video::ITexture * texture
Definition tile.h:50
u32 texture_id
Definition tile.h:49
FrameSpec()=default
Defines a layer of a tile.
Definition tile.h:62
video::SColor color
Definition tile.h:129
bool operator==(const TileLayer &other) const
Definition tile.h:68
std::vector< FrameSpec > * frames
Definition tile.h:123
bool has_color
If true, the tile has its own color.
Definition tile.h:132
void applyMaterialOptionsWithShaders(video::SMaterial &material) const
Definition tile.cpp:40
u8 scale
Definition tile.h:134
void applyMaterialOptions(video::SMaterial &material) const
Definition tile.cpp:8
TileLayer()=default
u16 animation_frame_count
Definition tile.h:114
u8 material_flags
Definition tile.h:117
video::ITexture * texture
Definition tile.h:107
u32 shader_id
Definition tile.h:109
u16 animation_frame_length_ms
Definition tile.h:113
bool isTransparent() const
Definition tile.h:92
u8 material_type
Definition tile.h:116
u32 texture_id
Definition tile.h:111
bool operator!=(const TileLayer &other) const
Definition tile.h:82
Definition tile.h:148
TileSpec()=default
TileRotation rotation
Tile rotation.
Definition tile.h:154
bool world_aligned
If true, the tile rotation is ignored.
Definition tile.h:152
u8 emissive_light
This much light does the tile emit.
Definition tile.h:156
TileLayer layers[MAX_TILE_LAYERS]
The first is base texture, the second is overlay.
Definition tile.h:158
#define MATERIAL_FLAG_BACKFACE_CULLING
Definition tile.h:30
#define MATERIAL_FLAG_TILEABLE_VERTICAL
Definition tile.h:39
TileRotation
Definition tile.h:137
MaterialType
Definition tile.h:12
@ TILE_MATERIAL_PLAIN_ALPHA
Definition tile.h:25
@ 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:24
#define MATERIAL_FLAG_TILEABLE_HORIZONTAL
Definition tile.h:38
#define MAX_TILE_LAYERS
We have two tile layers: layer 0 = base layer 1 = overlay.
Definition tile.h:58