My Project
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ParaEngine::BlockWorldClient Class Reference

this is a singleton client side block world instance. More...

#include <BlockWorldClient.h>

Inheritance diagram for ParaEngine::BlockWorldClient:
ParaEngine::CBlockWorld ParaEngine::IAttributeFields ParaEngine::IObjectScriptingInterface ParaEngine::IObject ParaEngine::CRefCounted

Public Member Functions

virtual int GetAttributeClassID ()
 attribute class ID should be identical, unless one knows how overriding rules work. More...
 
virtual const char * GetAttributeClassName ()
 a static string, describing the attribute class object's name
 
virtual const char * GetAttributeClassDescription ()
 a static string, describing the attribute class object
 
virtual int InstallFields (CAttributeClass *pClass, bool bOverride)
 this class should be implemented if one wants to add new attribute. More...
 
virtual IAttributeFieldsGetChildAttributeObject (const std::string &sName)
 get attribute by child object. More...
 
virtual int GetChildAttributeObjectCount (int nColumnIndex=0)
 get the number of child objects (row count) in the given column. More...
 
virtual int GetChildAttributeColumnCount ()
 we support multi-dimensional child object. More...
 
virtual IAttributeFieldsGetChildAttributeObject (int nRowIndex, int nColumnIndex=0)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetBlockLightColor_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetBlockLightColor_s, Vector3)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetPostProcessingScript_s, const char *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetPostProcessingAlphaScript_s, const char *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetUseSunlightShadowMap_s, bool *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetUseSunlightShadowMap_s, bool)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, HasSunlightShadowMap_s, bool *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetUseWaterReflection_s, bool *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetUseWaterReflection_s, bool)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, CanUseAdvancedShading_s, bool *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, IsMovieOutputMode_s, bool *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, EnableMovieOutputMode_s, bool)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetVertexBufferSizeLimit_s, int *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetVertexBufferSizeLimit_s, int)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, IsAsyncChunkMode_s, bool *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetAsyncChunkMode_s, bool)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetAlwaysInVertexBufferChunkRadius_s, int *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetAlwaysInVertexBufferChunkRadius_s, int)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetMaxVisibleVertexBufferBytes_s, int *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetMaxVisibleVertexBufferBytes_s, int)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetNearCameraChunkDist_s, int *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetNearCameraChunkDist_s, int)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetMaxBufferRebuildPerTick_s, int *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetMaxBufferRebuildPerTick_s, int)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetMaxBufferRebuildPerTick_FarChunk_s, int *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetMaxBufferRebuildPerTick_FarChunk_s, int)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, GetUsePointTextureFiltering_s, bool *)
 
 ATTRIBUTE_METHOD1 (BlockWorldClient, SetUsePointTextureFiltering_s, bool)
 
virtual void EnterWorld (const string &sWorldDir, float x, float y, float z)
 
virtual void LeaveWorld ()
 
virtual void UpdateVisibleChunks (bool bIsShadowPass=false)
 
virtual void ClearBlockRenderCache ()
 clear block render cache
 
void DeleteAllBlocks ()
 
virtual void SetBlockRenderMethod (BlockRenderMethod method)
 how blocks are preferred to be rendered. More...
 
void PreRender (bool bIsShadowPass=false)
 
void CheckRebuildVisibleChunks (bool bAsyncMode=true, bool bIsShadowPass=false)
 
void Render (BlockRenderPass nRenderPass=BlockRenderPass_Opaque, std::vector< BlockRenderTask *> *pCurRenderQueue=NULL, int nRenderMethod=-1)
 render all blocks in render queue using the given pass More...
 
void RenderDeferredLights ()
 render light geometry. More...
 
std::vector< BlockRenderTask * > * GetRenderQueueByPass (BlockRenderPass nRenderPass)
 
void RenderShadowMap ()
 render shadow map pass
 
virtual void AddRenderTask (BlockRenderTask *pRenderTask)
 
void SetDamagedBlock (uint16_t wx, uint16_t wy, uint16_t wz)
 
void SetDamagedBlockDegree (float degree)
 
bool IsPointUnderWater (const Vector3 &vPos)
 check whether a specified point is under the water surface. More...
 
void SetBlockLightColor (const LinearColor &color)
 default block emissive light color. More...
 
LinearColor GetBlockLightColor ()
 default block emissive light color. More...
 
void SetSelectionTexture (const char *textureName)
 used to render selection texture. More...
 
std::string GetSelectionTexture ()
 
void SetDamageTexture (const char *textureName)
 used to render damaged texture. More...
 
std::string GetDamageTexture ()
 
float GetWaterLevel (float x, float y, float z, int nRayLength=2)
 get the water block level just nRayLength blocks under the given positions it will also check global real water height and use the higher. More...
 
