My Project
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
ParaEngine::BlockTemplate Class Reference

block template base class. More...

#include <BlockTemplate.h>

Public Types

enum  BlockAttrubiteFlag {
  batt_obstruction = 0x0000001, batt_breakable = 0x0000002, batt_solid = 0x0000004, batt_liquid = 0x0000008,
  batt_blendedTexture = 0x0000010, batt_light = 0x0000020, batt_cubeModel = 0x0000040, batt_customModel = 0x0000080,
  batt_transparent = 0x0000100, batt_twoTexture = 0x0000200, batt_alphaTestTexture = 0x0000400, batt_singleSideTex = 0x0000800,
  batt_threeSideTex = 0x0001000, batt_fourSideTex = 0x0002000, batt_sixSideTex = 0x0004000, batt_climbable = 0x0008000,
  batt_blockcamera = 0x0010000, batt_framemove = 0x0020000, batt_onload = 0x0040000, batt_color_data = 0x0080000,
  batt_invisible = 0x0100000, batt_tiling = 0x0200000
}
 

Public Member Functions

 BlockTemplate (uint16_t id, uint32_t attFlag, uint16_t category_id)
 
void Init (uint32_t attFlag, uint16_t category_id)
 
uint16_t GetID () const
 
uint16_t GetCategoryID () const
 
uint32_t GetAttFlag () const
 
bool IsMatchAttribute (uint32_t attFlags) const
 if match any of the given attributes
 
bool IsMatchAttributes (uint32_t dwMask, uint32_t attFlags) const
 all attributes as specified in dwMask must match the value of attFlags
 
bool IsMatchAttributeAll (uint32_t attFlags) const
 if match all of the given attributes
 
bool HasColorData () const
 whether the block contains color data. More...
 
void SetAttribute (DWORD dwAtt, bool bTurnOn=true)
 enable or disable a given attribute. More...
 
uint8_t GetTorchLight ()
 torch default to 15
 
uint8_t GetLightValue ()
 get light value. More...
 
void SetTorchLight (uint8_t value)
 set torch light value
 
bool IsShadowCaster ()
 whether it is shadow caster. More...
 
void SetTexture0 (const char *texName, int nIndex=0)
 
void SetTexture1 (const char *texName)
 
void SetNormalMap (const char *texName)
 
TextureEntityGetTexture0 (uint32 nUserData=0)
 
TextureEntityGetTexture1 ()
 
TextureEntityGetNormalMap ()
 
uint16_t GetRenderPriority ()
 
void LoadModel (const std::string &sModelName)
 load from known model name
 
void SetAssociatedBlock (uint16_t associated_blockid)
 set associated block
 
BlockModelGetBlockModel (int nIndex=0)
 get the default block model. More...
 
BlockModelCreateGetBlockModel (int nIndex=0)
 
BlockModelGetBlockModelByData (uint32 nData)
 
BlockModelGetBlockModel (CBlockWorld *pBlockManager, uint16_t bx, uint16_t by, uint16_t bz, uint16_t nBlockData=0, Block **neighborBlocks=NULL)
 get model by block position. More...
 
void GetAABB (CBlockWorld *pBlockManager, uint16_t bx, uint16_t by, uint16_t bz, CShapeAABB *pOutAABB)
 get AABB in local space
 
void GetBoundingBoxVertices (Vector3 *pVertices, int *pNumber)
 get bounding box vertices
 
bool IsAssociatedBlockID (uint16_t block_id)
 whether associated
 
bool canProvidePower ()
 Can this block provide power. More...
 
void setProvidePower (bool bValue)
 
bool isBlockNormalCube ()
 
bool isSolidBlock ()
 
float GetPhysicalHeight ()
 physical height of this block. More...
 
float GetPhysicalHeight (CBlockWorld *pBlockManager, uint16_t bx, uint16_t by, uint16_t bz)
 
void SetPhysicalHeight (float fHeight)
 
void SetRenderPriority (uint16_t priority)
 
int32_t GetLightScatterStep ()
 how many light to scatter between neighbor blocks.
 
int32_t GetLightOpacity ()
 
void SetLightOpacity (int32 nValue)
 
bool IsFullyOpaque ()
 solid block without alpha blending is fully opaque
 
bool HasOpacity ()
 if true, it is not a fully transparent block. More...
 
bool IsTransparent ()
 if true, it is fully transparent block. More...
 
