BVB Source Codes

CRYENGINE Show ScriptBind_MaterialEffects.cpp Source code

Return Download CRYENGINE: download ScriptBind_MaterialEffects.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:   ScriptBind_MaterialEffects.cpp
  5. //  Version:     v1.00
  6. //  Created:     03/22/2007 by MichaelR
  7. //  Compilers:   Visual Studio.NET
  8. //  Description: MaterialEffects ScriptBind. MaterialEffects should be used
  9. //               from C++ if possible. Use this ScriptBind for legacy stuff.
  10. // -------------------------------------------------------------------------
  11. //  History:
  12. //
  13. ////////////////////////////////////////////////////////////////////////////
  14. #include "StdAfx.h"
  15. #include "ScriptBind_MaterialEffects.h"
  16. #include "MaterialEffects.h"
  17.  
  18. //------------------------------------------------------------------------
  19. CScriptBind_MaterialEffects::CScriptBind_MaterialEffects(ISystem* pSystem, CMaterialEffects* pMFX)
  20. {
  21.         m_pSystem = pSystem;
  22.         m_pMFX = pMFX;
  23.         assert(m_pMFX != 0);
  24.  
  25.         Init(gEnv->pScriptSystem, m_pSystem);
  26.         SetGlobalName("MaterialEffects");
  27.  
  28.         RegisterGlobals();
  29.         RegisterMethods();
  30. }
  31.  
  32. //------------------------------------------------------------------------
  33. CScriptBind_MaterialEffects::~CScriptBind_MaterialEffects()
  34. {
  35. }
  36.  
  37. //------------------------------------------------------------------------
  38. void CScriptBind_MaterialEffects::RegisterGlobals()
  39. {
  40.         gEnv->pScriptSystem->SetGlobalValue("MFX_INVALID_EFFECTID", InvalidEffectId);
  41. }
  42.  
  43. //------------------------------------------------------------------------
  44. void CScriptBind_MaterialEffects::RegisterMethods()
  45. {
  46. #undef SCRIPT_REG_CLASSNAME
  47. #define SCRIPT_REG_CLASSNAME &CScriptBind_MaterialEffects::
  48.  
  49.         SCRIPT_REG_TEMPLFUNC(GetEffectId, "customName, surfaceIndex2");
  50.         SCRIPT_REG_TEMPLFUNC(GetEffectIdByLibName, "LibName, FGFXName");
  51.         SCRIPT_REG_TEMPLFUNC(PrintEffectIdByMatIndex, "MatName1, MatName2");
  52.         SCRIPT_REG_TEMPLFUNC(ExecuteEffect, "effectId, paramsTable");
  53. }
  54.  
  55. //------------------------------------------------------------------------
  56. int CScriptBind_MaterialEffects::GetEffectId(IFunctionHandler* pH, const char* customName, int surfaceIndex2)
  57. {
  58.         TMFXEffectId effectId = m_pMFX->GetEffectId(customName, surfaceIndex2);
  59.  
  60.         return pH->EndFunction(effectId);
  61. }
  62.  
  63. //------------------------------------------------------------------------
  64. int CScriptBind_MaterialEffects::GetEffectIdByLibName(IFunctionHandler* pH, const char* LibName, const char* FGFXName)
  65. {
  66.         TMFXEffectId effectId = m_pMFX->GetEffectIdByName(LibName, FGFXName);
  67.  
  68.         return pH->EndFunction(effectId);
  69. }
  70.  
  71. //------------------------------------------------------------------------
  72. int CScriptBind_MaterialEffects::PrintEffectIdByMatIndex(IFunctionHandler* pH, int materialIndex1, int materialIndex2)
  73. {
  74.         TMFXEffectId effectId = m_pMFX->InternalGetEffectId(materialIndex1, materialIndex2);
  75.  
  76.         CryLogAlways("Requested MaterialEffect ID: %u", effectId);
  77.  
  78.         return pH->EndFunction(effectId);
  79. }
  80.  
  81. //------------------------------------------------------------------------
  82. int CScriptBind_MaterialEffects::ExecuteEffect(IFunctionHandler* pH, int effectId, SmartScriptTable paramsTable)
  83. {
  84.         if (effectId == InvalidEffectId)
  85.                 return pH->EndFunction(false);
  86.  
  87.         // minimalistic implementation.. extend if you need it
  88.         SMFXRunTimeEffectParams params;
  89.         paramsTable->GetValue("pos", params.pos);
  90.         paramsTable->GetValue("normal", params.normal);
  91.         paramsTable->GetValue("scale", params.scale);
  92.         paramsTable->GetValue("angle", params.angle);
  93.  
  94.         bool res = m_pMFX->ExecuteEffect(effectId, params);
  95.  
  96.         return pH->EndFunction(res);
  97. }
  98.  
downloadScriptBind_MaterialEffects.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