void InitDeviceObjects ()
 this function currently does nothing
 
void RestoreDeviceObjects ()
 
void DeleteDeviceObjects ()
 must call this function when device is lost.
 
void InvalidateDeviceObjects ()
 must call this function when device is invalid.
 
void RendererRecreated ()
 
void DoPostRenderingProcessing (BlockRenderPass nRenderPass=BlockRenderPass_Opaque)
 do post rendering processing
 
void RestoreNormalShader ()
 
void Cleanup ()
 
bool PrepareAllRenderTargets (bool bSetRenderTarget=true)
 call this function to set up all render targets for fancy graphics if any. More...
 
bool DrawMultiFrameBlockWorld ()
 render multi frame block world is enabled. More...
 
bool DrawMultiFrameBlockWorldOnSky ()
 render the image to the screen, with z test enabled and z-write disabled. More...
 
void SetPostProcessingScript (const char *sCallbackScript)
 this is usually set for fancy graphics' composite shader in deferred shading. More...
 
void SetPostProcessingAlphaScript (const char *sCallbackScript)
 
bool CanUseAdvancedShading ()
 check device capabilities for deferred shading. More...
 
void SetUseSunlightShadowMap (bool bEnable)
 whether to use sun light shadow map
 
bool GetUseSunlightShadowMap ()
 
void SetUseWaterReflection (bool bEnable)
 whether to use sun light shadow map
 
bool GetUseWaterReflection ()
 
void PrepareShadowCasters (CShadowMap *pShadowMap)
 prepare shadow casters
 
void RenderDynamicBlocks ()
 render selection and damaged blocks
 
virtual void GetMaxBlockHeightWatchingSky (uint16_t blockX_ws, uint16_t blockZ_ws, ChunkMaxHeight *pResult)
 
bool IsMovieOutputMode () const
 whenever in movie output mode, we will cache all terrain and lighting information. More...
 
void EnableMovieOutputMode (bool val)
 
int GetVertexBufferSizeLimit () const
 for 32 bits version, we need to set the vertex buffer size limit to something like 700MB to prevent running out of 2GB virtual memory. More...
 
void SetVertexBufferSizeLimit (int val)
 
int GetAlwaysInVertexBufferChunkRadius () const
 we will ensure all chunks in this buffer range are also in memory, and not counted in m_nVertexBufferSizeLimit
 
void SetAlwaysInVertexBufferChunkRadius (int val)
 
int GetMaxVisibleVertexBufferBytes () const
 we will only draw when there are less than this number of vertex visible at the current frame. More...
 
void SetMaxVisibleVertexBufferBytes (int val)
 
bool IsAsyncChunkMode () const
 if true, if we want to use a separate thread to fill the chunk buffer.
 
void SetAsyncChunkMode (bool val)
 
int GetNearCameraChunkDist () const
 near camera chunk is always rendered and cached in vertex buffer. More...
 
void SetNearCameraChunkDist (int val)
 
int GetMaxBufferRebuildPerTick () const
 how many chunks to upload to video memory per tick for near camera chunks. More...
 
void SetMaxBufferRebuildPerTick (int val)
 
int GetMaxBufferRebuildPerTick_FarChunk () const
 how many chunks to upload to video memory for far aways chunks per tick. More...
 
void SetMaxBufferRebuildPerTick_FarChunk (int val)
 
bool GetUsePointTextureFiltering ()
 whether to use point texture filtering for all ui images rendered. More...
 
void SetUsePointTextureFiltering (bool bUse)
 
- Public Member Functions inherited from ParaEngine::CBlockWorld
 ATTRIBUTE_METHOD1 (CBlockWorld, GetBlockRenderMethod_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetBlockRenderMethod_s, int)
 
 ATTRIBUTE_METHOD (CBlockWorld, ResumeLightUpdate_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, SuspendLightUpdate_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, ResetAllLight_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, LockWorld_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, UnlockWorld_s)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsLightUpdateSuspended_s, bool *)
 
 ATTRIBUTE_METHOD3 (CBlockWorld, SetChunkColumnTimeStamp_s, float)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetRenderDist_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetRenderDist_s, int)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetDirtyColumnCount_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetDirtyBlockCount_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsReadOnly_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetReadOnly_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsRemote_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetIsRemote_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsServerWorld_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetIsServerWorld_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsSaveLightMap_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetSaveLightMap_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsUseAsyncLoadWorld_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetUseAsyncLoadWorld_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetLightCalculationStep_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetLightCalculationStep_s, int)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetMaxCacheRegionCount_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetMaxCacheRegionCount_s, int)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetNumOfLockedBlockRegion_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetNumOfBlockRegion_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetTotalNumOfLoadedChunksInLockedBlockRegion_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsRenderBlocks_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetRenderBlocks_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetSunIntensity_s, float *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetSunIntensity_s, float)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetMinWorldPos_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetMinWorldPos_s, Vector3)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetMaxWorldPos_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetMaxWorldPos_s, Vector3)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetTotalChunksInMemory_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetTotalRenderableChunksInMemory_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, UseLinearTorchBrightness_s, bool)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, BeforeLoadBlockRegion)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, LoadBlockRegion)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, UnLoadBlockRegion)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, SaveRegionCallbackScript)
 NPL script to be called when a given region is flushed to disk.
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, GeneratorScript)
 
int OnBeforeLoadBlockRegion (int x, int y)
 called before block region is about to be loaded. More...
 
int OnLoadBlockRegion (int x, int y)
 called when block region has just loaded. More...
 
int OnUnLoadBlockRegion (int x, int y)
 called when block region has just unloaded. More...
 
int OnSaveBlockRegion (int x, int y)
 called when block region has just saved. More...
 
CBlockLightGridBaseGetLightGrid ()
 get light grid
 
virtual const std::string & GetIdentifier ()
 
virtual void SetIdentifier (const std::string &sID)
 
void ClearAllBlockTemplates ()
 
void SetActiveChunkRadius (int nActiveChunkRadius=12)
 how many chunk
 
void UpdateAllActiveChunks ()
 
const ParaEngine::Int32x3GetMinWorldPos () const
 minimum world position. More...
 
void SetMinWorldPos (const ParaEngine::Int32x3 &val)
 
const ParaEngine::Int32x3GetMaxWorldPos () const
 maximum world position. More...
 
void SetMaxWorldPos (const ParaEngine::Int32x3 &val)
 
uint16_t GetMaxCacheRegionCount () const
 
void SetMaxCacheRegionCount (uint16_t val)
 
virtual void SetLightCalculationStep (uint32 nTicks)
 how many lighting to calculate per tick for the lighting thread. More...
 
virtual uint32 GetLightCalculationStep ()
 
BlockRegionGetRegion (uint16_t x, uint16_t y, uint16_t z, uint16_t &rs_x, uint16_t &rs_y, uint16_t &rs_z)
 get region object More...
 
BlockRegionGetRegion (uint16_t region_x, uint16_t region_z)
 
int32_t GetActiveChunkDim ()
 
int32_t GetActiveChunkDimY ()
 
bool IsInBlockWorld ()
 
void SetRenderBlocks (bool bValue)
 whether it is readonly
 
bool IsRenderBlocks ()
 whether it is readonly
 
bool IsUseAsyncLoadWorld () const
 whether we will use async world loader. More...
 
void SetUseAsyncLoadWorld (bool val)
 
void SetReadOnly (bool bValue)
 whether it is readonly
 
bool IsReadOnly ()
 whether it is readonly
 
bool IsVisibleChunkDirty () const
 if true, it will check dirty bit for all active chunks in the next the render framemove
 
void SetVisibleChunkDirty (bool val)
 
void SetIsRemote (bool bValue)
 whether it is a remote world. More...
 
bool IsRemote ()
 whether it is a remote world
 
void SetIsServerWorld (bool bValue)
 whether it is a server world. More...
 
bool IsServerWorld ()
 whether it is server world
 
bool IsGroupByChunkBeforeTexture () const
 if true, when rendering blocks, always group by chunk first and then by texture. More...
 
void SetGroupByChunkBeforeTexture (bool val)
 
ParaEngine::mutexGetBlockWorldMutex ()
 when some thread is accessing the block world. More...
 
void LockWorld ()
 use scoped_lock where ever possible. More...
 
void UnlockWorld ()
 Unlock mutex.
 
BlockReadWriteLockGetReadWriteLock ()
 get read/write locker of this world
 
bool IsSaveLightMap () const
 whether to save light map to disk. More...
 
void SaveLightMap (bool val)
 
void SaveBlockTemplateData ()
 
void LoadBlockTemplateData ()
 
void SaveToFile (bool saveToTemp)
 
CWorldInfoGetWorldInfo ()
 return world info
 
BlockTemplateRegisterTemplate (uint16_t id, uint32_t attFlag, uint16_t category_id)
 
bool SetBlockVisible (uint16_t templateId, bool value, bool bRefreshWorld=true)
 return true if refresh world is required. More...
 
void RefreshBlockTemplate (uint16_t templateId)
 refresh light and other attributes for all instances of given block template. More...
 
uint32_t SetBlockId (uint16_t x, uint16_t y, uint16_t z, uint32_t nBlockID)
 
uint32_t GetBlockId (uint16_t x, uint16_t y, uint16_t z)
 
uint32_t SetBlockData (uint16_t x, uint16_t y, uint16_t z, uint32_t nBlockData)
 
uint32_t GetBlockData (uint16_t x, uint16_t y, uint16_t z)
 
BlockTemplateGetBlockTemplate (uint16_t id)
 
BlockTemplateGetBlockTemplate (uint16_t x, uint16_t y, uint16_t z)
 
BlockTemplateGetBlockTemplate (Uint16x3 &blockId_ws)
 
bool MatchTemplateAttribute (uint16_t templateId, BlockTemplate::BlockAttrubiteFlag flag)
 
void SetTemplateTexture (uint16_t id, const char *textureName)
 
ChunkMaxHeightGetHighestBlock (uint16_t blockX_ws, uint16_t blockZ_ws)
 
void RefreshAllLightsInColumn (uint16_t chunkX_ws, uint16_t chunkZ_ws)
 
void NotifyBlockHeightMapChanged (uint16_t blockIdX_ws, uint16_t blockIdZ_ws, ChunkMaxHeight &prevBlockHeight)
 
BlockIndex GetBlockIndex (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true)
 return the BlockChunk and the block index inside the chunk. More...
 
BlockChunkGetChunk (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true)
 get chunk by world coordinates
 
void SetBlockTemplateId (float x, float y, float z, uint16_t templateId)
 
void SetBlockTemplateIdByIdx (uint16_t x, uint16_t y, uint16_t z, uint16_t templateId)
 
uint16_t GetBlockTemplateId (float x, float y, float z)
 
uint16_t GetBlockTemplateIdByIdx (uint16_t x, uint16_t y, uint16_t z)
 
void SetBlockUserData (float x, float y, float z, uint32_t data)
 
void SetBlockUserDataByIdx (uint16_t x, uint16_t y, uint16_t z, uint32_t data)
 
uint32_t GetBlockUserData (float x, float y, float z)
 
uint32_t GetBlockUserDataByIdx (uint16_t x, uint16_t y, uint16_t z)
 
bool IsObstructionBlock (uint16_t x, uint16_t y, uint16_t z)
 
BlockGetBlock (uint16_t x, uint16_t y, uint16_t z)
 
BlockGetUnlockBlock (uint16_t x, uint16_t y, uint16_t z)
 
void SetChunkDirty (Uint16x3 &chunkId_ws, bool isDirty)
 
void SetChunkLightDirty (Uint16x3 &chunkId_ws)
 
void SetChunkColumnTimeStamp (uint16_t x, uint16_t z, uint16_t nTimeStamp)
 set chunk column time stamp. More...
 
int32_t GetChunkColumnTimeStamp (uint16_t x, uint16_t z)
 get the time stamp of for the given chunk column -1 means region not loaded yet, 0 means not available, 1 means loaded before
 
bool DoChunksNearChunkExist (uint16_t x, uint16_t y, uint16_t z, uint16_t radius)
 Checks if any of the chunks within radius blocks of the given block exist. More...
 
