DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CameraToolsMenu.c
Go to the documentation of this file.
1class CameraToolsMenu extends UIScriptedMenu
2{
3 protected static CameraToolsMenu m_Instance;
4 vector m_FreeflightCamTransform[4];
6
7 protected float m_Time;
8
9 protected Camera m_Camera1;
10 protected Camera m_Camera2;
11
13 protected bool m_IsPlaying;
14 protected int m_NextCameraIndex = 1;
15
16 protected float m_FollowingTimeFinished;
18
19 protected CTKeyframe m_SelectedKeyframe;
20 protected CTEvent m_SelectedEvent;
21 protected CTActor m_SelectedActor;
22
26
29
30 protected XComboBoxWidget m_InterpTypeSpeedCombo;
31 protected XComboBoxWidget m_InterpTypeCombo;
32 protected EditBoxWidget m_BlurEditWidget;
33 protected EditBoxWidget m_ActorTypeWidget;
34
35 protected EditBoxWidget m_ActorIdWidget;
36 protected EditBoxWidget m_ActorItemTypeWidget;
37
38 protected ButtonWidget m_AddItem;
39 protected ButtonWidget m_AddHandsItem;
40 protected ButtonWidget m_AddActor;
41 protected ButtonWidget m_Play;
42 protected ButtonWidget m_Stop;
43 protected ButtonWidget m_Save;
44 protected ButtonWidget m_Load;
45
46 protected ButtonWidget m_AddKeyframe;
47 protected ButtonWidget m_SaveKeyframe;
48 protected ButtonWidget m_DeleteKeyframe;
49 protected ButtonWidget m_ViewKeyframe;
50
51 protected ButtonWidget m_AddEvent;
52 protected ButtonWidget m_SaveEvent;
53 protected ButtonWidget m_DeleteEvent;
54 protected ButtonWidget m_ViewEvent;
55
56 protected ButtonWidget m_CopyButton;
57 protected ButtonWidget m_ApplyButton;
58 protected EditBoxWidget m_CameraEditbox;
60
62 {
63 m_Cameras = new array<ref CTKeyframe>;
64 m_Events = new array<ref CTEvent>;
65 m_Actors = new array<ref CTActor>;
66
67 m_Camera1 = Camera.Cast( GetGame().CreateObject( "staticcamera", GetGame().GetPlayer().GetPosition(), true ) );
68 m_Camera2 = Camera.Cast( GetGame().CreateObject( "staticcamera", GetGame().GetPlayer().GetPosition(), true ) );
69
70 m_Instance = this;
71 }
72
74 {
75 m_Camera1.SetActive( false );
76 m_Camera2.SetActive( false );
77
78 //GetGame().ObjectDelete( m_Camera1 );
79 //GetGame().ObjectDelete( m_Camera2 );
80
82
83 MissionGameplay ms = MissionGameplay.Cast( GetGame().GetMission() );
84 if (ms)
85 ms.GetHud().Show( true );
86 }
87
88 override void OnShow()
89 {
90 super.OnShow();
91 if ( !m_IsPlaying )
92 {
94 }
95 }
96
97 override void OnHide()
98 {
99 super.OnHide();
100 if ( !m_IsPlaying && GetGame() && GetGame().GetMission() && GetGame().GetUIManager())
101 {
104 }
105 }
106
107 void SelectKeyframe( CTKeyframe kf )
108 {
109 if ( m_SelectedKeyframe )
110 m_SelectedKeyframe.Unselect();
111
112 m_SelectedKeyframe = kf;
113 m_SelectedKeyframe.Select();
114 }
115
116 void SelectEvent( CTEvent ev )
117 {
118 m_SelectedEvent = ev;
119 }
120
121 void SelectActor( CTActor ac )
122 {
123 m_SelectedActor = ac;
124 }
125
126 override Widget Init()
127 {
128 layoutRoot = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/camera_tools/camera_tools.layout" );
129
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" ) );
138
139 m_AddKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "add_keyframe" ) );
140 m_AddEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "add_event" ) );
141
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" ) );
149
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" ) );
156
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" ) );
161
162 MissionGameplay ms = MissionGameplay.Cast( GetGame().GetMission() );
163 ms.GetHud().Show( false );
165
166 m_BlurEditWidget.SetText( "0.0" );
167 return layoutRoot;
168 }
169
170 PlayerBase GetActor( int index )
171 {
172 if ( index > -1 && index < m_Actors.Count() )
173 return PlayerBase.Cast( m_Actors.Get( index ).GetObj() );
174 else
175 return null;
176 }
177
178 static void PlayAnimOnActor( int actor, int anim )
179 {
180 if ( m_Instance )
181 {
182 PlayerBase p = m_Instance.GetActor( actor );
183 if ( p )
184 {
185 EmoteCB cb = EmoteCB.Cast( p.StartCommand_Action( anim, EmoteCB, DayZPlayerConstants.STANCEMASK_ALL ) );
186 cb.EnableCancelCondition(true);
187 }
188 }
189 }
190
191 void LoadData()
192 {
193 if ( !FileExist( g_Game.GetMissionFolderPath() + "/CameraTools" ) )
194 MakeDirectory( g_Game.GetMissionFolderPath() + "/CameraTools" );
195
196 m_Cameras.Clear();
197 m_Events.Clear();
198 m_Actors.Clear();
199
200 CTSaveStructure save_data = new CTSaveStructure();
201 JsonFileLoader<ref CTSaveStructure>.JsonLoadFile( g_Game.GetMissionFolderPath() + "/CameraTools/keyframe_data.json", save_data );
202
203 m_InterpTypeCombo.SetCurrentItem( save_data.m_InterpType );
204 m_InterpTypeSpeedCombo.SetCurrentItem( save_data.m_InterpSpeed );
205 SetBlurValue( save_data.m_BlurValue );
206
207 foreach ( Param6<vector, vector, float, float, float, int> transform : save_data.m_Cameras )
208 {
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 );
212 }
213
214 foreach ( Param4<int, int, float, bool> event_t : save_data.m_Events )
215 {
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 );
220 }
221
222 foreach( Param5<vector, vector, string, ref array<string>, string> actor_t : save_data.m_Actors )
223 {
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 );
226 }
227 }
228
229 void SaveData()
230 {
231 if ( !FileExist( g_Game.GetMissionFolderPath() + "/CameraTools" ) )
232 MakeDirectory( g_Game.GetMissionFolderPath() + "/CameraTools" );
233
234 CTSaveStructure save_data = new CTSaveStructure();
235 save_data.m_InterpType = m_InterpTypeCombo.GetCurrentItem();
236 save_data.m_InterpSpeed = m_InterpTypeSpeedCombo.GetCurrentItem();
237 save_data.m_BlurValue = GetBlurValue();
238
239 foreach ( CTKeyframe keyframe : m_Cameras )
240 {
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() );
242 save_data.m_Cameras.Insert( transform );
243 }
244
245 foreach ( CTEvent event_t : m_Events )
246 {
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() );
248 save_data.m_Events.Insert( ev );
249 }
250
251 foreach ( CTActor actor_t : m_Actors )
252 {
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() );
254 save_data.m_Actors.Insert( ac );
255 }
256
257 JsonFileLoader<ref CTSaveStructure>.JsonSaveFile( g_Game.GetMissionFolderPath() + "/CameraTools/keyframe_data.json", save_data );
258 }
259
260 float GetTotalTime( int index )
261 {
262 float time;
263 index = Math.Clamp( index, 0, m_Cameras.Count() );
264 for ( int i = 0; i < index; i++ )
265 {
266 time += m_Cameras.Get( i ).GetInterpTime();
267 }
268 return time;
269 }
270
272 {
273 if ( Camera.GetCurrentCamera() )
274 {
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 );
280 }
281 }
282
284 {
285 if ( m_SelectedKeyframe && Camera.GetCurrentCamera() )
286 {
287 m_SelectedKeyframe.SetPosition( Camera.GetCurrentCamera().GetWorldPosition() );
288 m_SelectedKeyframe.SetOrientation( Camera.GetCurrentCamera().GetOrientation() );
289 }
290 }
291
293 {
294 if ( m_SelectedKeyframe )
295 {
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 )
300 {
301 SelectKeyframe( m_Cameras.Get( index ) );
302 }
303 }
304 }
305
307 {
308 if ( m_SelectedKeyframe && Camera.GetCurrentCamera() )
309 {
310 Camera.GetCurrentCamera().SetPosition( m_SelectedKeyframe.GetPosition() );
311 Camera.GetCurrentCamera().SetOrientation( m_SelectedKeyframe.GetOrientation() );
312 }
313 }
314
315 void AddActor( string actor_type )
316 {
317 vector pos = GetCameraLookDir();
318 CTActor ac = new CTActor( m_Actors.Count(), pos, "0 0 0", actor_type, new array<string>, "", this );
319 if ( ac.GetObj() )
320 m_Actors.Insert( ac );
321 }
322
323 void AddEvent( int actor_index )
324 {
325 if ( actor_index > -1 )
326 {
327 CTEvent ev = new CTEvent( m_Events.Count(), actor_index, m_EventContent, false, this );
328 m_Events.Insert( ev );
329 }
330 }
331
332
333 void AddItem( string id, string type )
334 {
335 int id_int = id.ToInt();
336 if ( m_Actors.Count() > id_int && id_int > -1 )
337 {
338 CTActor ac = m_Actors.Get( id_int );
339 if ( ac )
340 ac.AddItem( type );
341 }
342 }
343
344 void AddHandsItem( string id, string type )
345 {
346 int id_int = id.ToInt();
347 if ( m_Actors.Count() > id_int && id_int > -1 )
348 {
349 CTActor ac = m_Actors.Get( id_int );
350 if ( ac )
351 ac.SetHandsItem( type );
352 }
353 }
354
356 {
357
358 }
359
361 {
362
363 }
364
366 {
367
368 }
369
370 Param6<vector, vector, float, float, float, int> GetCameraLine( int index )
371 {
372 if ( index > -1 && index < m_CameraLines.Count() )
373 {
374 return m_CameraLines[index];
375 }
376 return null;
377 }
378
379 void Play()
380 {
381 if (Camera.GetCurrentCamera())
382 Camera.GetCurrentCamera().GetTransform(m_FreeflightCamTransform);
383 if ( m_Cameras.Count() > 0 )
384 {
385 layoutRoot.Show( false );
386 GetGame().GetUIManager().ShowCursor( false );
388
389 foreach ( CTKeyframe keyframe : m_Cameras )
390 {
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 );
393
394 }
395
396 foreach ( CTActor ac : m_Actors )
397 {
398 ac.Hide();
399 }
400
401 foreach ( CTEvent ev : m_Events )
402 {
403 ev.GetEventTime();
404 }
405
407
408 int time = SetCameraData( GetCameraLine( 0 ), GetCameraLine( 1 ) );
409
410 if ( GetCameraLine( 0 ).param6 > -1 )
411 {
412 m_FollowingTimeFinished = time;
413 m_NextCamPosition = "0 0 0";
414 m_Camera1.SetActive( true );
415 }
416 else
417 {
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() );
422 }
423
424 m_NextCameraIndex = 1;
425 m_IsPlaying = true;
426 m_Time = 0;
427 }
428 }
429
430 void Stop()
431 {
432 layoutRoot.Show( true );
433 GetGame().GetUIManager().ShowCursor( true );
434
435 m_Camera1.SetActive( false );
436 m_Camera2.SetActive( false );
437 FreeDebugCamera.GetInstance().SetActive(true);
438
439 m_NextCameraIndex = 1;
440 m_IsPlaying = false;
441
442 foreach ( CTEvent ev : m_Events )
443 {
444 ev.Stop();
445 }
446
447 foreach ( CTActor ac : m_Actors )
448 {
449 ac.Reset();
450 ac.Show();
451 }
452
453 Camera.GetCurrentCamera().SetTransform(m_FreeflightCamTransform);
454 }
455
457 {
458 vector dir = FreeDebugCamera.GetInstance().GetDirection();
459 vector from = FreeDebugCamera.GetInstance().GetPosition();
460 vector to = from + ( dir * 10000 );
461 vector contact_pos;
462 vector contact_dir;
463 int contact_component;
464 Object ev_obj;
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) )
468 {
469 return contact_pos;
470 }
471
472 return "0 0 0";
473 }
474
476 {
478 vector from = FreeDebugCamera.GetInstance().GetPosition();
479 vector to = from + ( dir * 10000 );
480 vector contact_pos;
481 vector contact_dir;
482 int contact_component;
483 Object ev_obj;
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) )
487 {
488 return contact_pos;
489 }
490
491 return "0 0 0";
492 }
493
494 override void Update( float timeslice )
495 {
496
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);
500
501 #ifdef DIAG_DEVELOPER
502 if (DiagMenu.GetBool(DiagMenuIDs.CAMERATOOLS_ENABLE_REMOTE_CAMERA_BROADCAST))
503 {
504 Camera cam = Camera.GetCurrentCamera();
505
506 if (!cam && m_Camera1)
507 cam = m_Camera1;
508 if (cam)
509 {
510 Param4<vector, vector,float,float> p4 = new Param4<vector, vector,float,float>(GetGame().GetCurrentCameraPosition(),GetGame().GetCurrentCameraDirection(), cam.GetNearPlane(), cam.GetCurrentFOV());
511 GetGame().RPCSingleParam(null, ERPCs.DIAG_CAMERATOOLS_CAM_DATA, p4, false);
512 }
513
514 }
515 #endif
516
517 if ( m_CameraLines && m_IsPlaying )
518 {
519 foreach ( CTEvent ev : m_Events )
520 {
521 if ( ev.IsTime( m_Time, m_Time + timeslice ) )
522 {
523 ev.Play();
524 }
525 }
526
527 m_Time += timeslice;
528
529 if ( !Camera.GetCurrentCamera() || !m_Camera1 || !m_Camera2 )
530 {
531 return;
532 }
533
534 if ( m_FollowingBone )
535 {
536 PlayerBase p = GetActor( m_FollowingBone.param1 );
537 if ( p )
538 {
539 vector pos = p.GetBonePositionWS( m_FollowingBone.param2 );
540
541 int bone_index = p.GetBoneIndexByName("LeftHand_Dummy");
542 float bone_rot[4];
543 p.GetBoneRotationWS( bone_index, bone_rot );
544
545 vector new_orient = Math3D.QuatToAngles(bone_rot);
546
547 //Print("Rot: "+ new_orient[0] +", "+ new_orient[1] +", "+ new_orient[2]);
548
549 float temp = new_orient[1];
550 new_orient[0] = new_orient[0] + 325; // vertical
551 new_orient[1] = new_orient[2] + 245;// horizontal
552 new_orient[2] = temp + 290; // tilt
553
554 //Print("PostRot: "+ new_orient[0] +", "+ new_orient[1] +", "+ new_orient[2]);
555
556 m_Camera1.SetPosition(pos);
557 m_Camera1.SetOrientation(new_orient);
558 }
559 }
560
561 if ( m_NextCameraIndex + 1 == m_CameraLines.Count() )
562 {
563 Stop();
565 foreach ( CTEvent ev2 : m_Events )
566 {
567 ev2.Stop();
568 }
569 return;
570 }
571
572 if ( Camera.GetCurrentCamera().GetPosition() == m_NextCamPosition || ( m_FollowingTimeFinished != -1 && m_Time >= m_FollowingTimeFinished ) )
573 {
574 int time;
575 if ( GetCameraLine( m_NextCameraIndex - 1 ).param6 > -1 )
576 {
577 m_NextCameraIndex--;
578 GetCameraLine( m_NextCameraIndex ).param6 = -1;
579
580 time = SetCameraData( GetCameraLine( m_NextCameraIndex ), GetCameraLine( m_NextCameraIndex + 1 ) );
581 }
582 else
583 {
584 time = SetCameraData( GetCameraLine( m_NextCameraIndex ), GetCameraLine( m_NextCameraIndex + 1 ) );
585 }
586
587 m_NextCameraIndex++;
588 if ( GetCameraLine( m_NextCameraIndex - 1 ).param6 > -1 )
589 {
590 m_FollowingTimeFinished = time + m_Time;
591 m_NextCamPosition = "0 0 0";
592 m_Camera1.SetActive( true );
593 }
594 else if ( GetCameraLine( m_NextCameraIndex ) )
595 {
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() );
600 }
601 else
602 {
603 Stop();
605 FreeDebugCamera.GetInstance().SetOrientation( "0 0 0" );
606 foreach( CTEvent ev3 : m_Events )
607 {
608 ev3.Stop();
609 }
610 }
611 }
612 }
613 else
614 {
615 if ( m_Camera1.GetPosition() == m_NextCamPosition )
616 {
618 }
619
620 for ( int i = 0; i < ( m_Cameras.Count() - 1 ); i++ )
621 {
622 vector pos0 = m_Cameras.Get( i ).GetPosition();
623 vector pos1 = m_Cameras.Get( i + 1 ).GetPosition();
624 Debug.DrawArrow( pos0, pos1, 2, COLOR_RED, ShapeFlags.ONCE );
625 }
626
627 if ( m_SelectedActor )
628 {
629 if ( !g_Game.IsLeftCtrlDown() )
630 m_SelectedActor.SetPosition( GetMouseLookDir() );
631 else
632 {
633 vector from = m_SelectedActor.GetPosition();
634 vector to = GetMouseLookDir();
635 Debug.DrawArrow( from, to, 0.5, COLOR_RED, ShapeFlags.ONCE );
636 m_SelectedActor.SetRotation( vector.Direction( from,to ).Normalized().VectorToAngles() );
637 }
638
639 }
640
641 foreach ( CTActor ac : m_Actors )
642 {
643 ac.Update( timeslice );
644 }
645 }
646 }
647
648 float SetCameraData( Param6<vector, vector, float, float, float,int> transform1, Param6<vector, vector, float, float, float, int> transform2 )
649 {
650 float int_value = transform1.param3;
651 if ( m_InterpTypeSpeedCombo.GetCurrentItem() == 1 )
652 {
653 int_value = vector.Distance( transform1.param1, transform2.param1 ) / int_value;
654 }
655 PlayerBase p;
656 float pQuat[4];
657 int b_index;
658 if ( transform1.param6 > -1 )
659 {
660 p = GetActor( transform1.param6 );
661 if ( p )
662 {
663 b_index = p.GetBoneIndexByName( "LeftHand_Dummy" );
664 m_FollowingBone = new Param2<int, int>(transform1.param6, b_index);
665 }
666 }
667 else
668 {
669 m_Camera1.SetPosition( transform1.param1 );
670 m_Camera1.SetOrientation( transform1.param2 );
671 m_FollowingBone = null;
672 }
673 m_Camera1.SetFOV( transform1.param4 * Math.DEG2RAD );
674 m_Camera1.SetFocus( transform1.param5, GetBlurValue() );
675
676 if ( transform2 )
677 {
678 if ( transform2.param6 > -1 )
679 {
680 pQuat[4];
681 p = GetActor( transform2.param6 );
682 if ( p )
683 {
684 b_index = p.GetBoneIndexByName( "LeftHand_Dummy" );
685 if ( b_index != -1 )
686 {
687 m_Camera2.SetPosition( p.GetBonePositionWS( b_index ) );
688
689 p.GetBoneRotationWS( b_index, pQuat);
690 vector v = Math3D.QuatToAngles( pQuat );
691 v[0] = fixAngle_180_180( v[0] - 180 );
692 v[1] = fixAngle_180_180( v[1] - 270 );
693 v[2] = fixAngle_180_180( v[2] + 90 );
694 DbgUI.Text( v.ToString() );
695 m_Camera2.SetYawPitchRoll( v );
696 }
697 }
698 }
699 else
700 {
701 m_Camera2.SetPosition( transform2.param1 );
702 m_Camera2.SetOrientation( transform2.param2 );
703 }
704
705 m_Camera2.SetFOV( transform2.param4 * Math.DEG2RAD );
706 m_Camera2.SetFocus( transform2.param5, GetBlurValue() );
707 }
708
709 return int_value;
710 }
711
712 void SetBlurValue( float blur )
713 {
714 m_BlurEditWidget.SetText( blur.ToString() );
715 }
716
718 {
719 return m_BlurEditWidget.GetText().ToFloat();
720 }
721
722 override bool OnMouseButtonDown( Widget w, int x, int y, int button )
723 {
724 if ( w == layoutRoot && button == MouseState.RIGHT && !m_IsPlaying )
725 {
730 SetFocus( layoutRoot );
731 return true;
732 }
733 else if ( !IsFocusable( w ) )
734 {
735 SetFocus( layoutRoot );
736 }
737 return false;
738 }
739
740 override bool OnMouseButtonUp( Widget w, int x, int y, int button )
741 {
742 if ( w == layoutRoot && button == MouseState.LEFT )
743 {
744 SelectActor( null );
745 return true;
746 }
747 return false;
748 }
749
750 override bool OnClick( Widget w, int x, int y, int button )
751 {
752 if ( button == MouseState.LEFT )
753 {
754 if ( w == m_SaveKeyframe )
755 {
756 SaveKeyframe();
757 return true;
758 }
759 else if ( w == m_DeleteKeyframe )
760 {
761 DeleteKeyframe();
762 return true;
763 }
764 else if ( w == m_ViewKeyframe )
765 {
766 ViewKeyframe();
767 return true;
768 }
769 else if ( w == m_SaveEvent )
770 {
771 SaveEvent();
772 return true;
773 }
774 else if ( w == m_DeleteEvent )
775 {
776 DeleteEvent();
777 return true;
778 }
779 else if ( w == m_ViewEvent )
780 {
781 ViewEvent();
782 return true;
783 }
784 else if ( w == m_AddKeyframe )
785 {
786 AddKeyframe();
787 return true;
788 }
789 else if ( w == m_AddEvent )
790 {
791 AddEvent( 0 );
792 return true;
793 }
794 else if ( w == m_Play )
795 {
796 Play();
797 return true;
798 }
799 else if ( w == m_Stop )
800 {
801 Stop();
802 return true;
803 }
804 else if ( w == m_Save )
805 {
806 SaveData();
807 return true;
808 }
809 else if ( w == m_Load )
810 {
811 LoadData();
812 return true;
813 }
814 else if ( w == m_AddActor )
815 {
816 AddActor( m_ActorTypeWidget.GetText() );
817 }
818 else if ( w == m_AddItem )
819 {
820 AddItem( m_ActorIdWidget.GetText(), m_ActorItemTypeWidget.GetText() );
821 }
822 else if ( w == m_AddHandsItem )
823 {
824 AddHandsItem( m_ActorIdWidget.GetText(), m_ActorItemTypeWidget.GetText() );
825 }
826 else if ( w == m_CopyButton )
827 {
828 string clipboardIn = FreeDebugCamera.GetInstance().GetPosition().ToString(false)+"|"+ FreeDebugCamera.GetInstance().GetOrientation().ToString(false);
829 GetGame().CopyToClipboard( clipboardIn );
830
831 //Print(clipboardIn);
832 }
833 else if ( w == m_ApplyButton )
834 {
835 string camText = m_CameraEditbox.GetText();
836 if (camText && camText.IndexOf("|") !=-1)
837 {
838 int seperatorIndex = camText.IndexOf("|");
839 int length = camText.Length();
840
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());
845 }
846 }
847 }
848 return false;
849 }
850
851
852 override bool OnMouseEnter( Widget w, int x, int y )
853 {
854 if ( w == m_CameraEditbox)
855 m_CameraEditbox.SetText("");
856 return true;
857 }
858
859 override bool OnMouseLeave( Widget w, Widget enterW, int x, int y )
860 {
861 return true;
862 }
863
864 override bool OnFocus( Widget w, int x, int y )
865 {
866 if ( IsFocusable( w ) )
867 {
868 ColorRed( w );
869 return true;
870 }
871 return false;
872 }
873
874 override bool OnFocusLost( Widget w, int x, int y )
875 {
876 if ( IsFocusable( w ) )
877 {
878 ColorWhite( w, null );
879 return true;
880 }
881 return false;
882 }
883
885 {
886 if ( w )
887 {
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 );
889 }
890 return false;
891 }
892
893 override bool OnKeyPress(Widget w, int x, int y, int key)
894 {
895 if (!w && key == KeyCode.KC_P )
896 {
897 if ( !m_IsPlaying )
898 {
899 Play();
900 return true;
901 }
902 else
903 {
904 Stop();
905 return true;
906 }
907 return false;
908 }
909 else if ( g_Game.IsLeftCtrlDown() && key == KeyCode.KC_S )
910 {
911 SaveKeyframe();
912 return true;
913 }
914 else if ( g_Game.IsLeftCtrlDown() && key == KeyCode.KC_Q )
915 {
916 AddKeyframe();
917 return true;
918 }
919 else if ( g_Game.IsLeftCtrlDown() && key == KeyCode.KC_E )
920 {
921 DeleteKeyframe();
922 return true;
923 }
924
925 else if ( !w && g_Game.IsLeftCtrlDown() )
926 {
927 SelectActor( null );
928 return true;
929 }
930 return false;
931 }
932
933 //Coloring functions (Until WidgetStyles are useful)
934 void ColorRed( Widget w )
935 {
936 //SetFocus( w );
937 if ( w.IsInherited( ButtonWidget ) )
938 {
939 ButtonWidget button = ButtonWidget.Cast( w );
940 button.SetTextColor( ARGB( 255, 255, 0, 0 ) );
941 button.SetAlpha( 0.9 );
942 }
943 }
944
945 void ColorWhite( Widget w, Widget enterW )
946 {
947 if ( w.IsInherited( ButtonWidget ) )
948 {
949 ButtonWidget button = ButtonWidget.Cast( w );
950 if (button)
951 {
952 button.SetTextColor( ARGB( 255, 255, 255, 255 ) );
953 button.SetAlpha( 0.75 );
954 }
955 }
956 }
957}
DayZGame g_Game
Definition DayZGame.c:3654
float fixAngle_180_180(float pAngle)
DiagMenuIDs
Definition EDiagMenuIDs.c:2
ERPCs
Definition ERPCs.c:2
void Stop()
Stops all elements this effect consists of.
Definition Effect.c:179
protected bool m_IsPlaying
Whether the Effect is currently playing.
Definition Effect.c:37
Icon x
Icon y
PlayerBase GetPlayer()
static ref RadialMenu m_Instance
Definition RadialMenu.c:55
protected ButtonWidget m_ApplyButton
protected ButtonWidget m_CopyButton
bool IsFocusable(Widget w)
protected EAnimPlayState Play()
protected float m_Time
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
Definition Game.c:882
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.
Definition DbgUI.c:60
Definition Debug.c:14
static Shape DrawArrow(vector from, vector to, float size=0.5, int color=0xFFFFFFFF, int flags=0)
Definition Debug.c:383
static void DisableFreeCamera(PlayerBase player, bool teleport_player=false)
static void EnableFreeCameraSceneEditor(PlayerBase player)
proto native void ChangeGameFocus(int add, int input_device=-1)
Change game focus number.
proto native void ResetGameFocus(int input_device=-1)
Reset game focus number (set to 0)
Definition EnMath.c:7
void AddActiveInputExcludes(array< string > excludes)
void RemoveActiveInputExcludes(array< string > excludes, bool bForceSupress=false)
deprecated
proto native bool ShowCursor(bool visible)
protected ButtonWidget m_ApplyButton
void SetBlurValue(float blur)
protected ButtonWidget m_Stop
protected vector m_NextCamPosition
protected ref array< ref CTKeyframe > m_Cameras
protected ref array< ref CTActor > m_Actors
vector GetMouseLookDir()
protected ButtonWidget m_ViewKeyframe
protected CTActor m_SelectedActor
void SelectKeyframe(CTKeyframe kf)
void ColorRed(Widget w)
protected EditBoxWidget m_ActorIdWidget
protected ButtonWidget m_AddKeyframe
override void Update(float timeslice)
protected XComboBoxWidget m_InterpTypeSpeedCombo
protected float m_Time
void SelectEvent(CTEvent ev)
protected TextWidget m_CameraValues
vector GetCameraLookDir()
PlayerBase GetActor(int index)
protected ButtonWidget m_SaveKeyframe
void AddEvent(int actor_index)
static void PlayAnimOnActor(int actor, int anim)
override void OnShow()
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
protected float m_FollowingTimeFinished
protected ButtonWidget m_DeleteKeyframe
protected ButtonWidget m_DeleteEvent
float GetTotalTime(int index)
protected Camera m_Camera2
protected ref Param2< int, int > m_FollowingBone
void AddHandsItem(string id, string type)
protected bool m_IsPlaying
protected ButtonWidget m_ViewEvent
protected ButtonWidget m_AddItem
override bool OnKeyPress(Widget w, int x, int y, int key)
protected Camera m_Camera1
protected EditBoxWidget m_ActorTypeWidget
void SelectActor(CTActor ac)
protected ButtonWidget m_SaveEvent
void AddItem(string id, string type)
protected Widget m_KeyframeContent
protected ref array< ref Param6< vector, vector, float, float, float, int > > m_CameraLines
void ColorWhite(Widget w, Widget enterW)
protected EditBoxWidget m_CameraEditbox
protected CTKeyframe m_SelectedKeyframe
Param6< vector, vector, float, float, float, int > GetCameraLine(int index)
override void OnHide()
protected ButtonWidget m_Load
protected Widget m_EventContent
protected ButtonWidget m_AddHandsItem
protected XComboBoxWidget m_InterpTypeCombo
protected ButtonWidget m_CopyButton
override Widget Init()
float SetCameraData(Param6< vector, vector, float, float, float, int > transform1, Param6< vector, vector, float, float, float, int > transform2)
protected ref array< ref CTEvent > m_Events
override bool OnFocusLost(Widget w, int x, int y)
bool IsFocusable(Widget w)
protected EditBoxWidget m_BlurEditWidget
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
static protected CameraToolsMenu m_Instance
protected CTEvent m_SelectedEvent
protected ButtonWidget m_Play
override bool OnFocus(Widget w, int x, int y)
protected EditBoxWidget m_ActorItemTypeWidget
protected ButtonWidget m_AddEvent
override bool OnClick(Widget w, int x, int y, int button)
void AddActor(string actor_type)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
protected ButtonWidget m_AddActor
protected ButtonWidget m_Save
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString()
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.
Definition EnConvert.c:220
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
const int COLOR_RED
Definition constants.c:64
ShapeFlags
Definition EnDebug.c:126
static proto native void Text(string label)
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
proto native bool MakeDirectory(string name)
Makes a directory.
proto bool FileExist(string name)
Check existence of file.
KeyCode
Definition EnSystem.c:157
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
Definition EnMath.c:17
MouseState
Definition EnSystem.c:311
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.
proto native void SetFocus(Widget w)
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
int ARGB(int a, int r, int g, int b)
Definition proto.c:322