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

◆ FloatingCrossHair()

void FloatingCrossHair ( Widget widget)
protected

Highly WIP, do not use.

Only intended to be used with track IR

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

230 {
231 HumanInputController hic = m_Player.GetInputController();
232
234 if (!hic.CameraIsTracking())
235 {
236 widget.SetPos(0, 0);
237 widget.Update();
238 return;
239 }
240
241 ActionBase action = m_AM.GetRunningAction();
242
243 float dt = GetDayZGame().GetDeltaT();
244
245 HumanCommandWeapons hcw = m_Player.GetCommandModifier_Weapons();
246
247 vector transform[4];
248 m_Player.GetTransformWS(transform);
249
250 vector aimAngles = Vector(hcw.GetBaseAimingAngleLR(), hcw.GetBaseAimingAngleUD(), 0.0);
251 vector plrAngles = Math3D.MatrixToAngles(transform);
252
253 aimAngles = Vector(0.0, hcw.GetBaseAimingAngleUD(), 0.0);
254 plrAngles = Vector(hic.GetHeadingAngle() * -Math.RAD2DEG, 0, 0);
255
256 vector resAngle = aimAngles + plrAngles;
257
258 vector start;
259 MiscGameplayFunctions.GetHeadBonePos(m_Player, start);
260
261 vector direction = resAngle.AnglesToVector();
262
263 int layer = ObjIntersectView;
264 float range = 1.0;
265
266 Weapon_Base weapon;
267 if (Class.CastTo(weapon, m_Player.GetItemInHands()) && m_Player.IsRaised())
268 {
269 layer = ObjIntersectFire;
270 range = 10.0;
271
272 vector usti_hlavne_position = weapon.GetSelectionPositionMS( "usti hlavne" );
273 vector konec_hlavne_position = weapon.GetSelectionPositionMS( "konec hlavne" );
274 usti_hlavne_position = m_Player.ModelToWorld(usti_hlavne_position);
275 konec_hlavne_position = m_Player.ModelToWorld(konec_hlavne_position);
276
277 vector contact_dir;
278 int contact_component;
279
280 direction = konec_hlavne_position - usti_hlavne_position;
281 direction.Normalize();
282
283 start = konec_hlavne_position;
284
286 }
287 else
288 {
290 {
292 m_PreviousDirection = direction;
293 }
294
295 float r0[4];
296 float r1[4];
297
298 vector t[4];
299
301 Math3D.MatrixToQuat(t, r0);
302
303 Math3D.DirectionAndUpMatrix(direction, vector.Up, t);
304 Math3D.MatrixToQuat(t, r1);
305
306 Math3D.QuatLerp(r0, r0, r1, 0.1);
307
308 Math3D.QuatToMatrix(r0, t);
309
310 direction = t[2];
311
312 m_PreviousDirection = direction;
313 }
314
315 vector end = start + (direction * range);
316 vector position = end;
317
318 DayZPhysics.RaycastRV(start, end, position, contact_dir, contact_component, null, m_Player, m_Player, false, false, layer);
319
320 /*
321 vector lines[2];
322 lines[0] = start;
323 lines[1] = end;
324
325 Shape.CreateSphere(0xFFFFFF00, ShapeFlags.ONCE, usti_hlavne_position, 0.1);
326 Shape.CreateSphere(0xFFFFFF00, ShapeFlags.ONCE, konec_hlavne_position, 0.1);
327 Shape.CreateLines(0xFF00FF00, ShapeFlags.ONCE, lines, 2);
328 */
329
330 vector screenSpace = GetGame().GetScreenPos(position);
331
332 float sx, sy;
333 widget.GetScreenSize(sx, sy);
334 screenSpace[0] = screenSpace[0] - (sx * 0.5);
335 screenSpace[1] = screenSpace[1] - (sy * 0.5);
336
337 widget.SetScreenPos(screenSpace[0], screenSpace[1]);
338 widget.Update();
339 }
ActionManagerBase m_AM
Определения CrossHairSelector.c:57
vector m_PreviousDirection
Floating crosshair.
Определения CrossHairSelector.c:64
bool m_PreviousDirectionSet
Определения CrossHairSelector.c:65
DayZGame GetDayZGame()
Определения DayZGame.c:3870
DayZPlayer m_Player
Определения Hand_Events.c:42
Определения ActionBase.c:53
proto native vector GetScreenPos(vector world_pos)
Transforms position in world to position in screen in pixels as x, y component of vector,...
Super root of all classes in Enforce script.
Определения EnScript.c:11
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
Определения DayZPhysics.c:124
proto native float GetBaseAimingAngleLR()
returns base aiming angle LR - without sway/offsets/...
proto native float GetBaseAimingAngleUD()
returns base aiming angle UD - without sway/offsets/...
Определения human.c:994
proto native bool CameraIsTracking()
returns if camera is tracking (using IR device)
proto native float GetHeadingAngle()
returns main heading angle (in radians) -PI .. PI (this is world Y angle player is actualy pointing t...
Определения human.c:18
Определения EnMath3D.c:28
Определения EnMath.c:7
shorthand
Определения BoltActionRifle_Base.c:6
proto float Normalize()
Normalizes vector. Returns length.
static const vector Up
Определения EnConvert.c:107
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
Определения EnConvert.c:106
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto void QuatToMatrix(float q[4], out vector mat[3])
Converts quaternion to rotation matrix.
static proto vector MatrixToAngles(vector mat[3])
Returns angles of rotation matrix.
static proto void QuatLerp(out float qout[4], float q1[4], float q2[4], float frac)
Linear interpolation between q1 and q2 with weight 'frac' (0...1)
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4])
Creates rotation matrix from direction and up vector.
static const float RAD2DEG
Определения EnMath.c:16

Перекрестные ссылки vector::AnglesToVector(), HumanInputController::CameraIsTracking(), Class::CastTo(), Math3D::DirectionAndUpMatrix(), HumanCommandWeapons::GetBaseAimingAngleLR(), HumanCommandWeapons::GetBaseAimingAngleUD(), GetDayZGame(), GetGame(), HumanInputController::GetHeadingAngle(), CGame::GetScreenPos(), m_AM, m_Player, m_PreviousDirection, m_PreviousDirectionSet, Math3D::MatrixToAngles(), Math3D::MatrixToQuat(), vector::Normalize(), Math3D::QuatLerp(), Math3D::QuatToMatrix(), Math::RAD2DEG, DayZPhysics::RaycastRV(), vector::Up и Vector().

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