bool CheckChunkColumnsExist (int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
 Checks between a min and max all the chunks in between actually exist. More...
 
bool ChunkColumnExists (uint16_t chunkX, uint16_t chunkZ)
 Returns whether a chunk exists at chunk coordinates x, y.
 
bool IsChunkLocked (uint32 worldX, uint32 worldZ)
 whether the chunk at the given world position is locked. More...
 
int32_t GetBlocksInRegion (Uint16x3 &startChunk_ws, Uint16x3 &endChunk_ws, uint32_t matchType, const luabind::adl::object &result, uint32_t verticalSectionFilter=0)
 
int GetDirtyColumnCount ()
 get number of dirty chunk columns for light calculations
 
int GetDirtyBlockCount ()
 get the number of remaining dirty blocks
 
bool IsCubeModePicking ()
 ignore sub-block level physics during Pick() function. More...
 
void SetCubeModePicking (bool bIsCubeModePicking)
 
bool Pick (const Vector3 &rayOrig, const Vector3 &dir, float length, PickResult &result, uint32_t filter=0xffffffff)
 picking in block world
 
int FindFirstBlock (uint16_t x, uint16_t y, uint16_t z, uint16_t nSide=4, uint32_t max_dist=32, uint32_t attrFilter=0xffffffff, int nCategoryID=-1)
 find a block in the side direction that matched filter from block(x,y,z) this function can be used to check for free space upward or download More...
 
int GetFirstBlock (uint16_t x, uint16_t y, uint16_t z, int nBlockId, uint16_t nSide=5, uint32_t max_dist=32)
 get the y pos of the first block of nBlockID, start searching from x, y, z in the side direction More...
 
bool RefreshChunkColumn (int16_t curChunkWX, int16_t curChunkWZ)
 this function is called, when the entire column is loaded
 
bool IsChunkColumnInActiveRange (int16_t curChunkWX, int16_t curChunkWZ)
 is the chunk column in active chunk region. More...
 
bool GetBlockBrightness (Uint16x3 &blockId_ws, uint8_t *brightness, int nSize=27, int nLightType=-1)
 get light brightness of current and 26 nearby block More...
 
bool GetBlockMeshBrightness (Uint16x3 &blockId_ws, uint8_t *brightness, int nLightType=2)
 if the block in not solid, we will simply return the block's brightness. More...
 
float GetBlockBrightnessReal (const Vector3 &vPos, float *pBrightness=NULL)
 get the interpolated block brightness at the given position. More...
 
float GetBlockBrightnessReal (Uint16x3 &blockId_ws, float *pBrightness=NULL)
 
void SetSunIntensity (float intensity)
 
float GetSunIntensity ()
 
void SetLightBlockDirty (Uint16x3 &blockId_ws, bool isSunLight)
 
LightDataGetLightData (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true)
 get block light data by world coordinates
 
void SuspendLightUpdate ()
 
int GetNumOfLockedBlockRegion ()
 get the total number of locked bock regions. More...
 
int GetTotalNumOfLoadedChunksInLockedBlockRegion ()
 
int GetNumOfBlockRegion ()
 
void ResumeLightUpdate ()
 
bool IsLightUpdateSuspended ()
 
float GetLightBrightnessFloat (uint8_t brightness)
 
uint8_t GetLightBrightnessInt (uint8_t brightness)
 
float GetLightBrightnessLinearFloat (uint8_t brightness)
 
void GenerateLightBrightnessTable (bool bUseLinearBrightness=false)
 Creates the light to brightness table.
 
void OnViewCenterMove (float viewCenterX, float viewCenterY, float viewCenterZ)
 
void SetRenderDist (int nValue)
 max number of blocks to render from eye to farthest one
 
int GetRenderDist ()
 
BlockRenderMethod GetBlockRenderMethod ()
 get how blocks are preferred to be rendered. More...
 
void GetCurrentCenterChunkId (Int16x3 &oResult)
 
const Uint16x3GetEyeBlockId ()
 
void SetEyeBlockId (const Uint16x3 &eyePos)
 
const Uint16x3GetEyeChunkId ()
 
const Int16x3 GetMinActiveChunkId ()
 
void OnGenerateTerrain (int nRegionX, int nRegionY, int nChunkX=-1, int nChunkZ=-1)
 this function is called when region does not have matching disk file. More...
 
void SelectBlock (uint16_t x, uint16_t y, uint16_t z, int nGroupID=0)
 hight light select block More...
 
void DeselectBlock (uint16_t x, uint16_t y, uint16_t z, int nGroupID=0)
 
void DeselectAllBlock (int nGroupID=-1)
 
BlockRegionCreateGetRegion (uint16_t block_x, uint16_t block_y, uint16_t block_z)
 load region at the given position. More...
 
BlockRegionCreateGetRegion (uint16_t region_x, uint16_t region_z)
 
virtual void OnFrameMove ()
 
RenderableChunkGetRenderableChunk (const Int16x3 &chunkPos)
 
bool UnloadRegion (uint16_t block_x, uint16_t block_y, uint16_t block_z, bool bAutoSave=true)
 unload region from memory. More...
 
void ResetAllLight ()
 
- Public Member Functions inherited from ParaEngine::IAttributeFields
 ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *)
 
 ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s)
 
 ATTRIBUTE_METHOD (IAttributeFields, AddRef_s)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *)
 
 ATTRIBUTE_METHOD (IAttributeFields, Release_s)
 
virtual bool IsModified ()
 whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More...
 
virtual void SetModified (bool bModified)
 set whether any field has been modified. More...
 
virtual bool ValidateFields ()
 validate all fields and return true if validation passed. More...
 
virtual string GetValidationMessage ()
 get the recent validation message due to the most recent call to ValidateFields()
 
virtual bool ResetField (int nFieldID)
 Reset the field to its initial or default value. More...
 
virtual bool InvokeEditor (int nFieldID, const std::string &sParameters)
 Invoke an (external) editor for a given field. More...
 
virtual bool AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0)
 add child object. More...
 
virtual void * QueryObjectByName (const std::string &sObjectType)
 convert to object of a given type. More...
 
virtual void * QueryObject (int nObjectType)
 convert to object of a given type. More...
 
virtual int GetTime ()
 get the current local time in case it is animated in milli seconds frames. More...
 
virtual void SetTime (int nTime)
 
virtual CDynamicAttributeFieldGetDynamicField (const std::string &sName)
 Get a dynamic field with a given name. More...
 
virtual CDynamicAttributeFieldGetDynamicField (int nIndex)
 Get a dynamic field with a given index. More...
 
virtual const char * GetDynamicFieldNameByIndex (int nIndex)
 get field name by index
 
