summaryrefslogtreecommitdiffstats
path: root/src/studio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/studio.cpp')
-rw-r--r--src/studio.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/studio.cpp b/src/studio.cpp
index 1b7b77d..d472fbc 100644
--- a/src/studio.cpp
+++ b/src/studio.cpp
@@ -211,12 +211,26 @@ void *chams_material() {
211 return g_chams_mat; 211 return g_chams_mat;
212} 212}
213 213
214void chams_apply(void *mat, bool ignorez) { 214void chams_color(void *mat, float r, float g, float b) {
215 using ColorFn = void (*)(void *, float, float, float); 215 using ColorFn = void (*)(void *, float, float, float);
216 using FindVarFn = void *(*)(void *, const char *, bool *, bool);
217 using SetVec3Fn = void (*)(void *, float, float, float);
218 bool found = false;
219 void *var = vfunc<FindVarFn>(mat, 11)(mat, "$color", &found, false);
220 if (var)
221 vfunc<SetVec3Fn>(var, 11)(var, r, g, b);
222 found = false;
223 var = vfunc<FindVarFn>(mat, 11)(mat, "$color2", &found, false);
224 if (var)
225 vfunc<SetVec3Fn>(var, 11)(var, r, g, b);
226 vfunc<ColorFn>(mat, 28)(mat, r, g, b);
227}
228
229void chams_apply(void *mat, bool ignorez) {
216 using FlagFn = void (*)(void *, int, bool); 230 using FlagFn = void (*)(void *, int, bool);
217 vfunc<ColorFn>(mat, 28)(mat, (float)g_chams_rgb[0] / 255.0f, 231 chams_color(mat, (float)g_chams_rgb[0] / 255.0f,
218 (float)g_chams_rgb[1] / 255.0f, 232 (float)g_chams_rgb[1] / 255.0f,
219 (float)g_chams_rgb[2] / 255.0f); 233 (float)g_chams_rgb[2] / 255.0f);
220 vfunc<FlagFn>(mat, 29)(mat, 1 << 15 /* MATERIAL_VAR_IGNOREZ */, ignorez); 234 vfunc<FlagFn>(mat, 29)(mat, 1 << 15 /* MATERIAL_VAR_IGNOREZ */, ignorez);
221} 235}
222 236
@@ -240,10 +254,9 @@ void hkdModelExecute(void *self, const void *state, const void *info,
240 g_orig_model_exec(self, state, info, bone); 254 g_orig_model_exec(self, state, info, bone);
241 g_force_override(self, nullptr, 0); 255 g_force_override(self, nullptr, 0);
242 // debugwhite is shared: restore colour and depth behaviour. 256 // debugwhite is shared: restore colour and depth behaviour.
243 using ColorFn = void (*)(void *, float, float, float);
244 using FlagFn = void (*)(void *, int, bool); 257 using FlagFn = void (*)(void *, int, bool);
245 vfunc<FlagFn>(mat, 29)(mat, 1 << 15, false); 258 vfunc<FlagFn>(mat, 29)(mat, 1 << 15, false);
246 vfunc<ColorFn>(mat, 28)(mat, 1.0f, 1.0f, 1.0f); 259 chams_color(mat, 1.0f, 1.0f, 1.0f);
247 return; 260 return;
248 } 261 }
249 } 262 }