4 vector m_FreeflightCamTransform[4];
14 protected int m_NextCameraIndex = 1;
75 m_Camera1.SetActive(
false );
76 m_Camera2.SetActive(
false );
83 MissionGameplay ms = MissionGameplay.Cast(
GetGame().GetMission() );
85 ms.GetHud().Show(
true );
109 if ( m_SelectedKeyframe )
110 m_SelectedKeyframe.Unselect();
112 m_SelectedKeyframe = kf;
113 m_SelectedKeyframe.Select();
118 m_SelectedEvent = ev;
123 m_SelectedActor = ac;
130 m_KeyframeContent = layoutRoot.FindAnyWidget(
"keyframe_list_content" );
131 m_EventContent = layoutRoot.FindAnyWidget(
"events_list_content" );
132 m_InterpTypeCombo = XComboBoxWidget.Cast( layoutRoot.FindAnyWidget(
"interp_type" ) );
133 m_InterpTypeSpeedCombo = XComboBoxWidget.Cast( layoutRoot.FindAnyWidget(
"interp_speed_type" ) );
134 m_BlurEditWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget(
"blur_value" ) );
135 m_ActorTypeWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget(
"add_actor_type" ) );
136 m_ActorIdWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget(
"add_actor_id" ) );
137 m_ActorItemTypeWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget(
"add_item_type" ) );
139 m_AddKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"add_keyframe" ) );
140 m_AddEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"add_event" ) );
142 m_AddItem = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"add_actor_item" ) );
143 m_AddHandsItem = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"add_actor_item_hands" ) );
144 m_AddActor = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"add_actor" ) );
145 m_Play = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"play" ) );
146 m_Stop = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"stop" ) );
147 m_Save = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"save" ) );
148 m_Load = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"load" ) );
150 m_SaveKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"save_keyframe" ) );
151 m_DeleteKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"delete_keyframe" ) );
152 m_ViewKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"snap_to_keyframe" ) );
153 m_SaveEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"save_event" ) );
154 m_DeleteEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"delete_event" ) );
155 m_ViewEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"snap_to_event" ) );
157 m_CopyButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"CopyButton" ) );
158 m_ApplyButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget(
"ApplyButton" ) );
159 m_CameraEditbox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget(
"CameraEditbox" ) );
160 m_CameraValues =
TextWidget.Cast( layoutRoot.FindAnyWidget(
"CameraValues" ) );
162 MissionGameplay ms = MissionGameplay.Cast(
GetGame().GetMission() );
163 ms.GetHud().Show(
false );
166 m_BlurEditWidget.SetText(
"0.0" );
172 if ( index > -1 && index < m_Actors.Count() )
173 return PlayerBase.Cast( m_Actors.Get( index ).GetObj() );
186 cb.EnableCancelCondition(
true);
201 JsonFileLoader<ref CTSaveStructure>.JsonLoadFile(
g_Game.GetMissionFolderPath() +
"/CameraTools/keyframe_data.json", save_data );
203 m_InterpTypeCombo.SetCurrentItem( save_data.
m_InterpType );
204 m_InterpTypeSpeedCombo.SetCurrentItem( save_data.
m_InterpSpeed );
207 foreach ( Param6<vector, vector, float, float, float, int> transform : save_data.
m_Cameras )
209 CTKeyframe kf =
new CTKeyframe( m_Cameras.Count(), transform.param1, transform.param2, transform.param3, transform.param4, transform.param5, transform.param6, GetTotalTime( m_Cameras.Count() ), m_KeyframeContent,
this );
210 kf.SetInterpTime( transform.param3 );
211 m_Cameras.Insert( kf );
214 foreach ( Param4<int, int, float, bool> event_t : save_data.
m_Events )
216 CTEvent ev =
new CTEvent( m_Events.Count(), event_t.param1, m_EventContent, event_t.param4,
this );
217 ev.SetEventType( event_t.param2 );
218 ev.SetEventTime( event_t.param3 );
219 m_Events.Insert( ev );
224 CTActor ac =
new CTActor( m_Actors.Count(), actor_t.param1, actor_t.param2, actor_t.param3, actor_t.param4, actor_t.param5,
this );
225 m_Actors.Insert( ac );
235 save_data.
m_InterpType = m_InterpTypeCombo.GetCurrentItem();
236 save_data.
m_InterpSpeed = m_InterpTypeSpeedCombo.GetCurrentItem();
239 foreach ( CTKeyframe keyframe : m_Cameras )
241 Param6<vector, vector, float, float, float, int> transform =
new Param6<vector, vector, float, float, float, int>( keyframe.GetPosition(), keyframe.GetOrientation(), keyframe.GetInterpTime(), keyframe.GetFOV(), keyframe.GetDOF(), keyframe.GetPin() );
245 foreach ( CTEvent event_t : m_Events )
247 Param4<int, int, float, bool> ev =
new Param4<int, int, float, bool>( event_t.GetEventActor(), event_t.GetEventType(), event_t.GetEventTime(), event_t.GetEventWalk() );
251 foreach ( CTActor actor_t : m_Actors )
253 Param5<vector, vector, string, ref array<string>,
string> ac =
new Param5<vector, vector, string, ref array<string>,
string>( actor_t.GetPosition(), actor_t.GetRotation(), actor_t.GetActorType(), actor_t.GetItems(), actor_t.GetHandsItem() );
257 JsonFileLoader<ref CTSaveStructure>.JsonSaveFile(
g_Game.GetMissionFolderPath() +
"/CameraTools/keyframe_data.json", save_data );
263 index =
Math.
Clamp( index, 0, m_Cameras.Count() );
264 for (
int i = 0; i < index; i++ )
266 time += m_Cameras.Get( i ).GetInterpTime();
273 if (
Camera.GetCurrentCamera() )
275 vector pos =
Camera.GetCurrentCamera().GetWorldPosition();
276 vector orient =
Camera.GetCurrentCamera().GetOrientation();
277 CTKeyframe kf =
new CTKeyframe( m_Cameras.Count(), pos, orient, 1, 70, 50, -1, GetTotalTime( m_Cameras.Count() ), m_KeyframeContent,
this );
278 m_Cameras.Insert( kf );
279 SelectKeyframe( kf );
285 if ( m_SelectedKeyframe &&
Camera.GetCurrentCamera() )
287 m_SelectedKeyframe.SetPosition(
Camera.GetCurrentCamera().GetWorldPosition() );
288 m_SelectedKeyframe.SetOrientation(
Camera.GetCurrentCamera().GetOrientation() );
294 if ( m_SelectedKeyframe )
296 int index = m_Cameras.Find( m_SelectedKeyframe );
297 m_Cameras.Remove( index );
298 index =
Math.
Clamp( index, 0, m_Cameras.Count() - 1 );
299 if ( m_Cameras.Count() > 0 )
301 SelectKeyframe( m_Cameras.Get( index ) );
308 if ( m_SelectedKeyframe &&
Camera.GetCurrentCamera() )
310 Camera.GetCurrentCamera().SetPosition( m_SelectedKeyframe.GetPosition() );
311 Camera.GetCurrentCamera().SetOrientation( m_SelectedKeyframe.GetOrientation() );
317 vector pos = GetCameraLookDir();
318 CTActor ac =
new CTActor( m_Actors.Count(), pos,
"0 0 0", actor_type,
new array<string>,
"",
this );
320 m_Actors.Insert( ac );
325 if ( actor_index > -1 )
327 CTEvent ev =
new CTEvent( m_Events.Count(), actor_index, m_EventContent,
false,
this );
328 m_Events.Insert( ev );
335 int id_int =
id.ToInt();
336 if ( m_Actors.Count() > id_int && id_int > -1 )
338 CTActor ac = m_Actors.Get( id_int );
346 int id_int =
id.ToInt();
347 if ( m_Actors.Count() > id_int && id_int > -1 )
349 CTActor ac = m_Actors.Get( id_int );
351 ac.SetHandsItem( type );
372 if ( index > -1 && index < m_CameraLines.Count() )
374 return m_CameraLines[index];
381 if (
Camera.GetCurrentCamera())
382 Camera.GetCurrentCamera().GetTransform(m_FreeflightCamTransform);
383 if ( m_Cameras.Count() > 0 )
385 layoutRoot.Show(
false );
389 foreach ( CTKeyframe keyframe : m_Cameras )
391 Param6<vector, vector, float, float, float, int> transform =
new Param6<vector, vector, float, float, float, int>( keyframe.GetPosition(), keyframe.GetOrientation(), keyframe.GetInterpTime(), keyframe.GetFOV(), keyframe.GetDOF(), keyframe.GetPin() );
392 m_CameraLines.Insert( transform );
396 foreach ( CTActor ac : m_Actors )
401 foreach ( CTEvent ev : m_Events )
408 int time = SetCameraData( GetCameraLine( 0 ), GetCameraLine( 1 ) );
410 if ( GetCameraLine( 0 ).param6 > -1 )
412 m_FollowingTimeFinished = time;
413 m_NextCamPosition =
"0 0 0";
414 m_Camera1.SetActive(
true );
418 m_NextCamPosition = m_Camera2.GetPosition();
419 m_FollowingTimeFinished = -1;
420 m_Camera1.SetActive(
true );
421 m_Camera1.InterpolateTo( m_Camera2, time, m_InterpTypeCombo.GetCurrentItem() );
424 m_NextCameraIndex = 1;
432 layoutRoot.Show(
true );
435 m_Camera1.SetActive(
false );
436 m_Camera2.SetActive(
false );
439 m_NextCameraIndex = 1;
442 foreach ( CTEvent ev : m_Events )
447 foreach ( CTActor ac : m_Actors )
453 Camera.GetCurrentCamera().SetTransform(m_FreeflightCamTransform);
458 vector dir = FreeDebugCamera.GetInstance().GetDirection();
459 vector from = FreeDebugCamera.GetInstance().GetPosition();
460 vector to = from + ( dir * 10000 );
463 int contact_component;
465 if ( m_SelectedEvent )
466 ev_obj = GetActor( m_SelectedEvent.GetEventActor() );
467 if (
DayZPhysics.
RaycastRV(from, to, contact_pos, contact_dir, contact_component, null, null, ev_obj) )
478 vector from = FreeDebugCamera.GetInstance().GetPosition();
479 vector to = from + ( dir * 10000 );
482 int contact_component;
484 if ( m_SelectedEvent )
485 ev_obj = GetActor( m_SelectedEvent.GetEventActor() );
486 if (
DayZPhysics.
RaycastRV(from, to, contact_pos, contact_dir, contact_component, null, null, ev_obj) )
497 string camPos = MiscGameplayFunctions.TruncateVecToS(FreeDebugCamera.GetInstance().GetPosition(),0);
498 string camOri = MiscGameplayFunctions.TruncateVecToS(FreeDebugCamera.GetInstance().GetOrientation(),0);
499 m_CameraValues.SetText(
"Pos:" +camPos +
" | Rot:" + camOri);
501 #ifdef DIAG_DEVELOPER
506 if (!cam && m_Camera1)
510 Param4<vector, vector,float,float> p4 =
new Param4<vector, vector,float,float>(
GetGame().GetCurrentCameraPosition(),
GetGame().GetCurrentCameraDirection(), cam.GetNearPlane(), cam.GetCurrentFOV());
519 foreach ( CTEvent ev : m_Events )
529 if ( !
Camera.GetCurrentCamera() || !m_Camera1 || !m_Camera2 )
534 if ( m_FollowingBone )
536 PlayerBase p = GetActor( m_FollowingBone.param1 );
539 vector pos = p.GetBonePositionWS( m_FollowingBone.param2 );
541 int bone_index = p.GetBoneIndexByName(
"LeftHand_Dummy");
543 p.GetBoneRotationWS( bone_index, bone_rot );
549 float temp = new_orient[1];
550 new_orient[0] = new_orient[0] + 325;
551 new_orient[1] = new_orient[2] + 245;
552 new_orient[2] = temp + 290;
556 m_Camera1.SetPosition(pos);
557 m_Camera1.SetOrientation(new_orient);
561 if ( m_NextCameraIndex + 1 == m_CameraLines.Count() )
565 foreach ( CTEvent ev2 : m_Events )
572 if (
Camera.GetCurrentCamera().GetPosition() == m_NextCamPosition || ( m_FollowingTimeFinished != -1 &&
m_Time >= m_FollowingTimeFinished ) )
575 if ( GetCameraLine( m_NextCameraIndex - 1 ).param6 > -1 )
578 GetCameraLine( m_NextCameraIndex ).param6 = -1;
580 time = SetCameraData( GetCameraLine( m_NextCameraIndex ), GetCameraLine( m_NextCameraIndex + 1 ) );
584 time = SetCameraData( GetCameraLine( m_NextCameraIndex ), GetCameraLine( m_NextCameraIndex + 1 ) );
588 if ( GetCameraLine( m_NextCameraIndex - 1 ).param6 > -1 )
590 m_FollowingTimeFinished = time +
m_Time;
591 m_NextCamPosition =
"0 0 0";
592 m_Camera1.SetActive(
true );
594 else if ( GetCameraLine( m_NextCameraIndex ) )
596 m_NextCamPosition = GetCameraLine( m_NextCameraIndex ).param1;
597 m_FollowingTimeFinished = -1;
598 m_Camera1.SetActive(
true );
599 m_Camera1.InterpolateTo( m_Camera2, time, m_InterpTypeCombo.GetCurrentItem() );
605 FreeDebugCamera.GetInstance().SetOrientation(
"0 0 0" );
606 foreach( CTEvent ev3 : m_Events )
615 if ( m_Camera1.GetPosition() == m_NextCamPosition )
620 for (
int i = 0; i < ( m_Cameras.Count() - 1 ); i++ )
622 vector pos0 = m_Cameras.Get( i ).GetPosition();
623 vector pos1 = m_Cameras.Get( i + 1 ).GetPosition();
627 if ( m_SelectedActor )
629 if ( !
g_Game.IsLeftCtrlDown() )
630 m_SelectedActor.SetPosition( GetMouseLookDir() );
633 vector from = m_SelectedActor.GetPosition();
634 vector to = GetMouseLookDir();
641 foreach ( CTActor ac : m_Actors )
643 ac.Update( timeslice );
648 float SetCameraData( Param6<vector, vector, float, float, float,int> transform1, Param6<vector, vector, float, float, float, int> transform2 )
650 float int_value = transform1.param3;
651 if ( m_InterpTypeSpeedCombo.GetCurrentItem() == 1 )
653 int_value =
vector.
Distance( transform1.param1, transform2.param1 ) / int_value;
658 if ( transform1.param6 > -1 )
660 p = GetActor( transform1.param6 );
663 b_index = p.GetBoneIndexByName(
"LeftHand_Dummy" );
669 m_Camera1.SetPosition( transform1.param1 );
670 m_Camera1.SetOrientation( transform1.param2 );
671 m_FollowingBone = null;
673 m_Camera1.SetFOV( transform1.param4 *
Math.
DEG2RAD );
674 m_Camera1.SetFocus( transform1.param5, GetBlurValue() );
678 if ( transform2.param6 > -1 )
681 p = GetActor( transform2.param6 );
684 b_index = p.GetBoneIndexByName(
"LeftHand_Dummy" );
687 m_Camera2.SetPosition( p.GetBonePositionWS( b_index ) );
689 p.GetBoneRotationWS( b_index, pQuat);
695 m_Camera2.SetYawPitchRoll( v );
701 m_Camera2.SetPosition( transform2.param1 );
702 m_Camera2.SetOrientation( transform2.param2 );
705 m_Camera2.SetFOV( transform2.param4 *
Math.
DEG2RAD );
706 m_Camera2.SetFocus( transform2.param5, GetBlurValue() );
714 m_BlurEditWidget.SetText( blur.
ToString() );
719 return m_BlurEditWidget.GetText().ToFloat();
742 if ( w == layoutRoot && button ==
MouseState.LEFT )
754 if ( w == m_SaveKeyframe )
759 else if ( w == m_DeleteKeyframe )
764 else if ( w == m_ViewKeyframe )
769 else if ( w == m_SaveEvent )
774 else if ( w == m_DeleteEvent )
779 else if ( w == m_ViewEvent )
784 else if ( w == m_AddKeyframe )
789 else if ( w == m_AddEvent )
794 else if ( w == m_Play )
799 else if ( w == m_Stop )
804 else if ( w == m_Save )
809 else if ( w == m_Load )
814 else if ( w == m_AddActor )
816 AddActor( m_ActorTypeWidget.GetText() );
818 else if ( w == m_AddItem )
820 AddItem( m_ActorIdWidget.GetText(), m_ActorItemTypeWidget.GetText() );
822 else if ( w == m_AddHandsItem )
824 AddHandsItem( m_ActorIdWidget.GetText(), m_ActorItemTypeWidget.GetText() );
828 string clipboardIn = FreeDebugCamera.GetInstance().GetPosition().ToString(
false)+
"|"+ FreeDebugCamera.GetInstance().GetOrientation().ToString(
false);
835 string camText = m_CameraEditbox.GetText();
836 if (camText && camText.
IndexOf(
"|") !=-1)
838 int seperatorIndex = camText.
IndexOf(
"|");
839 int length = camText.
Length();
841 string posStr = camText.
Substring(0,seperatorIndex);
842 string oriStr = camText.
Substring(seperatorIndex+1, length - seperatorIndex - 1);
843 FreeDebugCamera.GetInstance().SetPosition(posStr.
ToVector());
844 FreeDebugCamera.GetInstance().SetOrientation(oriStr.
ToVector());
854 if ( w == m_CameraEditbox)
855 m_CameraEditbox.SetText(
"");
878 ColorWhite( w, null );
888 return ( w == m_SaveKeyframe || w == m_DeleteKeyframe || w == m_ViewKeyframe || w == m_SaveEvent || w == m_DeleteEvent || w == m_ViewEvent || w == m_AddKeyframe || w == m_AddEvent || w == m_Play || w == m_Stop || w == m_Save || w == m_Load || w == m_InterpTypeCombo );
895 if (!w && key ==
KeyCode.KC_P )
925 else if ( !w &&
g_Game.IsLeftCtrlDown() )
937 if ( w.IsInherited( ButtonWidget ) )
939 ButtonWidget button = ButtonWidget.Cast( w );
940 button.SetTextColor(
ARGB( 255, 255, 0, 0 ) );
941 button.SetAlpha( 0.9 );
947 if ( w.IsInherited( ButtonWidget ) )
949 ButtonWidget button = ButtonWidget.Cast( w );
952 button.SetTextColor(
ARGB( 255, 255, 255, 255 ) );
953 button.SetAlpha( 0.75 );
float fixAngle_180_180(float pAngle)
void Stop()
Stops all elements this effect consists of.
protected bool m_IsPlaying
Whether the Effect is currently playing.
protected ButtonWidget m_ApplyButton
protected ButtonWidget m_CopyButton
bool IsFocusable(Widget w)
class JsonUndergroundAreaTriggerData GetPosition
proto native Mission GetMission()
proto native void CopyToClipboard(string text)
proto native Input GetInput()
void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
proto native vector GetPointerDirection()
Returns the direction where the mouse points, from the camera view.
proto native UIManager GetUIManager()
proto native WorkspaceWidget GetWorkspace()
ref array< ref Param5< vector, vector, string, ref array< string >, string > > m_Actors
ref array< ref Param6< vector, vector, float, float, float, int > > m_Cameras
ref array< ref Param4< int, int, float, bool > > m_Events
static proto native FreeDebugCamera GetInstance()
Returns reference to FreeDebugCamera (it's singleton, thus only one instance is present)
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.
static Shape DrawArrow(vector from, vector to, float size=0.5, int color=0xFFFFFFFF, int flags=0)
static void DisableFreeCamera(PlayerBase player, bool teleport_player=false)
static void EnableFreeCameraSceneEditor(PlayerBase player)
void AddActiveInputExcludes(array< string > excludes)
void RemoveActiveInputExcludes(array< string > excludes, bool bForceSupress=false)
deprecated
proto native bool ShowCursor(bool visible)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto string ToString(bool beautify=true)
Vector to string.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
DayZPlayerConstants
defined in C++
proto native CGame GetGame()
static proto native void Text(string label)
proto native bool MakeDirectory(string name)
Makes a directory.
proto bool FileExist(string name)
Check existence of file.
static proto vector QuatToAngles(float q[4])
Returns Angles vector from quaternion.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static const float DEG2RAD
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto vector ToVector()
Returns a vector from a string.
proto native int IndexOf(string sample)
Finds 'sample' in 'str'. Returns -1 when not found.
proto native int Length()
Returns length of string.
int ARGB(int a, int r, int g, int b)