-
Автор темы
- #1
as said above
this is not fully finished but not hard to do u can easy make this into the v3 / v4 version if you want to do it
the render function
the visual part
the dot_product
this is not fully finished but not hard to do u can easy make this into the v3 / v4 version if you want to do it
the render function
C++:
void render::filled_rect_world(Vector center, Vector2D size, Color color, int angle) {
Vector top_left, top_right, bot_left, bot_right;
switch (angle) {
case 0: // Z
top_left = Vector(-size.x, -size.y, 0);
top_right = Vector(size.x, -size.y, 0);
bot_left = Vector(-size.x, size.y, 0);
bot_right = Vector(size.x, size.y, 0);
break;
case 1: // Y
top_left = Vector(-size.x, 0, -size.y);
top_right = Vector(size.x, 0, -size.y);
bot_left = Vector(-size.x, 0, size.y);
bot_right = Vector(size.x, 0, size.y);
break;
case 2: // X
top_left = Vector(0, -size.y, -size.x);
top_right = Vector(0, -size.y, size.x);
bot_left = Vector(0, size.y, -size.x);
bot_right = Vector(0, size.y, size.x);
break;
}
//top line
Vector c_top_left = center + add_top_left;
Vector c_top_right = center + add_top_right;
//bottom line
Vector c_bot_left = center + add_bot_left;
Vector c_bot_right = center + add_bot_right;
Vector m_flTopleft, m_flTopRight, m_flBotLeft, m_flBotRight;
//your standard world to screen if u need one just grab from a past
if (WorldToScreen(c_top_left, m_flTopleft) && WorldToScreen(c_top_right, m_flTopRight) &&
WorldToScreen(c_bot_left, m_flBotLeft) && WorldToScreen(c_bot_right, m_flBotRight)) {
Vertex_t vertices[4];
static int m_flTexID = g_pSurface->CreateNewTextureID(true);
g_pSurface->DrawSetTexture( m_flTexID );
g_pSurface->DrawSetColor( color );
vertices[0].Init(Vector2D(m_flTopleft.x, m_flTopleft.y));
vertices[1].Init(Vector2D(m_flTopRight.x, m_flTopRight.y));
vertices[2].Init(Vector2D(m_flBotRight.x, m_flBotRight.y));
vertices[3].Init(Vector2D(m_flBotLeft.x, m_flBotLeft.y));
g_pSurface->DrawTexturedPolygon2(4, vertices, true);
}
}
C++:
void visuals::pencross()
{
//add a check for if your dead cant be bothered
if (!g_pEngine->IsInGame() || !g_pLocalPlayer)
return;
const auto m_flWeapon = get_weapon(g_pLocalPlayer->get_active_weapon());
if (!m_flWeapon)
return;
const auto m_flWeaponInfo = (m_flWeapon->get_wpn_data());
if (!m_flWeaponInfo)
return;
//yes this is messy and badish i norm clean up the code when i am done with it but cant be bothered atm and its not fully done yet
CGameTrace enterTrace;
CTraceFilter filter;
Ray_t ray;
QAngle viewangles; g_pEngine->GetViewAngles(viewangles);
Vector direction; math::get().angle_vectors(viewangles, &direction);
Vector start = g_pLocalPlayer->get_eye_pos();
auto m_flMaxRange = m_flWeaponInfo->m_flRange * 2; //
Vector end = start + (direction * m_flMaxRange);
// u can just use your cheat traceline
filter.pSkip = g_pLocalPlayer;
ray.Init(start, end);
g_pTrace->TraceRay(ray, MASK_SHOT | CONTENTS_GRATE, &filter, &enterTrace);
float angle_z = math::get().dot_product(Vector(0, 0, 1), enterTrace.plane.normal);
float invangle_z = math::get().dot_product(Vector(0, 0, -1), enterTrace.plane.normal);
float angle_y = math::get().dot_product(Vector(0, 1, 0), enterTrace.plane.normal);
float invangle_y = math::get().dot_product(Vector(0, -1, 0), enterTrace.plane.normal);
float angle_x = math::get().dot_product(Vector(1, 0, 0), enterTrace.plane.normal);
float invangle_x = math::get().dot_product(Vector(-1, 0, 0), enterTrace.plane.normal);
//--------------------------------------------------------------------------------------------------------------------\\
if u wanna do pen color change just do something like if can pen color red else green
//--------------------------------------------------------------------------------------------------------------------\\
//if u wanna do something like otv3 /4 thats not hard at all
if (angle_z > 0.5 || invangle_z > 0.5)
render::get().filled_rect_world(enterTrace.endpos, Vector2D(5, 5), Color(34, 139, 34 , 179), 0);
else if (angle_y > 0.5 || invangle_y > 0.5)
render::get().filled_rect_world(enterTrace.endpos, Vector2D(5, 5), Color(34, 139, 34, 179), 1);
else if (angle_x > 0.5 || invangle_x > 0.5)
render::get().filled_rect_world(enterTrace.endpos, Vector2D(5, 5), Color(34, 139, 34, 179), 2);
}
C++:
float math::dot_product( const Vector v1, const Vector v2 )
{
return v1[ 0 ] * v2[ 0 ] + v1[ 1 ] * v2[ 1 ] + v1[ 2 ] * v2[ 2 ];
}
Последнее редактирование: