My Project
BlockTessellators.h
1 #pragma once
2 #include "BlockCommon.h"
3 
4 namespace ParaEngine
5 {
6  class CBlockWorld;
7  class BlockChunk;
8  class BlockVertexCompressed;
9 
12  {
13  public:
15 
16  virtual void SetWorld(CBlockWorld* pWorld);
17 
18  int32_t GetAvgVertexLight(int32_t v1, int32_t v2, int32_t v3, int32_t v4);
19 
21  int32_t GetMaxVertexLight(int32_t v1, int32_t v2, int32_t v3, int32_t v4);
22 
26  uint8 GetMeshBrightness(BlockTemplate * pBlockTemplate, uint8* blockBrightness);
27 
31  uint32_t CalculateCubeAO();
32 
33 
40  virtual int32 TessellateBlock(BlockChunk* pChunk, uint16 packedBlockId, BlockRenderMethod dwShaderID, BlockVertexCompressed** pOutputData);
41 
42  public:
43  Block* neighborBlocks[27];
44  uint8_t blockBrightness[27 * 3];
45  BlockModel tessellatedModel;
46 
47  protected:
49  bool UpdateCurrentBlock(BlockChunk* pChunk, uint16 packedBlockId);
50 
56  void FetchNearbyBlockInfo(BlockChunk* pChunk, const Uint16x3& packedBlockId, int nNearbyBlockCount = 27, int nNearbyLightCount = -1);
57 
58  protected:
59  CBlockWorld* m_pWorld;
60  BlockTemplate * m_pCurBlockTemplate;
61  uint32 m_nBlockData;
62  BlockModel* m_pCurBlockModel;
63  // world space location.
64  Uint16x3 m_blockId_ws;
65  // chunk containing current block.
66  BlockChunk* m_pChunk;
67  // chunk space coordinate.
68  Uint16x3 m_blockId_cs;
69  };
70 
73  {
74  public:
77  virtual int32 TessellateBlock(BlockChunk* pChunk, uint16 packedBlockId, BlockRenderMethod dwShaderID, BlockVertexCompressed** pOutputData);
78 
79 
80  protected:
81  void TessellateLiquidOrIce(BlockRenderMethod dwShaderID);
82  void TessellateStdCube(BlockRenderMethod dwShaderID);
83  void TessellateUniformLightingCustomModel(BlockRenderMethod dwShaderID);
84  void TessellateSelfLightingCustomModel(BlockRenderMethod dwShaderID);
85 
86 
87  };
88 }
int32_t GetMaxVertexLight(int32_t v1, int32_t v2, int32_t v3, int32_t v4)
not used.
Definition: BlockTessellators.cpp:39
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: BlockModel.h:12
Definition: BlockChunk.h:14
Definition: BlockModel.h:172
basic block world coordinate
Definition: BlockCoordinate.h:72
uint8 GetMeshBrightness(BlockTemplate *pBlockTemplate, uint8 *blockBrightness)
Definition: BlockTessellators.cpp:46
virtual int32 TessellateBlock(BlockChunk *pChunk, uint16 packedBlockId, BlockRenderMethod dwShaderID, BlockVertexCompressed **pOutputData)
generate triangles for a given block in a block world, taking all nearby blocks into consideration...
Definition: BlockTessellators.cpp:34
base class for an instance of block world
Definition: BlockWorld.h:35
uint32_t CalculateCubeAO()
calculate ambient occlusion flags for cube model.
Definition: BlockTessellators.cpp:111
generate tessellated vertices for a given block in the world.
Definition: BlockTessellators.h:11
void FetchNearbyBlockInfo(BlockChunk *pChunk, const Uint16x3 &packedBlockId, int nNearbyBlockCount=27, int nNearbyLightCount=-1)
fetch and update nearby (3*3*3=27 blocks) block id and block brightness.
Definition: BlockTessellators.cpp:94
Chunk is a 16*16*16 inside a region.
Definition: BlockChunk.h:138
block template base class.
Definition: BlockTemplate.h:15
custom model tessellation like button, stairs, etc.
Definition: BlockTessellators.h:72
bool UpdateCurrentBlock(BlockChunk *pChunk, uint16 packedBlockId)
update the current block info, including all block position, m_pCurBlockModel, m_nBlockData, etc.
Definition: BlockTessellators.cpp:70