请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

ESFKAMI

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

ESFX

ESF: Xenoverse

ESF123

ESF1.2.3

EVM2.1

EVM2.1

ECXSSJ

ECX: TeamSSJ

ECX2.2

ECX RC2

ECX2.3

ECX RC3

查看: 1352|回复: 0

[MetaHook]Studio Light Strength

[复制链接]

212

主题

217

帖子

1215

积分

ESFKAMI

Rank: 8Rank: 8

积分
1215
发表于 2017-7-14 16:47:48 | 显示全部楼层 |阅读模式

by hzqst

  1. #define R_STUDIOLIGHTING_SIG "\x51\xDB\x05\x2A\x2A\x2A\x2A\x8A\x4C\x24\x10\xB8\x01\x00\x00\x00\x84\xC8\xD9\x5C\x24\x00"
  2. #define R_STUDIOLIGHTING_SIG_NEW "\x55\x8B\xEC\x51\xDB\x05\x2A\x2A\x2A\x2A\x8A\x4D\x10\xB8\x01\x00\x00\x00\x84\xC8\xD9\x5D\xFC"

  3. #define STUDIO_NF_FULLBRIGHT  0x0004

  4. typedef struct
  5. {
  6.     void (*R_StudioLighting)(float *lv, int bone, int flags, vec3_t normal);
  7.         void (*R_StudioSetupLighting)(alight_t *plighting);
  8. }studiofuncs_t;

  9. studiofuncs_t gStudioFuncs;

  10. void InstallHook(void)
  11. {
  12.         if(g_dwEngineBuildnum >= 5953)
  13.                 gStudioFuncs.R_StudioLighting = (void (*)(float *, int, int, vec3_t))g_pMetaHookAPI->SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, R_STUDIOLIGHTING_SIG_NEW, sizeof(R_STUDIOLIGHTING_SIG_NEW)-1);
  14.         else
  15.                 gStudioFuncs.R_StudioLighting = (void (*)(float *, int, int, vec3_t))g_pMetaHookAPI->SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, R_STUDIOLIGHTING_SIG, sizeof(R_STUDIOLIGHTING_SIG)-1);

  16.         g_pMetaHookAPI->InlineHook(gStudioFuncs.R_StudioLighting, R_StudioLighting, (void *&)gStudioFuncs.R_StudioLighting);  
  17.         g_pMetaHookAPI->InlineHook(gStudioFuncs.R_StudioSetupLighting, R_StudioSetupLighting, (void *&)gStudioFuncs.R_StudioSetupLighting);  
  18. }

  19. int HUD_GetStudioModelInterface(int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio)
  20. {
  21.         gStudioFuncs.R_StudioSetupLighting = pstudio->StudioSetupLighting;

  22.         InstallHook();

  23.         return gExportFuncs.HUD_GetStudioModelInterface(version, ppinterface, pstudio);
  24. }

  25. alight_t g_savedLighting;

  26. void R_StudioSetupLighting(alight_t *plighting)
  27. {
  28.         memcpy(&g_savedLighting, plighting, sizeof(alight_t));
  29.         gStudioFuncs.R_StudioSetupLighting(plighting);
  30. }

  31. void R_StudioLighting(float *lv, int bone, int flags, vec3_t normal)
  32. {
  33.         if(flags & STUDIO_NF_FULLBRIGHT)
  34.         {
  35.                 //save the lighting strength at first.
  36.                 int r_ambientlight = g_savedLighting.ambientlight;
  37.                 float r_shadelight = g_savedLighting.shadelight;

  38.                 //changed to whatever you want
  39.                 g_savedLighting.ambientlight = 192;
  40.                 g_savedLighting.shadelight = 128.0f;

  41.                 //then call the original StudioSetupLighting to modify engine's r_ambientlight & r_shadelight.
  42.                 gStudioFuncs.studioapi_StudioSetupLighting(&g_savedLighting);

  43.                 //then call the original func the calculate the lighting value (lv)
  44.                 gHookFuncs.R_StudioLighting(lv, bone, flags, normal);

  45.                 //or you can just set *lv = 1 if you want it fullbright, if you do this way, there is no need to save or change the global lighting strength.
  46.                 //*lv = 1;

  47.                 //then set the lighting value back;
  48.                 g_savedLighting.ambientlight = r_ambientlight;
  49.                 g_savedLighting.shadelight = r_shadelight;

  50.                 //then call the original StudioSetupLighting to set engine's r_ambientlight & r_shadelight back.
  51.                 gStudioFuncs.studioapi_StudioSetupLighting(&g_savedLighting);
  52.                 return;
  53.         }

  54.         //nothing to do, just do the original way.
  55.         gHookFuncs.R_StudioLighting(lv, bone, flags, normal);
  56. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|ESFKAMI    

GMT+8, 2018-8-18 10:14 , Processed in 0.354428 second(s), 21 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表