virtual int GetDynamicFieldCount ()
 how many dynamic field this object currently have. More...
 
virtual int SetDynamicField (const std::string &sName, const CVariable &value)
 set a dynamic field with a given name. More...
 
virtual int AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType)
 add dynamic field and return field index
 
virtual void RemoveAllDynamicFields ()
 remove all dynamic fields
 
virtual int SaveDynamicFieldsToString (std::string &output)
 save only text dynamic fields to fieldname = value text strings. More...
 
virtual int LoadDynamicFieldsFromString (const std::string &input)
 load only text dynamic fields from string More...
 
CAttributeClassGetAttributeClass ()
 get the main attribute class object. More...
 
void PrintObject ()
 print the content of this object to a text file at temp/doc/[ClassName].txt. More...
 
- Public Member Functions inherited from ParaEngine::IObject
virtual void Clone (IObject *obj) const
 Clone the object's contains to a pointer. More...
 
virtual IObjectClone () const
 Clone the object's contains and return a pointer to the newly created object. More...
 
virtual bool Equals (const IObject *obj) const
 Compare the object with another object. More...
 
virtual const ITypeGetType () const
 
virtual std::string ToString () const
 
WeakPtr_typeGetWeakReference ()
 get weak reference object. More...
 
virtual int ProcessObjectEvent (const ObjectEvent &event)
 this function is only used to backward compatibility of ParaObject:AddEvent() function. More...
 
- Public Member Functions inherited from ParaEngine::CRefCounted
void addref () const
 add reference count of the object. More...
 
bool delref () const
 decrease reference count of the object. More...
 
int GetRefCount () const
 get the reference count
 
virtual int Release ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 

Static Public Member Functions

static BlockWorldClientGetInstance ()
 
static bool CompareRenderOrder (BlockRenderTask *v0, BlockRenderTask *v1)
 
- Static Public Member Functions inherited from ParaEngine::CBlockWorld
static float GetVerticalOffset ()
 
static void SetVerticalOffset (float offset)
 
- Static Public Member Functions inherited from ParaEngine::IAttributeFields
static HRESULT GetAttributeClassID_s (IAttributeFields *cls, int *p1)
 
static HRESULT GetAttributeClassName_s (IAttributeFields *cls, const char **p1)
 
static bool OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false)
 Open a given file with the default registered editor in the game engine. More...
 

Protected Member Functions

virtual void UpdateActiveChunk ()
 
- Protected Member Functions inherited from ParaEngine::CBlockWorld
void UnloadRegion (BlockRegion *pRegion, bool bAutoSave=true)
 removed given region from memory. More...
 
RenderableChunkGetActiveChunk (uint16_t curChunkWX, uint16_t curChunkWY, uint16_t curChunkWZ)
 : world chunk coordinates
 
bool ReuseActiveChunk (int16_t curChunkWX, int16_t curChunkWY, int16_t curChunkWZ, BlockRegion *pRegion)
 force reusing active chunk
 
virtual void UpdateRegionCache ()
 
virtual void ClearOutOfRangeActiveChunkData ()
 
- Protected Member Functions inherited from ParaEngine::IAttributeFields
virtual CAttributeClassCreateAttributeClass ()
 initialize fields
 
virtual CDynamicAttributesSetGetDynamicAttributes (bool bCreateIfNotExist=false)
 

Additional Inherited Members

- Public Types inherited from ParaEngine::CBlockWorld
enum  CallBackType {
  Type_LoadBlockRegion = 0, Type_UnLoadBlockRegion, Type_GeneratorScript, Type_SaveRegionCallbackScript,
  Type_BeforeLoadBlockRegion
}
 script call back type
 
- Public Types inherited from ParaEngine::IAttributeFields
typedef ParaEngine::weak_ptr< IObject, IAttributeFieldsWeakPtr_type
 
- Public Types inherited from ParaEngine::IObject
typedef ParaEngine::weak_ptr< IObjectWeakPtr_type
 
- Protected Types inherited from ParaEngine::CBlockWorld
typedef BlockRegionBlockRegionPtr
 array of 64*64 regions. More...
 
- Protected Attributes inherited from ParaEngine::CBlockWorld
std::string m_sName
 
int32_t m_activeChunkDim
 
int32_t m_activeChunkDimY
 
bool m_isInWorld
 whether this world is active
 
bool m_bReadOnlyWorld
 if true, no auto world saving is done when user moving out of the region cache. More...
 
bool m_bIsRemote
 a remote world connected to server. More...
 
bool m_bIsServerWorld
 a server world. More...
 
bool m_bSaveLightMap
 whether to save light map to disk. More...
 
bool m_bCubeModePicking
 ignore sub-block level physics during Pick() function. More...
 
