DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ DrawLineOfFireCameraHybrid()

void WeaponDebug::DrawLineOfFireCameraHybrid ( vector usti_hlavne_position,
vector camera_dir,
vector camera_pos,
vector konec_hlavne_position )
inlineprivate

См. определение в файле WeaponDebug.c строка 354

355 {
356 bool muzzle_shot;
357 vector contact_point_cam_trace;
358 vector contact_point_muzzle_trace;
359
360 vector aim_at_position;
361
362 vector contact_dir_muzzle;
363 vector contact_dir;
364
365 vector contact_point;
366
367 int contact_component;
368 int contact_component_muzzle;
369
370 float distance_to_aim_at;
371 vector end_point = camera_pos + camera_dir * 100;
372 vector start_point = camera_pos + (CAMERA_BULLET_ORIGIN_OFFSET * camera_dir);
373 vector weapon_aim_direction = usti_hlavne_position - konec_hlavne_position;
374 weapon_aim_direction.Normalize();
375
376 Man player = g_Game.GetPlayer();
377 Object player_o;
378 Class.CastTo(player_o, player);
379
380 if ( DayZPhysics.RaycastRV(start_point, end_point, contact_point_cam_trace, contact_dir, contact_component,null, null, player_o , false, false, ObjIntersectFire) )
381 {
382 m_TargetDistance = vector.Distance(start_point, contact_point_cam_trace);
383 aim_at_position = contact_point_cam_trace;
384
385 if ( DayZPhysics.RaycastRV(usti_hlavne_position, contact_point_cam_trace, contact_point_muzzle_trace, contact_dir, contact_component,null, null, player_o , false, false, ObjIntersectFire, 0.05) )
386 {
387 float collision_distance = vector.Distance(contact_point_cam_trace, contact_point_muzzle_trace);
388 float muzzle_collision_distance = vector.Distance(usti_hlavne_position, contact_point_muzzle_trace);
389
390 if ((collision_distance > 2 && muzzle_collision_distance < MAX_MUZZLE_DISTANCE_TOLERANCE) || m_TargetDistance < CAMERA_TRACE_MIN_DISTANCE_TOLERANCE)
391 {
392 muzzle_shot = true;
393 aim_at_position = contact_point_muzzle_trace;
394 }
395 }
396 }
397
398
399
400 distance_to_aim_at = vector.Distance(camera_pos, aim_at_position);
401
402 if ( m_IsFireKeyPressed )
403 {
404 Debug.RemoveShape(m_PermanentLine1);
405 Debug.RemoveShape(m_PermanentLine2);
406 Debug.RemoveShape(m_PermanentShape1);
407
408 vector contact_point_temp;
409
410 if (muzzle_shot)
411 {
412 m_PermanentLine1 = Debug.DrawLine(usti_hlavne_position, usti_hlavne_position + weapon_aim_direction * 5, Colors.RED, ShapeFlags.NOZBUFFER );
413 m_PermanentLine2 = Debug.DrawLine(camera_pos, contact_point_cam_trace, Colors.GREEN, ShapeFlags.NOZBUFFER );
414 PrintString("muzle shot");
415 }
416 else
417 {
418 vector dir = contact_point_cam_trace - camera_pos;
419 dir.Normalize();
420 dir = dir * 100;
421 float dst = vector.Distance(camera_pos, contact_point_cam_trace);
422 float dist2 = vector.Distance(camera_pos, contact_point_cam_trace);
423
424 //m_PermanentShape1 = Debug.DrawSphere(start_point, 0.015,Colors.GREEN);
425 m_PermanentLine1 = Debug.DrawLine(start_point, contact_point_cam_trace + dir, Colors.RED, ShapeFlags.NOZBUFFER );
426 PrintString("camera shot");
427 }
428 }
429
430 float clamped_distance = Math.Clamp(distance_to_aim_at, 0 , 100);
431 float distance_normalized = Math.InverseLerp(0, 100, clamped_distance);
432 float hit_sphere_size = Math.Lerp(0.025, 0.75, distance_normalized);
433
434 Debug.RemoveShape(m_HitShape4);
435 Debug.RemoveShape(m_HitShape);
436 m_HitShape = Debug.DrawSphere(contact_point_cam_trace, 0.20,Colors.GREEN, ShapeFlags.TRANSP);
437 m_HitShape4 = Debug.DrawSphere(aim_at_position, hit_sphere_size);
438
439 }
string Debug()
Определения CachedEquipmentStorageBase.c:29
DayZGame g_Game
Определения DayZGame.c:3942
const float CAMERA_TRACE_MIN_DISTANCE_TOLERANCE
Определения WeaponDebug.c:17
bool m_IsFireKeyPressed
Определения WeaponDebug.c:24
Shape m_HitShape4
Определения WeaponDebug.c:44
const float MAX_MUZZLE_DISTANCE_TOLERANCE
Определения WeaponDebug.c:15
Shape m_PermanentLine2
Определения WeaponDebug.c:47
const float CAMERA_BULLET_ORIGIN_OFFSET
Определения WeaponDebug.c:16
Shape m_PermanentLine1
Определения WeaponDebug.c:46
Shape m_PermanentShape1
Определения WeaponDebug.c:49
float m_TargetDistance
Определения WeaponDebug.c:25
Shape m_HitShape
Определения WeaponDebug.c:38
proto float Normalize()
Normalizes vector. Returns length.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
class LOD Object
@ Colors
Определения EnWorld.c:88
ShapeFlags
Определения EnDebug.c:126
class array< Class T > PrintString

Перекрестные ссылки CAMERA_BULLET_ORIGIN_OFFSET, CAMERA_TRACE_MIN_DISTANCE_TOLERANCE, Class::CastTo(), Math::Clamp(), vector::Distance(), Debug::DrawLine(), Debug::DrawSphere(), g_Game, Colors::GREEN, Math::InverseLerp(), Math::Lerp(), m_HitShape, m_HitShape4, m_IsFireKeyPressed, m_PermanentLine1, m_PermanentLine2, m_PermanentShape1, m_TargetDistance, MAX_MUZZLE_DISTANCE_TOLERANCE, vector::Normalize(), PrintString, DayZPhysics::RaycastRV(), Colors::RED и Debug::RemoveShape().

Используется в OnPostFrameUpdate().