@@ -1147,6 +1147,57 @@ luabind::object CScriptGameObject::GetShaders(bool bHud)
11471147 return table;
11481148}
11491149
1150+ luabind::object CScriptGameObject::GetDefaultShaders (bool bHud)
1151+ {
1152+ IKinematics* k = nullptr ;
1153+
1154+ if (bHud)
1155+ {
1156+ CActor* act = smart_cast<CActor*>(&object ());
1157+ CHudItem* itm = smart_cast<CHudItem*>(&object ());
1158+ if (itm)
1159+ k = itm->HudItemData ()->m_model ;
1160+ else if (act)
1161+ k = g_player_hud->m_model ->dcast_PKinematics ();
1162+ }
1163+
1164+ if (!k)
1165+ k = object ().Visual ()->dcast_PKinematics ();
1166+
1167+ luabind::object table = luabind::newtable (ai ().script_engine ().lua ());
1168+
1169+ if (!k)
1170+ {
1171+ table[" error" ] = true ;
1172+ return table;
1173+ }
1174+
1175+ IRenderVisual* vis = k->dcast_RenderVisual ();
1176+ xr_vector<IRenderVisual*>* children = vis->get_children ();
1177+
1178+ if (!children)
1179+ {
1180+ luabind::object subtable = luabind::newtable (ai ().script_engine ().lua ());
1181+ subtable[" shader" ] = vis->getDebugShaderDef ();
1182+ subtable[" texture" ] = vis->getDebugTextureDef ();
1183+ table[1 ] = subtable;
1184+ return table;
1185+ }
1186+
1187+ int i = 1 ;
1188+
1189+ for (auto * child : *children)
1190+ {
1191+ luabind::object subtable = luabind::newtable (ai ().script_engine ().lua ());
1192+ subtable[" shader" ] = child->getDebugShaderDef ();
1193+ subtable[" texture" ] = child->getDebugTextureDef ();
1194+ table[i] = subtable;
1195+ ++i;
1196+ }
1197+
1198+ return table;
1199+ }
1200+
11501201void set_shader_tex (IRenderVisual* vis, int id, LPCSTR shader, LPCSTR texture)
11511202{
11521203 xr_vector<IRenderVisual*>* children = vis->get_children ();
@@ -1172,6 +1223,31 @@ void set_shader_tex(IRenderVisual* vis, int id, LPCSTR shader, LPCSTR texture)
11721223 children->at (id)->SetShaderTexture (shader, texture);
11731224}
11741225
1226+ void reset_shader_tex (IRenderVisual* vis, int id)
1227+ {
1228+ xr_vector<IRenderVisual*>* children = vis->get_children ();
1229+
1230+ if (!children)
1231+ {
1232+ vis->ResetShaderTexture ();
1233+ return ;
1234+ }
1235+
1236+ if (id == -1 )
1237+ {
1238+ for (auto * child : *children)
1239+ {
1240+ child->ResetShaderTexture ();
1241+ }
1242+ return ;
1243+ }
1244+
1245+ id--;
1246+
1247+ if (id >= 0 && children->size () > id)
1248+ children->at (id)->ResetShaderTexture ();
1249+ }
1250+
11751251void CScriptGameObject::SetShaderTexture (int id, LPCSTR shader, LPCSTR texture, bool bHud)
11761252{
11771253 IKinematics* k = nullptr ;
@@ -1197,3 +1273,29 @@ void CScriptGameObject::SetShaderTexture(int id, LPCSTR shader, LPCSTR texture,
11971273
11981274 set_shader_tex (k->dcast_RenderVisual (), id, shader, texture);
11991275}
1276+
1277+ void CScriptGameObject::ResetShaderTexture (int id, bool bHud)
1278+ {
1279+ IKinematics* k = nullptr ;
1280+
1281+ if (bHud)
1282+ {
1283+ CActor* act = smart_cast<CActor*>(&object ());
1284+ CHudItem* itm = smart_cast<CHudItem*>(&object ());
1285+ if (itm)
1286+ k = itm->HudItemData ()->m_model ;
1287+ else if (act)
1288+ {
1289+ reset_shader_tex (g_player_hud->m_model ->dcast_RenderVisual (), id);
1290+ reset_shader_tex (g_player_hud->m_model_2 ->dcast_RenderVisual (), id);
1291+ return ;
1292+ }
1293+ }
1294+
1295+ if (!k)
1296+ k = object ().Visual ()->dcast_PKinematics ();
1297+
1298+ if (!k) return ;
1299+
1300+ reset_shader_tex (k->dcast_RenderVisual (), id);
1301+ }
0 commit comments