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

◆ DoMeasurement()

void PoweredOptic_Base::DoMeasurement ( )
inlineprotected

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

136 {
137 PlayerBase player = GetPlayer();
138
139 if ( player )
140 {
141 vector from = GetGame().GetCurrentCameraPosition();
142 vector fromDirection = GetGame().GetCurrentCameraDirection();
143 vector to = from + (fromDirection * RANGEFINDER_MAX_DISTANCE);
144 vector contact_pos;
145 vector contact_dir;
146 int contactComponent;
147
148 bool hit = DayZPhysics.RaycastRV( from, to, contact_pos, contact_dir, contactComponent, NULL , NULL, player, false, false, ObjIntersectIFire);
149
150 // (a)
151 // from -> --- <- horizEnd
152 // (h) \ |
153 // to -> \|
154
155 // Generate result
156 float h = vector.Distance( from, contact_pos );
157
158 if (hit)
160 else
162
163 // Horizontal distance
164 TextWidget angleText = TextWidget.Cast(m_Root.FindAnyWidget("AngleText"));
165 TextWidget horizText = TextWidget.Cast(m_Root.FindAnyWidget("RangeHDText"));
166
167 vector horizontalTo = Vector( contact_pos[0], from[1], contact_pos[2] );
168 float a = vector.Distance( from, horizontalTo );
169
170 // Angle between horizontal and actual line
171 float heightDiff = contact_pos[1] - from[1];
172 float angle = Math.Atan( heightDiff / a ) * Math.RAD2DEG;
173 angle = Math.Round(angle);
174
175 if (angleText)
176 {
177 if (hit)
178 angleText.SetText(string.Format("%1", angle));
179 else
180 SetInvalidText( angleText );
181 }
182
183 if (horizText)
184 {
185 if (hit)
186 SetDistanceText( horizText, a );
187 else
188 SetInvalidText( horizText );
189 }
190 }
191 }
PlayerBase GetPlayer()
Определения ModifierBase.c:51
proto native vector GetCurrentCameraPosition()
proto native vector GetCurrentCameraDirection()
Widget m_Root
Определения Rangefinder.c:6
static const float RANGEFINDER_MAX_DISTANCE
Определения Rangefinder.c:3
void SetDistanceText(TextWidget text, float dist)
Определения Rangefinder.c:110
void SetInvalidText(TextWidget text)
Определения Rangefinder.c:129
TextWidget m_RangeText
Определения Rangefinder.c:7
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

Перекрестные ссылки Math::Atan(), vector::Distance(), CGame::GetCurrentCameraDirection(), CGame::GetCurrentCameraPosition(), GetGame(), GetPlayer(), m_RangeText, m_Root, Math::RAD2DEG, RANGEFINDER_MAX_DISTANCE, DayZPhysics::RaycastRV(), Math::Round(), SetDistanceText(), SetInvalidText() и Vector().