My Project
ParaScriptingTerrain.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2004 - 2006 ParaEngine Dev Studio, All Rights Reserved.
3 // Date: 2005.12
4 // Description: API for terrain
5 //-----------------------------------------------------------------------------
6 #pragma once
7 
8 #include "ParaScriptingCommon.h"
9 #include "ParaScriptingGlobal.h"
10 namespace ParaEngine{
11  class CTerrainTile;
12 }
13 
14 namespace ParaScripting
15 {
16  using namespace std;
17  using namespace ParaEngine;
18 
23  class PE_CORE_DECL ParaTerrain
24  {
25  public:
26  ParaTerrain(void);
27  ~ParaTerrain(void);
28  public:
30  static ParaAttributeObject GetAttributeObject();
32  static void GetAttributeObject_(ParaAttributeObject& output);
33 
35  static ParaAttributeObject GetBlockAttributeObject();
36 
37 
42  static int GetTextureCount(float x, float y);
43 
52  static void GetTexturesInCell(float x, float y, const object& out);
53 
60  static bool RemoveTextureInCell(float x, float y, int nIndex);
61 
71  static ParaAssetObject GetTexture(float x, float y, int nIndex);
73  static void GetTexture__(ParaAssetObject* pOut, float x, float y, int nIndex);
82  static bool ReplaceTexture(float x, float y, int nIndex, ParaAssetObject& TextureAsset);
83  static bool ReplaceTexture_(float x, float y, int nIndex, const object& sTextureAsset);
84 
91  static ParaAttributeObject GetAttributeObjectAt(float x, float y);
93  static void GetAttributeObjectAt_(ParaAttributeObject& output, float x, float y);
94 
101  static float GetElevation(float x, float y);
102 
108  static DWORD GetRegionValue(const char* sLayerName, float x, float y);
109 
117  static DWORD GetRegionValue4(const char* sLayerName, float x, float y, const char* argb);
118 
120  static string GetTerrainOnloadScript(float x, float y);
122  static const char * GetTerrainOnloadScript__(float x, float y);
123 
125  static string GetTerrainElevFile(float x, float y);
127  static const char* GetTerrainElevFile__(float x, float y);
128 
129 
134  static void SaveTerrain(bool bHeightMap, bool bTextures);
135 
141  static void ReloadTerrain(bool bHeightMap, bool bTextures);
142 
146  static void UpdateTerrain();
147  static void UpdateTerrain1(bool bForceUpdate);
148 
158  static void SnapPointToVertexGrid(float x, float y, float* vertex_x, float* vertex_y);
159 
161  static float GetVertexSpacing();
162 
164  // Terrain editor
166 
177  static void Paint(const char* detailTexture, float brushRadius, float brushIntensity, float maxIntensity, bool erase, float x, float y);
182  static void Paint_(int nDetailTextureID, float brushRadius, float brushIntensity, float maxIntensity, bool erase, float x, float y);
183 
194  static void DigCircleFlat(float x, float y, float radius, float fFlatPercentage, float factor);
195 
210  static void Flatten (float x,float y,float radius, int flatten_op, float elevation,float factor);
211 
223  static void RadialScale (float x, float y, float scale_factor, float min_dist,float max_dist, float smooth_factor);
224 
225  /*
226  * This creates a Gaussian hill at the specified location with the specified parameters.
227  * it actually adds the hill to the original terrain surface.
228  * Here ElevNew(x,y) =
229  |(x,y)-(center_x,center_y)| < radius*smooth_factor, ElevOld(x,y)+hscale*exp(-[(x-center_x)^2+(y-center_y)^2]/(2*standard_deviation^2) ),
230  |(x,y)-(center_x,center_y)| > radius*smooth_factor, minimize hill effect.
231  * @param center_x: the center of the affected circle. value in the range [0,1]
232  * @param center_y: the center of the affected circle.value in the range [0,1]
233  * @param radius: the radius of the affected circle.value in the range [0,0.5]
234  * @param hscale: scale factor. One can think of it as the maximum height of the Gaussian Hill. this value can be negative
235  * @param standard_deviation: standard deviation of the unit height value. should be in the range (0,1).
236  * 0.1 is common value. larger than that will just make a flat hill with smoothing.
237  * @param smooth_factor: value is between [0,1]. 1 means fully transformed; 0 means nothing is changed
238  */
239  static void GaussianHill (float x,float y,float radius,float hscale,float standard_deviation,float smooth_factor);
240 
247  static void Spherical ( float x,float y,float radius, float offset);
248 
263  static void Roughen_Smooth (float x, float y, float radius,bool roughen, bool big_grid,float factor);
264 
271  static void Ramp(float x1, float y1, float x2, float y2, float radius, float borderpercentage, float factor);
272 
282  static void AddHeightField(float x, float y, const char* filename, int nSmoothPixels);
283 
303  static void MergeHeightField(float x, float y, const char* filename, int mergeOperation=0, float weight1=1.0, float weight2=1.0, int nSmoothPixels=7);
304 
309  static void UpdateHoles(float x, float y);
317  static bool IsHole(float x, float y);
326  static void SetHole(float x, float y, bool bIsHold);
327 
329  static bool IsModified();
330 
337  static void SetContentModified(float x, float y, bool bIsModified);
338 
359  static void SetContentModified4(float x, float y, bool bIsModified, DWORD dwModifiedBits);
360 
362  static void SetAllLoadedModified(bool bIsModified, DWORD dwModifiedBits);
363 
364 
366  //
367  // global effect and light settings
368  //
370 
372  static void EnableLighting(bool bEnable);
373 
375  //
376  //Edit additional terrin data e.g walkable region,waypoint region
377  //
379  static void PaintTerrainData (float x,float y,float radius,unsigned int data,unsigned int dataMask,unsigned int bitOffset);
380 
381  static uint32 GetTerrainData (float x,float y,uint32 dataMask,byte bitOffset);
382 
383  static void SetVisibleDataMask(uint32 mask,byte bitOffset);
384 
385 
387  //
388  //Block terrain api
389  //
391 
392  //call this function to start block world
393  //params are camera position, if camera is attached to object then it should be attached object position
394  static void EnterBlockWorld(float x,float y,float z);
395 
396  //call this when leave block world
397  //this function will release most resource(buffer,cached data) used by block engine.
398  static void LeaveBlockWorld();
399 
400  static bool IsInBlockWorld();
401 
402  static void SaveBlockWorld(bool saveToTemp);
403 
404  static void DeleteAllBlocks();
405 
406  //set block template
407  //x,y,z should be positive value
408  //templateId may contain two template values packed as template0 + (template1<<16)
409  //use 0 to delete a block.
410  static void SetBlockTemplateId(float x,float y,float z,uint16_t templateId);
411 
412  static void SetBlockTemplateIdByIdx(uint16_t x,uint16_t y,uint16_t z,uint32_t templateId);
413 
414  static uint32_t GetBlockTemplateId(float x,float y,float z);
415 
416  static uint32_t GetBlockTemplateIdByIdx(uint16_t x,uint16_t y,uint16_t z);
417 
418  //user data is used to store per instance data e.g
419  //for two template block it means the blend factor of two template
420  //for model object it means the facing and scale value
421  //one can pack one or more value into a single uint32 value
422  //and unpack them according to pre-defined rules according to block type
423  static void SetBlockUserData(float x,float y,float z,uint32_t data);
424 
425  static void SetBlockUserDataByIdx(uint16_t x,uint16_t y,uint16_t z,uint32_t data);
426 
427  static uint32_t GetBlockUserData(float x,float y,float z);
428 
429  static uint32_t GetBlockUserDataByIdx(uint16_t x,uint16_t y,uint16_t z);
430 
431  //ray orignial should be positive value
432  //ray direction should be normalized value
433  //@return:
434  //result["x"] = pickResult.X;
435  //result["y"] = pickResult.Y;
436  //result["z"] = pickResult.Z;
437  //result["blockX"] = pickResult.BlockX;
438  //result["blockY"] = pickResult.BlockY;
439  //result["blockZ"] = pickResult.BlockZ;
440  //result["side"] = pickResult.Side;
441  //result["length"] = pickResult.Distance;
442  //side value : 0 negativeX,1 positiveX,2 NZ,3 PZ,4 NY, 5PY
443  //length > fMaxDistance when no collision detected
444  static object Pick(float rayX,float rayY,float rayZ,float dirX,float dirY,float dirZ,float fMaxDistance,const object& result,uint32_t filter=0xffffffff);
445  static object MousePick(float fMaxDistance,const object& result,uint32_t filter=0xffffffff);
446 
450  static bool RegisterBlockTemplate(uint16_t templateId,const object& params);
451 
452  static void SetTemplateTexture(uint16_t templateId,const char* fileName);
453 
454  static void SetBlockWorldYOffset(float offset);
455 
460  static object GetBlocksInRegion(int32_t startChunkX,int32_t startChunkY,int32_t startChunkZ,int32_t endChunkX,int32_t endChunkY,int32_t endChunkZ,
461  uint32_t matchType,const object& result);
462 
463  //get visible chunk region
464  //@return : world space chunk id {minX,minY,minZ,maxX,maxY,maxZ}
465  static object GetVisibleChunkRegion(const object& result);
466 
467  static void SetBlockWorldSunIntensity(float value);
468 
474  static void SelectBlock(uint16_t x,uint16_t y,uint16_t z,bool isSelect);
475  static void SelectBlock1(uint16_t x,uint16_t y,uint16_t z,bool isSelect, int nGroupID);
476 
480  static void DeselectAllBlock1(int nGroupID);
481 
482  static void DeselectAllBlock();
483 
484 
485  //set damage block id
486  //@param x,y,z :world space block id;
487  static void SetDamagedBlock(uint16_t x,uint16_t y,uint16_t z);
488 
489  //set damage block degree
490  //@param damageDegree: [0,1] 0 means undamaged block,1 full damaged block
491  static void SetDamageDegree(float damagedDegree);
492 
500  static 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);
501 
504  static int GetFirstBlock(uint16_t x,uint16_t y,uint16_t z, int nBlockId, uint16_t nSide = 4, uint32_t max_dist = 32);
505 
509  static int32_t GetChunkColumnTimeStamp(uint32_t chunkX, uint32_t chunkZ);
510 
513  static void SetChunkColumnTimeStamp(uint32_t chunkX, uint32_t chunkZ, uint32_t nTimeStamp);
514 
518  static const std::string& GetMapChunkData(uint32_t chunkX, uint32_t chunkZ, bool bIncludeInit, uint32_t verticalSectionFilter);
519 
520  static object ApplyMapChunkData(uint32_t chunkX, uint32_t chunkZ, uint32_t verticalSectionFilter, const std::string& chunkData, const object& out);
521 
523  static void GetBlockFullData(uint16_t x, uint16_t y, uint16_t z, uint16_t* pId, uint32_t* pUserData);
524 
525  };
526 
527 }
Definition: SceneObject.h:15
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: enum_maker.hpp:46
it represents an attribute object associated with an object.
Definition: ParaScriptingGlobal.h:458
for luabind, The main drawback of this approach is that the compilation time will increase for the fi...
Definition: luaSQLite.cpp:1971
it represents an asset entity.
Definition: ParaScriptingCommon.h:85