bool m_isVisibleChunkDirty
 if true, it will check dirty bit for all active chunks in the next the render framemove
 
bool m_bRenderBlocks
 whether to render blocks
 
bool m_bUseAsyncLoadWorld
 whether we will use async world loader. More...
 
bool m_group_by_chunk_before_texture
 if true, when rendering blocks, always group by chunk first and then by texture. More...
 
bool m_is_linear_torch_brightness
 if true, light value in block shader is linear. More...
 
std::vector< RenderableChunk * > m_activeChunks
 
Int16x3 m_minActiveChunkId_ws
 
ParaEngine::mutex m_blockworld_mutex
 when some thread is accessing the block world. More...
 
int16_t m_curRegionIdX
 
int16_t m_curRegionIdZ
 
Int16x3 m_curChunkIdW
 
Int16x3 m_lastChunkIdW
 
Int16x3 m_lastChunkIdW_RegionCache
 
Uint16x3 m_lastViewCheckIdW
 
Uint16x3 m_curCenterBlockId
 
Uint16x3 m_curCamBlockId
 
Uint16x3 m_curCamChunkId
 
Uint16x3 m_selectBlockIdW
 
Int32x3 m_minWorldPos
 minimum world position. More...
 
Int32x3 m_maxWorldPos
 maximum world position. More...
 
int m_minRegionX
 
int m_minRegionZ
 
int m_maxRegionX
 
int m_maxRegionZ
 
int m_nRenderDistance
 max number of blocks to render from eye to farthest one
 
BlockRenderMethod m_dwBlockRenderMethod
 the current block rendering method. More...
 
float m_sunIntensity
 
CBlockLightGridBasem_pLightGrid
 
std::vector< RenderableChunk * > m_visibleChunks
 
std::vector< RenderableChunk * > m_tempDirtyChunks
 
uint16_t m_maxCacheRegionCount
 
BlockRegionPtrm_pRegions
 
std::map< int, BlockRegion * > m_regionCache
 
std::map< uint16_t, BlockTemplate * > m_blockTemplates
 
std::vector< BlockTemplate * > m_blockTemplatesArray
 
std::map< uint16_t, BlockTemplateVisibleDatam_blockTemplateVisibleDatas
 
CWorldInfo m_worldInfo
 
float m_lightBrightnessTableFloat [17]
 Light to brightness conversion table. More...
 
uint8_t m_lightBrightnessTableInt [17]
 Light to brightness conversion table. More...
 
float m_lightBrightnessLinearTableFloat [17]
 
std::vector< CBlockSelectGroupm_selectedBlockMap
 
BlockReadWriteLock m_readWriteLock
 read-write lock. More...
 
- Protected Attributes inherited from ParaEngine::IObject
WeakPtr_type m_weak_reference
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 
- Static Protected Attributes inherited from ParaEngine::CBlockWorld
static float g_verticalOffset = 0
 

Detailed Description

this is a singleton client side block world instance.

It handles rendering in addition to CBlockWorld

Member Function Documentation

§ CanUseAdvancedShading()

bool ParaEngine::BlockWorldClient::CanUseAdvancedShading ( )

check device capabilities for deferred shading.

§ DrawMultiFrameBlockWorld()

bool ParaEngine::BlockWorldClient::DrawMultiFrameBlockWorld ( )

render multi frame block world is enabled.

§ DrawMultiFrameBlockWorldOnSky()

bool ParaEngine::BlockWorldClient::DrawMultiFrameBlockWorldOnSky ( )

render the image to the screen, with z test enabled and z-write disabled.

As if drawing on the skybox.

§ GetAttributeClassID()

virtual int ParaEngine::BlockWorldClient::GetAttributeClassID ( )
inlinevirtual

attribute class ID should be identical, unless one knows how overriding rules work.

Reimplemented from ParaEngine::CBlockWorld.

§ GetBlockLightColor()

LinearColor ParaEngine::BlockWorldClient::GetBlockLightColor ( )

default block emissive light color.

It is usually white or yellow light.

§ GetChildAttributeColumnCount()

int ParaEngine::BlockWorldClient::GetChildAttributeColumnCount ( )
virtual

we support multi-dimensional child object.

by default objects have only one column.

Reimplemented from ParaEngine::CBlockWorld.

§ GetChildAttributeObject()

IAttributeFields * ParaEngine::BlockWorldClient::GetChildAttributeObject ( const std::string &  sName)
virtual

get attribute by child object.

used to iterate across the attribute field hierarchy.

Reimplemented from ParaEngine::CBlockWorld.

§ GetChildAttributeObjectCount()

int ParaEngine::BlockWorldClient::GetChildAttributeObjectCount ( int  nColumnIndex = 0)
virtual

get the number of child objects (row count) in the given column.

