2 #include "BlockCommon.h" 3 #include "BlockModel.h" 10 class IBlockModelProvider;
18 static const uint16_t g_maxRenderPriority;
19 enum BlockAttrubiteFlag
21 batt_obstruction = 0x0000001,
22 batt_breakable = 0x0000002,
23 batt_solid = 0x0000004,
24 batt_liquid = 0x0000008,
25 batt_blendedTexture = 0x0000010,
26 batt_light = 0x0000020,
27 batt_cubeModel = 0x0000040,
28 batt_customModel = 0x0000080,
30 batt_transparent = 0x0000100,
31 batt_twoTexture = 0x0000200,
32 batt_alphaTestTexture = 0x0000400,
34 batt_singleSideTex = 0x0000800,
35 batt_threeSideTex = 0x0001000,
36 batt_fourSideTex = 0x0002000,
37 batt_sixSideTex = 0x0004000,
38 batt_climbable = 0x0008000,
39 batt_blockcamera = 0x0010000,
41 batt_framemove = 0x0020000,
42 batt_onload = 0x0040000,
43 batt_color_data = 0x0080000,
45 batt_invisible = 0x0100000,
47 batt_tiling = 0x0200000,
50 BlockTemplate(uint16_t
id,uint32_t attFlag, uint16_t category_id);
54 void Init(uint32_t attFlag, uint16_t category_id);
56 inline uint16_t GetID()
const 61 inline uint16_t GetCategoryID()
const 66 inline uint32_t GetAttFlag()
const 74 return ((m_attFlag & attFlags) > 0);
80 return ((m_attFlag & dwMask) == attFlags);
86 return ((m_attFlag & attFlags) == attFlags);
96 return ((m_attFlag & batt_color_data) == batt_color_data);
109 return m_nLightValue;
114 return m_nLightValue;
123 void SetTexture0(
const char* texName,
int nIndex = 0);
125 void SetTexture1(
const char* texName);
127 void SetNormalMap(
const char* texName);
138 inline uint16_t GetRenderPriority()
140 return m_renderPriority;
144 void LoadModel(
const std::string& sModelName);
153 BlockModel& CreateGetBlockModel(
int nIndex = 0);
155 BlockModel& GetBlockModelByData(uint32 nData);
176 void setProvidePower(
bool bValue);
178 bool isBlockNormalCube();
185 void SetPhysicalHeight(
float fHeight);
190 inline void SetRenderPriority(uint16_t priority)
192 if(priority > g_maxRenderPriority)
193 priority = g_maxRenderPriority;
194 m_renderPriority = priority;
200 return m_lightScatterStep;
206 inline int32_t GetLightOpacity() {
207 return m_lightOpacity;
209 void SetLightOpacity(int32 nValue);
214 return m_lightOpacity >= 15;
219 return m_lightOpacity > 1;
224 return m_lightOpacity <= 1;
232 inline bool IsAlphaBlendedTexture(){
246 inline BlockRenderPass GetRenderPass()
const {
return m_renderPass; }
247 void SetRenderPass(BlockRenderPass val) { m_renderPass = val; }
253 void SetMapColor(
Color val);
254 DWORD GetBlockColor(int32_t blockData);
255 DWORD GetDiffuseColor(int32_t blockData);
256 void setUnderWaterColor(
const Color & val);
257 const Color & getUnderWaterColor()
const;
258 int getTileSize()
const {
return mTileSize; }
263 uint16_t m_category_id;
265 uint16_t m_associated_blockid;
267 uint16_t m_renderPriority;
269 BlockRenderPass m_renderPass;
274 int32_t m_lightScatterStep;
276 int32 m_lightOpacity;
280 float m_fPhysicalHeight;
282 float m_fSpeedReductionPercent;
284 bool m_bIsShadowCaster;
285 bool m_bProvidePower;
287 std::vector<TextureEntity*> m_textures0;
288 std::vector<TextureEntity*> m_textures1;
290 uint8_t m_nLightValue;
291 std::string m_secondTexName;
292 std::string m_normalMapName;
293 std::vector<BlockModel> m_block_models;
297 Color m_UnderWaterColor;
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
bool IsTransparent()
if true, it is fully transparent block.
Definition: BlockTemplate.h:223
bool IsMatchAttributeAll(uint32_t attFlags) const
if match all of the given attributes
Definition: BlockTemplate.h:84
void SetSpeedReductionPercent(float val)
[0,1] when player is walking into this block, this is the speed reduction.
Definition: BlockTemplate.cpp:501
bool HasColorData() const
whether the block contains color data.
Definition: BlockTemplate.h:94
void SetTorchLight(uint8_t value)
set torch light value
Definition: BlockTemplate.cpp:412
bool HasOpacity()
if true, it is not a fully transparent block.
Definition: BlockTemplate.h:218
different physics engine has different winding order.
Definition: EventBinding.h:32
uint8_t GetTorchLight()
torch default to 15
Definition: BlockTemplate.h:107
Definition: BlockChunk.h:14
Definition: BlockModel.h:172
Color GetMapColor() const
a single color as shown on the mini-map.
Definition: BlockTemplate.cpp:535
void GetBoundingBoxVertices(Vector3 *pVertices, int *pNumber)
get bounding box vertices
Definition: BlockTemplate.cpp:206
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
bool IsMatchAttributes(uint32_t dwMask, uint32_t attFlags) const
all attributes as specified in dwMask must match the value of attFlags
Definition: BlockTemplate.h:78
void GetAABB(CBlockWorld *pBlockManager, uint16_t bx, uint16_t by, uint16_t bz, CShapeAABB *pOutAABB)
get AABB in local space
Definition: BlockTemplate.cpp:418
bool IsFullyOpaque()
solid block without alpha blending is fully opaque
Definition: BlockTemplate.h:213
AABB-related code.
Definition: ShapeAABB.h:11
void SetAttribute(DWORD dwAtt, bool bTurnOn=true)
enable or disable a given attribute.
Definition: BlockTemplate.cpp:488
base class for an instance of block world
Definition: BlockWorld.h:35
bool IsMatchAttribute(uint32_t attFlags) const
if match any of the given attributes
Definition: BlockTemplate.h:72
void MakeCustomLinearModelProvider(int nModelCount)
make this model provider as linear for custom models.
Definition: BlockTemplate.cpp:512
BlockModel & GetBlockModel(int nIndex=0)
get the default block model.
Definition: BlockTemplate.cpp:232
float GetSpeedReductionPercent() const
[0,1] when player is walking into this block, this is the speed reduction.
Definition: BlockTemplate.cpp:496
Definition: enum_maker.hpp:46
int32_t GetLightScatterStep()
how many light to scatter between neighbor blocks.
Definition: BlockTemplate.h:199
block template base class.
Definition: BlockTemplate.h:15
interface class for filtering block models.
Definition: BlockModelProvider.h:12
float GetPhysicalHeight()
physical height of this block.
Definition: BlockTemplate.cpp:462
void SetAssociatedBlock(uint16_t associated_blockid)
set associated block
Definition: BlockTemplate.cpp:392
bool IsShadowCaster()
whether it is shadow caster.
Definition: BlockTemplate.h:121
bool IsAlphaTestTexture()
whether the block model contains no alpha tested texture.
Definition: BlockTemplate.h:228
bool canProvidePower()
Can this block provide power.
Definition: BlockTemplate.h:174
Definition: ParaColor.h:275
bool IsAssociatedBlockID(uint16_t block_id)
whether associated
Definition: BlockTemplate.cpp:397
void LoadModel(const std::string &sModelName)
load from known model name
Definition: BlockTemplate.cpp:249
uint8_t GetLightValue()
get light value.
Definition: BlockTemplate.h:113