陆地

来源:互联网 发布:餐饮业进销存软件 编辑:程序博客网 时间:2024/03/29 08:58

西昌.何雨锋 

 

陆地

1、在62中,不用管在哪个场景中建立陆地:land1=CreateTVLandscape();
而在65中,必须明确指出在哪个场景中建立陆地:
        land1=new CTVLandscape();
       land1=scene1->CreateLandscape("land1");   //VB在前面加一个set
2、陆地从高度图中建立的方法:
       62:    land1->GenerateHugeTerrain("..//..//..//media//height1.jpg",TV_PRECISION_LOW,16,16,500,500,tvtrue);   
       65:    land1->GenerateTerrain("..//..//media//height1.jpg",cTV_PRECISION_LOW ,16,16,500,500,true);
      除了函数名,基本雷同。
3、放缩:
      62:  land1->SetTerrainScale(1,3,1,tvfalse);
      65:  land1->SetScale(1,3,1);
4、设置某一块的颜色:
      land1->SetTexture(global1->GetTex("map1"),1);
      如果最后一个参数是-1,那么就每块都覆盖,成了一个格子。
5、放缩纹理。
      land1->SetTextureScale(3,3,3);
     好象没有实质的作用。
6、高度设置:  void SetHeight(float fX, float fZ, float fNewHeight, bool bUpdateQuadtree = true, bool bDontUpdateNow = false, bool bRelative = false);
                                                           位置                         新的高度                是否更新四叉树                              是否不现在更新                     关联(为true时点变化很大)
      用鼠标设置某点高度方法:land1->SetHeight(col1->GetCollisionImpact().x,col1->GetCollisionImpact().z,land1->GetHeight(col1->GetCollisionImpact().x,col1->GetCollisionImpact().z)-1,true,false,false); 

6、其他函数:
 bool GenerateTerrain(const char* sDataSource, cCONST_TV_LANDSCAPE_PRECISION ePrecision, int iWidthIn256SizedChunk,int iHeightIn256SizedChunk, float fPosX, float fPosY, float fPosZ, bool bSmoothTerrain = true);
            //将一幅高低图来形成一个陆地(“高低图名”,精度,大小块数x,大小块数y, 起始位置x,y,z,是否平滑化 )
 void SetAffineLevel(cCONST_TV_LANDSCAPE_AFFINE eAffileLevel);
          //设置水平高度(有水才有效果)
 float GetHeight(float fX, float fZ);
        //得到某点高度值
 cTV_3DVECTOR GetNormal(float fX, float fZ);
       //得到某点的3维点
 float GetSlope(float fX1, float fZ1, float fX2, float fZ2);
      //得到溢出
 float GetSlopeAngle(float fX1, float fZ1, float fX2, float fZ2);
      //得到溢出角度 
 void Render();
     //渲染
 void SetLightingMode(cCONST_TV_LIGHTINGMODE eLightingMode = cTV_LIGHTING_MANAGED );
//设置灯光模式
 void SetPosition(float x, float y, float z);
//设置位置
 void SetRotation(float fAngleX, float fAngleY, float fAngleZ);
//设置旋转角度,62下没有
 void SetScale(float x, float y, float z);
//放缩
 void SetMatrix(cTV_3DMATRIX* mMatrix);
//设置矩阵
 void SetTexture(int iTexture, int iChunkID = -1);
//设置颜色,-1为平铺所有
 void SetMaterial(int iMaterial, int iChunkID = -1);
//设置材质  
 void ExpandTexture(int iTexture, int iStartChunkX = 0, int iStartChunkY = 0, int Width = -1, int Height = -1 , bool bDetailsAlso = false);
                 //在地图的指定区域涂抹纹理(只能从0.0的chunk向其他chunk进行,(纹理,起chunkx,起chunky,宽,高)
                 //这种涂抹只能在一块固定的chunk上进行,不能半透明,而只能全部矩形覆盖.

 void CreateEmptyTerrain(cCONST_TV_LANDSCAPE_PRECISION ePrecision, int iWidth, int iHeight, float fPosX, float fPosY, float fPosZ);
//建立一个空的陆地
 int GetMaterial(int iChunkIndex = -1);
 int GetTexture(int iChunkIndex = -1);

 int SaveTerrainData(const char* sDataDestination, cCONST_TV_LANDSAVE eSaveMode);
//保存陆地数据,但存的格式不是高度图,可以直接load就把此图完全读出,而且当地形发生变化时,保存文件也变化.
 int LoadTerrainData(const char* sDataSource);
 //读取陆地数据,但不包括纹理
 void SetTerrainChunkEnable(int iChunkX, int iChunkZ, bool bEnable);
 bool IsChunkVisible(int iChunkIndex);

 void SetDetailTextureScale(float fTuScale, float fTvScale, int iChunkIndex = -1);
 void SetPagingSystem(bool bEnable , int iVisibleChunk = 5);
//设置页系统,无限扩大,第二个参数为可见块,随着移动而可见块变化.

 int TexGen_AddLayer(const char* sTextureDataSource, int iAltitudeStart, int iAltitudeEnd, float fBlendPower = 1.0f, float fTextureScaleX = 1.0f, float fTextureScaleY = 1.0f, float fRandomness = 0.0f, float fSlopeMin = -1.0f, float fSlopeMax = -1.0f);
                 //增加一个layer,  ("文件名",海拔起点,海拔终点,混合强度,纹理放缩x,纹理放缩y,随机因子0~1,最小斜率,最大斜率)
 void TexGen_ClearLayers();
 void TexGen_Generate(const char* sSourceHeightmap, const char* sCompileFile, cCONST_TV_TEXGENRESOLUTION eTexGenResolution);
                 //根据一个高度地图生成一个layer图?
    int TexGen_GetCount();
 void TexGen_DeleteLayer(int iLayer);
 char* TexGen_GetLayerSource(int iLayer);


    void FlushHeightChanges(bool bUpdateQuadTree = true, bool bUpdateNormals = true);

 void SetDetailTexture(int iDetailTexture, int iGroup = -1);
 void SetTextureScale(float fTuScale, float fTvScale, int iGroup = -1);
 void SetDetailMode(cCONST_TV_DETAILMAP_MODE eMode);

 CTVCollisionResult* MousePick(int iMouseX, int iMouseY);
//检测鼠标碰撞陆地与否
 CTVCollisionResult* AdvancedCollide(cTV_3DVECTOR* vStartPoint, cTV_3DVECTOR* vEndPoint);
 //高级碰撞检测(点1,点2);

 void DeleteAll();
 bool IsActive();

 void SetCustomLightmap(int iLightmapTexture, int iChunkID = -1);
 void SetHeightmapMode(cCONST_TV_LANDSCAPE_HEIGHTMAP eHeightmapFormat);

 void SetBlendingMode(cCONST_TV_BLENDINGMODE eMode);
                 //设置混合颜色模式
                   参数为
                      cTV_BLEND_NO = 0,   不混合
                      cTV_BLEND_ALPHA = 1,  透明
                      cTV_BLEND_ADD = 2,  2,加强透明
                     cTV_BLEND_COLOR = 3,  3,颜色透明
                     cTV_BLEND_ADDALPHA = 4,
                     cTV_BLEND_MULTIPLY = 5

 void SetBlendingModeEx(cCONST_TV_BLENDEX eSourceBlend, cCONST_TV_BLENDEX eDestBlend);

 void SetAlphaTest(bool bAlphaTest, int iAlphaRef = 128, bool bWriteToBuffer = true);
 
 void SetTag(const char* sTag);
 char* GetTag();
 void SetUserData(int i32bitsPointers);
 int GetUserData();
 void SetName(const char* sName);
 char* GetName();

 cTV_3DVECTOR GetPosition();
 cTV_3DMATRIX GetMatrix();
 cTV_3DVECTOR GetScale();

 void SetCullMode(cCONST_TV_CULLING eCullMode);
 bool SetHeightArray( int iVertexOffsetX, int iVertexOffsetZ, int iWidth, int iHeight, float* pFirstHeightOfArray);
 
 // splatting support.
 void SetSplattingEnable(bool bEnable, int iChunk = -1, float fSplattingAlpha = 1.0f);
                 //是否允许喷溅(是否,-1,透明度)
 void AddSplattingTexture(int iBaseTexture, float fPriority, float fTilingU = 1, float fTilingV = 1, float fShiftU = 0, float fShiftV = 0);
                 //增加喷溅文理(基础纹理,优先权0~1,平铺U,平铺V,转动U,转动V );
 void SetSplattingTextureProperties(int iBaseSplatTexture, cTV_3DVECTOR* vLayerNormal, float fRotationRoll = 0.0f, float fTilingU = 1.0f, float fTilingV = 1.0f, float fShiftU = 0, float fShiftV = 0.0f);
 void RemoveAllSplattingTextures();

 void ExpandSplattingTexture(int iAlphaMap, int iBaseSplatTexture, int iStartX = 0, int iStartY = 0, int iWidth = -1, int iHeight = -1);
                 //输出喷溅(透明图,喷射图,x,y,宽度,高度)
 void SetSplattingTexture(int iAlphaMap, int iBaseSplatTexture, int iChunk);
                  //在某chunk上输出喷溅纹理??
 void ClearAllSplattingLayers(int iChunk = -1);
                  //清除所有的在chunk上的喷溅
 void EnableLOD(bool bEnable, float fLODSwitchDistance = 512.0f, cCONST_TV_LANDSCAPE_PRECISION iMinPrecision = cTV_PRECISION_ULTRA_LOW, float fStartDistance = 0.0f, bool bDiscardAltitude = true) ;
 void OptimizeSplatting(bool bShader = false, bool bCombinedAlphaMap = false, int iChunkAlphaMapWidth = -1, int iChunkAlphaMapHeight = -1);
                  //优化 喷溅
 void ComputeNormals(bool bFixChunkBoundaries = true);
 void SetSplattingMode(bool bUsePS2Shader, bool bUseTextureAlphaAsSpecularMap = false);
                 //设置喷溅模式
 void SetProgressiveLOD(bool bEnable);
                   //设置进步模式,
 void SetShader(CTVShader* pShader);
                  
 int GetChunkCount();
                 //得到chunk总数
 cCONST_TV_LANDSCAPE_PRECISION GetPrecision();
 int GetLandWidth();
 int GetLandHeight();

 bool SetHeightArrayEx(int iX, int iY, int iWidth, int iHeight, const char* sDatasource);
 void FixSeams(CTVLandscape* lOtherLand);
                 //固定结缝与另一陆地
 void SetClamping(bool bEnable, int iChunkID = -1);
                
 void ReplaceSplattingTexture(int iCurrentSplatTexture, int iNewSplatTexture);
 void ReplaceSplattingAlpha(int iCurrentAlphaTexture, int iNewAlphaTexture);

 void Enable(bool bEnable);
 void SetCollisionEnable(bool bEnable);
 //void RemoveSplattingTexture();

 void GetBoundingBox(cTV_3DVECTOR* retBoundingBoxMin, cTV_3DVECTOR* retBoundingBoxMax);
 float GetLandRealWidth();
 float GetLandRealHeight();

 int GetChunkIDFromPosition(cTV_3DVECTOR* vPosition);
 int GetChunkID(int iChunkX, int iChunkZ);

 void SetTextureEx(int iLayer, int iTexture, int iChunkID = -1);
 int GetTextureEx(int iLayer, int iChunkID = 0);
 void RemoveSplattingTexture(int iBaseSplatTexture);
 void RemoveSplattingLayer(int iBaseSplatTexture, int iChunk);
 bool IsVisible();
 cTV_3DVECTOR GetRotation();
 bool GetHeightArray( int iVertexOffsetX, int iVertexOffsetZ, int iWidth, int iHeight, float* retAllocatedHeightArray);
 void Destroy();
 cTV_3DVECTOR GetInterpolatedNormal(float fX, float fZ);

 CTVShader* GetShader();
 bool GetProgressiveLOD();

 

原创粉丝点击