please note different columns can have different row count.

Reimplemented from ParaEngine::CBlockWorld.

§ GetMaxBufferRebuildPerTick()

int ParaEngine::BlockWorldClient::GetMaxBufferRebuildPerTick ( ) const

how many chunks to upload to video memory per tick for near camera chunks.

See also
: GetNearCameraChunkDist

§ GetMaxBufferRebuildPerTick_FarChunk()

int ParaEngine::BlockWorldClient::GetMaxBufferRebuildPerTick_FarChunk ( ) const

how many chunks to upload to video memory for far aways chunks per tick.

See also
: GetNearCameraChunkDist

§ GetMaxVisibleVertexBufferBytes()

int ParaEngine::BlockWorldClient::GetMaxVisibleVertexBufferBytes ( ) const

we will only draw when there are less than this number of vertex visible at the current frame.

§ GetNearCameraChunkDist()

int ParaEngine::BlockWorldClient::GetNearCameraChunkDist ( ) const

near camera chunk is always rendered and cached in vertex buffer.

default to 2 chunks from eye position.

§ GetUsePointTextureFiltering()

bool ParaEngine::BlockWorldClient::GetUsePointTextureFiltering ( )

whether to use point texture filtering for all ui images rendered.

§ GetVertexBufferSizeLimit()

int ParaEngine::BlockWorldClient::GetVertexBufferSizeLimit ( ) const

for 32 bits version, we need to set the vertex buffer size limit to something like 700MB to prevent running out of 2GB virtual memory.

§ GetWaterLevel()

float ParaEngine::BlockWorldClient::GetWaterLevel ( float  x,
float  y,
float  z,
int  nRayLength = 2 
)

get the water block level just nRayLength blocks under the given positions it will also check global real water height and use the higher.

Parameters
nRayLengthcast a ray from x,y,z downward and find the water height.

§ InstallFields()

int ParaEngine::BlockWorldClient::InstallFields ( CAttributeClass pClass,
bool  bOverride 
)
virtual

this class should be implemented if one wants to add new attribute.

This function is always called internally.

Reimplemented from ParaEngine::CBlockWorld.

§ IsMovieOutputMode()

bool ParaEngine::BlockWorldClient::IsMovieOutputMode ( ) const

whenever in movie output mode, we will cache all terrain and lighting information.

Block chunks are loaded without delay. this mode is only available on PC and turned on manually, since it may slow down rendering for slow PC. And may crash for big scenes running 32bits version due to memory limit.

§ IsPointUnderWater()

bool ParaEngine::BlockWorldClient::IsPointUnderWater ( const Vector3 vPos)

check whether a specified point is under the water surface.

first check block world and then check real world

Returns
: return true if point is under water surface.

§ PrepareAllRenderTargets()

bool ParaEngine::BlockWorldClient::PrepareAllRenderTargets ( bool  bSetRenderTarget = true)

call this function to set up all render targets for fancy graphics if any.

§ Render()

void ParaEngine::BlockWorldClient::Render ( BlockRenderPass  nRenderPass = BlockRenderPass_Opaque,
std::vector< BlockRenderTask *> *  pCurRenderQueue = NULL,
int  nRenderMethod = -1 
)

render all blocks in render queue using the given pass

Parameters
pCurRenderQueueif NULL, it will fetch current render queue according to nRenderPass
nRenderMethodif -1, it will use the this->GetBlockRenderMethod(), otherwise we will render using this specifed render method. pass any value in enumeration BlockRenderMethod

block light params and sun intensity

this is for height shift, using the render origin.

§ RenderDeferredLights()

void ParaEngine::BlockWorldClient::RenderDeferredLights ( )

render light geometry.

§ SetBlockLightColor()

void ParaEngine::BlockWorldClient::SetBlockLightColor ( const LinearColor color)

default block emissive light color.

It is usually white or yellow light.

§ SetBlockRenderMethod()

void ParaEngine::BlockWorldClient::SetBlockRenderMethod ( BlockRenderMethod  method)
virtual

how blocks are preferred to be rendered.

Reimplemented from ParaEngine::CBlockWorld.

§ SetDamageTexture()

void ParaEngine::BlockWorldClient::SetDamageTexture ( const char *  textureName)

used to render damaged texture.

It is layer on top of block texture

§ SetPostProcessingScript()

void ParaEngine::BlockWorldClient::SetPostProcessingScript ( const char *  sCallbackScript)

this is usually set for fancy graphics' composite shader in deferred shading.

§ SetSelectionTexture()

void ParaEngine::BlockWorldClient::SetSelectionTexture ( const char *  textureName)

used to render selection texture.

It is layer on top of block texture

Parameters
textureNameif textureName begins with "[0-9]:filename", it will be setting the Nth selection texture

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