My Project
Static Public Member Functions | List of all members
ParaScripting::ParaBlockWorld Class Reference

Wrapper of internal CBlockWorld. More...

#include <ParaScriptingBlockWorld.h>

Static Public Member Functions

static object GetWorld (const object &sWorldName)
 static function to create get a world instance
 
static int GetVersion (const object &pWorld)
 get version
 
static ParaAttributeObject GetBlockAttributeObject (const object &pWorld)
 get block terrain manager's attribute object. More...
 
static bool RegisterBlockTemplate (const object &pWorld, uint16_t templateId, const object &params)
 register blocks with given parameters More...
 
static bool RegisterBlockTemplate_ (CBlockWorld *pWorld, uint16_t templateId, const object &params)
 
static void SetBlockWorldYOffset (const object &pWorld, float offset)
 set Block world's y offset in real world coordinate. More...
 
static void EnterWorld (const object &pWorld, const char *sWorldDir)
 call this function after all block templates has been registered to initialize the world note this function can be called multiple times to load different world with the same block templates. More...
 
static void LeaveWorld (const object &pWorld)
 call this function when leave the block world
 
static void SaveBlockWorld (const object &pWorld, bool saveToTemp)
 
static void LoadRegion (const object &pWorld, uint16_t x, uint16_t y, uint16_t z)
 load region at the given position. More...
 
static void UnloadRegion (const object &pWorld, uint16_t x, uint16_t y, uint16_t z)
 unload data for a given region from memory
 
static void SetBlockId (const object &pWorld, uint16_t x, uint16_t y, uint16_t z, uint32_t templateId)
 set block id set the given position. More...
 
static uint32_t GetBlockId (const object &pWorld, uint16_t x, uint16_t y, uint16_t z)
 get block id at the given block position. More...
 
static void SetBlockData (const object &pWorld, uint16_t x, uint16_t y, uint16_t z, uint32_t data)
 set per block user data
 
static uint32_t GetBlockData (const object &pWorld, uint16_t x, uint16_t y, uint16_t z)
 get per block user data
 
static object GetBlocksInRegion (const object &pWorld, int32_t startChunkX, int32_t startChunkY, int32_t startChunkZ, int32_t endChunkX, int32_t endChunkY, int32_t endChunkZ, uint32_t matchType, const object &result)
 get block in [startChunk,endChunk] More...
 
static void SetBlockWorldSunIntensity (const object &pWorld, float value)
 set current sun intensity in [0,1] range
 