bool IsAlphaTestTexture ()
 whether the block model contains no alpha tested texture. More...
 
bool IsAlphaBlendedTexture ()
 
float GetSpeedReductionPercent () const
 [0,1] when player is walking into this block, this is the speed reduction. More...
 
void SetSpeedReductionPercent (float val)
 [0,1] when player is walking into this block, this is the speed reduction. More...
 
void MakeCustomLinearModelProvider (int nModelCount)
 make this model provider as linear for custom models. More...
 
BlockRenderPass GetRenderPass () const
 
void SetRenderPass (BlockRenderPass val)
 
Color GetMapColor () const
 a single color as shown on the mini-map. More...
 
void SetMapColor (Color val)
 
DWORD GetBlockColor (int32_t blockData)
 
DWORD GetDiffuseColor (int32_t blockData)
 
void setUnderWaterColor (const Color &val)
 
const ColorgetUnderWaterColor () const
 
int getTileSize () const
 

Static Public Attributes

static const uint16_t g_maxRenderPriority = 0xf
 

Friends

class IBlockModelProvider
 

Detailed Description

block template base class.

Member Function Documentation

§ canProvidePower()

bool ParaEngine::BlockTemplate::canProvidePower ( )
inline

Can this block provide power.

Only wire currently seems to have this change based on its state.

§ GetBlockModel() [1/2]

BlockModel & ParaEngine::BlockTemplate::GetBlockModel ( int  nIndex = 0)

get the default block model.

Parameters
nIndexmodel index default to 0

§ GetBlockModel() [2/2]

BlockModel & ParaEngine::BlockTemplate::GetBlockModel ( CBlockWorld pBlockManager,
uint16_t  bx,
uint16_t  by,
uint16_t  bz,
uint16_t  nBlockData = 0,
Block **  neighborBlocks = NULL 
)

get model by block position.

Parameters
neighborBlocks27 neighbor blocks

§ GetLightValue()

uint8_t ParaEngine::BlockTemplate::GetLightValue ( )
inline

get light value.

§ GetMapColor()

Color ParaEngine::BlockTemplate::GetMapColor ( ) const

a single color as shown on the mini-map.

It is usually the average color of the block's texture. This color is also used in BMax Model

§ GetPhysicalHeight()

float ParaEngine::BlockTemplate::GetPhysicalHeight ( )

physical height of this block.

for non-obstruction block, this will always return -1.f. for obstruction block, this usually returns 1.0f. for slabs, it will return 0.5. for lily pad, it will return 0.

§ GetSpeedReductionPercent()

float ParaEngine::BlockTemplate::GetSpeedReductionPercent ( ) const

[0,1] when player is walking into this block, this is the speed reduction.

default to 1.0, which is no speed reduction.

§ HasColorData()

bool ParaEngine::BlockTemplate::HasColorData ( ) const
inline

whether the block contains color data.

whether it is a cube block without texture and whose data field contains color index. we will use a single pass to draw all blocks of different colors.

§ HasOpacity()

bool ParaEngine::BlockTemplate::HasOpacity ( )
inline

if true, it is not a fully transparent block.

§ IsAlphaTestTexture()

bool ParaEngine::BlockTemplate::IsAlphaTestTexture ( )
inline

whether the block model contains no alpha tested texture.

Since we will use a fast shader and early Z for such block rendering.

§ IsShadowCaster()

bool ParaEngine::BlockTemplate::IsShadowCaster ( )
inline

whether it is shadow caster.

most blocks default to true, except for water blocks.

§ IsTransparent()

bool ParaEngine::BlockTemplate::IsTransparent ( )
inline

if true, it is fully transparent block.

§ MakeCustomLinearModelProvider()

void ParaEngine::BlockTemplate::MakeCustomLinearModelProvider ( int  nModelCount)

make this model provider as linear for custom models.

§ SetAttribute()

void ParaEngine::BlockTemplate::SetAttribute ( DWORD  dwAtt,
bool  bTurnOn = true 
)

enable or disable a given attribute.

Parameters
dwAtt
bTurnOntrue to turn on, false to turn off.

§ SetSpeedReductionPercent()

void ParaEngine::BlockTemplate::SetSpeedReductionPercent ( float  val)

[0,1] when player is walking into this block, this is the speed reduction.

default to 1.0, which is no speed reduction.


The documentation for this class was generated from the following files: