BVB Source Codes

CRYENGINE Show terrain_det_tex.cpp Source code

Return Download CRYENGINE: download terrain_det_tex.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   terrain_det_tex.cpp
  5. //  Version:     v1.00
  6. //  Created:     28/5/2001 by Vladimir Kajalin
  7. //  Compilers:   Visual Studio.NET
  8. //  Description: terrain detail textures
  9. // -------------------------------------------------------------------------
  10. //  History:
  11. //
  12. ////////////////////////////////////////////////////////////////////////////
  13.  
  14. #include "StdAfx.h"
  15. #include "terrain.h"
  16. #include "terrain_sector.h"
  17. #include "3dEngine.h"
  18.  
  19. void CTerrain::SetDetailLayerProperties(int nId, float fScaleX, float fScaleY,
  20.                                         uint8 ucProjAxis, const char* szSurfName,
  21.                                         const PodArray<int>& lstnVegetationGroups, IMaterial* pMat,
  22.                                         int nSID)
  23. {
  24.         if (nId >= 0 && nId < SRangeInfo::e_max_surface_types)
  25.         {
  26.                 const int nNameLength = strlen(szSurfName);
  27.                 const int nDestNameLength = sizeof(m_SSurfaceType[nSID][nId].szName) - 1;
  28.                 if (nNameLength > nDestNameLength)
  29.                         Error("CTerrain::SetDetailLayerProperties: attempt to assign too long surface type name (%s)", szSurfName);
  30.                 cry_strcpy(m_SSurfaceType[nSID][nId].szName, szSurfName);
  31.                 m_SSurfaceType[nSID][nId].fScale = fScaleX;
  32.                 m_SSurfaceType[nSID][nId].ucDefProjAxis = ucProjAxis;
  33.                 m_SSurfaceType[nSID][nId].ucThisSurfaceTypeId = nId;
  34.                 m_SSurfaceType[nSID][nId].lstnVegetationGroups.Reset();
  35.                 m_SSurfaceType[nSID][nId].lstnVegetationGroups.AddList(lstnVegetationGroups);
  36.                 m_SSurfaceType[nSID][nId].pLayerMat = (CMatInfo*)pMat;
  37. #ifndef SW_STRIP_LOADING_MSG
  38.                 if (m_SSurfaceType[nSID][nId].pLayerMat && !m_bEditor)
  39.                         CTerrain::Get3DEngine()->PrintMessage("  Layer %d - %s has material %s", nId, szSurfName, pMat->GetName());
  40. #endif
  41.         }
  42.         else
  43.         {
  44.                 Warning("CTerrain::SetDetailTextures: LayerId is out of range: %d: %s", nId, szSurfName);
  45.                 assert(!"CTerrain::SetDetailTextures: LayerId is out of range");
  46.         }
  47. }
  48.  
  49. void CTerrain::LoadSurfaceTypesFromXML(XmlNodeRef pDetTexTagList, int nSID)
  50. {
  51.         LOADING_TIME_PROFILE_SECTION;
  52.  
  53.         MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Terrain, 0, "Surface types");
  54.  
  55. #ifndef SW_STRIP_LOADING_MSG
  56.         CTerrain::Get3DEngine()->PrintMessage("Loading terrain layers for segment %d ...", nSID);
  57. #endif
  58.  
  59.         if (!pDetTexTagList)
  60.                 return;
  61.  
  62.         m_bProcVegetationInUse = false;
  63.  
  64.         for (int nId = 0; nId < pDetTexTagList->getChildCount() && nId < SRangeInfo::e_max_surface_types; nId++)
  65.         {
  66.                 XmlNodeRef pDetLayer = pDetTexTagList->getChild(nId);
  67.                 IMaterialManager* pMatMan = Get3DEngine()->GetMaterialManager();
  68.                 const char* pMatName = pDetLayer->getAttr("DetailMaterial");
  69.                 IMaterial* pMat = pMatName[0] ? pMatMan->LoadMaterial(pMatName) : NULL;
  70.  
  71.                 float fScaleX = 1.f;
  72.                 pDetLayer->getAttr("DetailScaleX", fScaleX);
  73.                 float fScaleY = 1.f;
  74.                 pDetLayer->getAttr("DetailScaleY", fScaleY);
  75.                 uint8 projAxis = pDetLayer->getAttr("ProjAxis")[0];
  76.  
  77.                 if (!pMat || pMat == pMatMan->GetDefaultMaterial())
  78.                 {
  79.                         Error("CTerrain::LoadSurfaceTypesFromXML: Error loading material: %s", pMatName);
  80.                         pMat = pMatMan->GetDefaultTerrainLayerMaterial();
  81.                 }
  82.  
  83.                 if (CMatInfo* pMatInfo = (CMatInfo*)pMat)
  84.                 {
  85.                         pMatInfo->m_fDefautMappingScale = fScaleX;
  86.                         Get3DEngine()->InitMaterialDefautMappingAxis(pMatInfo);
  87.                 }
  88.  
  89.                 PodArray<int> lstnVegetationGroups;
  90.                 for (int nGroup = 0; nGroup < pDetLayer->getChildCount(); nGroup++)
  91.                 {
  92.                         XmlNodeRef pVegetationGroup = pDetLayer->getChild(nGroup);
  93.                         int nVegetationGroupId = -1;
  94.                         if (pVegetationGroup->isTag("VegetationGroup") && pVegetationGroup->getAttr("Id", nVegetationGroupId))
  95.                         {
  96.                                 lstnVegetationGroups.Add(nVegetationGroupId);
  97.                                 m_bProcVegetationInUse = true;
  98.                         }
  99.                 }
  100.  
  101.                 SetDetailLayerProperties(nId, fScaleX, fScaleY, projAxis, pDetLayer->getAttr("Name"), lstnVegetationGroups, pMat, nSID);
  102.         }
  103. }
  104.  
  105. void CTerrain::UpdateSurfaceTypes(int nSID)
  106. {
  107.         if (GetParentNode(nSID))
  108.                 GetParentNode(nSID)->UpdateDetailLayersInfo(true);
  109. }
  110.  
downloadterrain_det_tex.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top