static int FindFirstBlock (const object &pWorld, 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...
 
static int GetFirstBlock (const object &pWorld, uint16_t x, uint16_t y, uint16_t z, int nBlockId, uint16_t nSide=4, 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
 
static void SetTemplateTexture (const object &pWorld, uint16_t templateId, const char *fileName)
 set the template texture. More...
 
static object GetVisibleChunkRegion (const object &pWorld, const object &result)
 get visible chunk region only used on client side More...
 
static object Pick (const object &pWorld, float rayX, float rayY, float rayZ, float dirX, float dirY, float dirZ, float fMaxDistance, const object &result, uint32_t filter=0xffffffff)
 ray origin should be positive value, ray direction should be normalized value function is only used on client world More...
 
static object MousePick (const object &pWorld, float fMaxDistance, const object &result, uint32_t filter=0xffffffff)
 picking by current mouse position. More...
 
static void SelectBlock (const object &pWorld, uint16_t x, uint16_t y, uint16_t z, bool isSelect)
 add/remove block to/from highlight block list only used on client side More...
 
static void SelectBlock1 (const object &pWorld, uint16_t x, uint16_t y, uint16_t z, bool isSelect, int nGroupID)
 
static void DeselectAllBlock1 (const object &pWorld, int nGroupID)
 
static void DeselectAllBlock (const object &pWorld)
 
static void SetDamagedBlock (const object &pWorld, uint16_t x, uint16_t y, uint16_t z)
 set damage block id only used on client side More...
 
static void SetDamageDegree (const object &pWorld, float damagedDegree)
 set damage block degree More...
 

Detailed Description

Wrapper of internal CBlockWorld.

may have multiple instance of the block world.

Member Function Documentation

§ DeselectAllBlock1()

void ParaScripting::ParaBlockWorld::DeselectAllBlock1 ( const object pWorld,
int  nGroupID 
)
static
Parameters
nGroupID0 for animated selection, 1 for wire frame selection. -1 for all

§ EnterWorld()

void ParaScripting::ParaBlockWorld::EnterWorld ( const object pWorld,
const char *  sWorldDir 
)
static

call this function after all block templates has been registered to initialize the world note this function can be called multiple times to load different world with the same block templates.

call LeaveWorld() before EnterWorld again.

Parameters
sWorldDirworld directory or world config file.

§ FindFirstBlock()

int ParaScripting::ParaBlockWorld::FindFirstBlock ( const object pWorld,
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 
)
static

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

Parameters
side4 is top. 5 is bottom.
attrFilterattribute to match. 0 means air. default to any block
nCategoryID-1 means any category_id. default to -1
Returns
-1 if not found. otherwise distance to the first block that match in the side direction is returned.

§ GetBlockAttributeObject()

ParaScripting::ParaAttributeObject ParaScripting::ParaBlockWorld::GetBlockAttributeObject ( const object pWorld)
static

get block terrain manager's attribute object.

§ GetBlockId()

uint32_t ParaScripting::ParaBlockWorld::GetBlockId ( const object pWorld,
uint16_t  x,
uint16_t  y,
uint16_t  z 
)
static

get block id at the given block position.

§ GetBlocksInRegion()

luabind::object ParaScripting::ParaBlockWorld::GetBlocksInRegion ( const object pWorld,
int32_t  startChunkX,
int32_t  startChunkY,
int32_t  startChunkZ,
int32_t  endChunkX,
int32_t  endChunkY,
int32_t  endChunkZ,
uint32_t  matchType,
const object result 
)
static

get block in [startChunk,endChunk]

Parameters
resultin/out containing the result.
startChunkY,endChunkYif negative, and startChunkY == endChunkY, -startChunkY will be used as verticalSectionFilter (a bitwise filter).
Returns
{count,x{},y{},z{},tempId{}}

§ GetVisibleChunkRegion()

luabind::object ParaScripting::ParaBlockWorld::GetVisibleChunkRegion ( const object pWorld,
const object result 
)
static

get visible chunk region only used on client side

Returns
: world space chunk id {minX,minY,minZ,maxX,maxY,maxZ}

§ LoadRegion()

void ParaScripting::ParaBlockWorld::LoadRegion ( const object pWorld,
uint16_t  x,
uint16_t  y,
uint16_t  z 
)
static

load region at the given position.

current implementation will load entire region rather than just chunk. one need to call load chunk before SetBlock/GetBlock api can be called in the region.

§ MousePick()

luabind::object ParaScripting::ParaBlockWorld::MousePick ( const object pWorld,
float  fMaxDistance,
const object result,
uint32_t  filter = 0xffffffff 
)
static

picking by current mouse position.

only used on client world

§ Pick()

luabind::object ParaScripting::ParaBlockWorld::Pick ( const object pWorld,
float  rayX,
float  rayY,
float  rayZ,
float  dirX,
float  dirY,
float  dirZ,
float  fMaxDistance,
const object result,
uint32_t  filter = 0xffffffff 
)
static

ray origin should be positive value, ray direction should be normalized value function is only used on client world

Returns
: result["x"] = pickResult.X; result["y"] = pickResult.Y; result["z"] = pickResult.Z; result["blockX"] = pickResult.BlockX; result["blockY"] = pickResult.BlockY; result["blockZ"] = pickResult.BlockZ; result["side"] = pickResult.Side; result["length"] = pickResult.Distance; side value : 0 negativeX,1 positiveX,2 NZ,3 PZ,4 NY, 5PY length > fMaxDistance when no collision detected

§ RegisterBlockTemplate()

bool ParaScripting::ParaBlockWorld::RegisterBlockTemplate ( const object pWorld,
uint16_t  templateId,
const object params 
)
static

register blocks with given parameters

Parameters
paramsit can be attFlag of int type. or it can be a table containing additional format such as {attFlag=number, modelName=string, etc. }

§ SelectBlock()

void ParaScripting::ParaBlockWorld::SelectBlock ( const object pWorld,
uint16_t  x,
uint16_t  y,
uint16_t  z,
bool  isSelect 
)
static

add/remove block to/from highlight block list only used on client side

Parameters
x,y,zworld space block id;
isSelect: true to select block, false to de-select block
nGroupIDgroup id. 0 for highlight 1 for wireframe.

§ SetBlockId()

void ParaScripting::ParaBlockWorld::SetBlockId ( const object pWorld,
uint16_t  x,
uint16_t  y,
uint16_t  z,
uint32_t  templateId 
)
static

set block id set the given position.

Parameters
x,y,zshould be positive value
templateIdtemplate id. specify 0 to delete a block.

§ SetBlockWorldYOffset()

void ParaScripting::ParaBlockWorld::SetBlockWorldYOffset ( const object pWorld,
float  offset 
)
static

set Block world's y offset in real world coordinate.

§ SetDamagedBlock()

void ParaScripting::ParaBlockWorld::SetDamagedBlock ( const object pWorld,
uint16_t  x,
uint16_t  y,
uint16_t  z 
)
static

set damage block id only used on client side

Parameters
x,y,z:world space block id;

§ SetDamageDegree()

void ParaScripting::ParaBlockWorld::SetDamageDegree ( const object pWorld,
float  damagedDegree 
)
static

set damage block degree

Parameters
damageDegree[0,1] 0 means undamaged block,1 full damaged block

§ SetTemplateTexture()

void ParaScripting::ParaBlockWorld::SetTemplateTexture ( const object pWorld,
uint16_t  templateId,
const char *  fileName 
)
static

set the template texture.

only used on client side This function is deprecated. use RegisterBlockTemplate instead.


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