-
Автор темы
- #1
I'm releasing that cuz its useless, u will need CMergedMDL to render it on main menu xD
If u need any structs or classes just talk to me
To reset animation just set cycle to ur wanted value
If u need any structs or classes just talk to me
To reset animation just set cycle to ur wanted value
C++:
class panel_MDL : public Singleton<panel_MDL>
{
public:
c_base_animating* CreateModel(int entry, int serial, const char* path, bool weapon = false);
void Paint();
c_base_animating* player;
c_base_animating* weapon;
ITexture* buffer;
float x, y, w, h;
};
C++:
bool PrecacheModel(const char* szModelName)
{
INetworkStringTable* m_pModelPrecacheTable = interfaces::net_work_string->FindTable("modelprecache");
if (m_pModelPrecacheTable)
{
interfaces::new_mdl_info->FindOrLoadModel(szModelName);
int idx = m_pModelPrecacheTable->AddString(false, szModelName);
if (idx == INVALID_STRING_INDEX)
return false;
}
return true;
}
c_base_animating* panel_MDL::CreateModel(int entry, int serial, const char* path, bool weapon)
{
static c_client_class* client_class = nullptr;
if (!client_class)
client_class = interfaces::client_dll->get_all_classes();
while (client_class)
{
if (client_class->m_class_id == 12)
break;
client_class = client_class->m_next;
}
if (client_class)
{
auto cc = client_class->m_create_fn(entry, serial);
//Let's precache it to initialize any model in any map
auto loaded_model = PrecacheModel(path);
if (loaded_model)
{
auto flex = reinterpret_cast<c_base_animating*>(cc->get_client_unknown()->get_base_entity());
if (flex->initialize_as_client_entity(path, 0))
{
flex->get_effects() |= 0x20;
return flex;
}
}
}
return nullptr;
}
C++:
const char* sequence = "rom";
static bool can_frame_advance = false;
static auto reset_addr = SIG("client.dll", "56 8B F1 83 BE ? ? ? ? FF 75 0A 8B 06").get();
const auto reset_sequence = reinterpret_cast<void(__thiscall*)(void*)>(reset_addr);
if (!player) {
auto entry = interfaces::entity_list->get_highest_entity_index() + 1;
auto serial = random_int(0, 4095);
player = CreateModel(entry, serial, "models/player/custom_player/legacy/ctm_sas_varianta.mdl");
if (player->LookupSequence(sequence) != -1)
{
//Useless btw
reset_sequence(player);
player->SetCycle(0);
player->set_sequence(player->LookupSequence(sequence));
can_frame_advance = true;
}
weapon = CreateModel(entry + 1, random_int(0, 4095), "models/weapons/w_pist_deagle.mdl");
if (player && weapon)
weapon->FollowEntity(player, true);
}
static int x = 0;
static int y = 0;
static int _drag_x = 0;
static int _drag_y = 0;
static int w = 150;
static int h = 250;
static float rot_y;
static bool _dragging = false;
static bool _rotating = false;
bool _click = false;
bool _click2 = false;
auto MousePos = D::GetMousePosition();
if (GetAsyncKeyState(VK_LBUTTON)) _click = true;
if (GetAsyncKeyState(VK_RBUTTON)) _click2 = true;
if (_dragging && !_click)
{
_dragging = false;
}
if (_rotating && !_click2)
{
_rotating = false;
}
if (_dragging && _click)
{
x = MousePos.x - _drag_x;
y = MousePos.y - _drag_y;
}
if (_rotating && _click2)
{
rot_y = DEG2RAD(MousePos.x * 50);
}
if (D::MouseInRegion(x, y, w, h))
{
_dragging = true;
_rotating = true;
_drag_x = MousePos.x - x;
_drag_y = MousePos.y - y;
}
if (!player)
return;
//Using variable to performance optimizations
if (can_frame_advance)
player->FrameAdvance(interfaces::global_vars->m_frame_time);
float flWidthRatio = ((float)150.f / (float)250.f) / (4.0f / 3.0f);
CMatRenderContextPtr pRenderContext(interfaces::material_system);
auto orig = g::local->get_eye_position();
int viewportX, viewportY, viewportWidth, viewportHeight;
CViewSetup view;
memset(&view, 0, sizeof(view));
view.x = view.x_old = x;
view.y = view.y_old = y;
view.width = 150;
view.height = 250;
view.m_bOrtho = false;
this->x = view.x;
this->y = view.y;
this->w = view.width;
this->h = view.height;
float halfAngleRadians = 54 * (0.5f * M_PI / 180.0f);
float t = tan(halfAngleRadians);
t *= flWidthRatio;
float retDegrees = (180.0f / M_PI) * atan(t);
view.fov = retDegrees * 2;
view.origin = orig + vec3_t(-170, -5, -5);
vec3_t vMins, vMaxs;
auto model = interfaces::model_info->get_model(player->get_model_index());
interfaces::model_info->GetModelRenderBounds(model, vMins, vMaxs);
view.origin.z += (vMins.z + vMaxs.z) * 0.55f;
view.m_flAspectRatio = (float)view.width / (float)view.height;
view.angles = qangle_t();
view.zNear = 7;
view.zFar = 1000;
static auto pCubemapTexture = interfaces::material_system->FindTexture("editor/cubemap.hdr", NULL, true);
pRenderContext->BindLocalCubemap(pCubemapTexture);
pRenderContext->SetLightingOrigin(0, 0, 0);
static Vector4D whites[6] =
{
Vector4D(0.4, 0.4, 0.4, 1.f),
Vector4D(0.4, 0.4, 0.4, 1.f),
Vector4D(0.4, 0.4, 0.4, 1.f),
Vector4D(0.4, 0.4, 0.4, 1.f),
Vector4D(0.4, 0.4, 0.4, 1.f),
Vector4D(0.4, 0.4, 0.4, 1.f),
};
pRenderContext->SetAmbientLightCube(whites);
Frustum_t dummyFrustum;
interfaces::render_view->Push3DView(pRenderContext, view, 0, NULL, dummyFrustum);
interfaces::mdl_render->SuppressEngineLighting(true);
float color[3] = { 1.0f, 1.0f, 1.0f };
interfaces::render_view->SetColorModulation(color);
interfaces::render_view->SetBlend(1.0f);
player->set_abs_origin(orig);
player->set_abs_angles(qangle_t(0, math::normalize_yaw(rot_y), 0));
player->DrawModel(0x1, 255);
if (weapon)
weapon->DrawModel(0x1, 255);
interfaces::mdl_render->SuppressEngineLighting(false);
interfaces::render_view->PopView(pRenderContext, dummyFrustum);
pRenderContext->BindLocalCubemap(NULL);
C++:
VFUNC_SIG(FollowEntity(c_base_entity* ent, bool bBoneMerge), "client.dll", "55 8B EC 51 8B 45 08 56 8B F1 85 C0 0F 84 ? ? ? ? 6A 00", void(__thiscall*)(void*, c_base_entity*, bool), ent, bBoneMerge)
VFUNC(FrameAdvance(float adv), 220, float(__thiscall*)(void*, float), adv)
VFUNC(initialize_as_client_entity(const char* path, int flag), 96, bool(__thiscall*)(void*, const char*, int), path, flag)
Вложения
-
49.4 KB Просмотры: 1,086