1 #ifndef PLAYER_DEVICE_COMMON_H
2 #define PLAYER_DEVICE_COMMON_H
7 #include "player_interface.h"
11 v3f vl
, vt
, pos
, post
, dir
;
12 struct teleport_gate
*gate
;
16 * this is a little yucky but needs to be done so we can use this 'prediction'
17 * in the pose function. its unfortunate. too bad
19 VG_STATIC
void followcam_nextpos( player_interface
*player
,
20 struct mixedcam_state
*mc
,
26 VG_STATIC
int followcam_will_hit_gate( player_interface
*player
,
27 struct mixedcam_state
*mc
)
32 followcam_nextpos( player
, mc
, next_pos
, d
);
34 return gate_intersect_plane( mc
->gate
, next_pos
, mc
->pos
, _
);
40 VG_STATIC
void mixedcam_transport( struct mixedcam_state
*mc
,
43 m3x3_mulv( gate
->transport
, mc
->vl
, mc
->vl
);
48 player_apply_transport_to_cam( gate
->transport
);
52 VG_STATIC
void mixedcam_reset( player_interface
*player
,
53 struct mixedcam_state
*mc
)
59 VG_STATIC
void mixedcam_set_targets( struct mixedcam_state
*mc
, v3f v
, v3f co
)
62 v3_copy( co
, mc
->post
);
66 VG_STATIC
void mixedcam_iterate_firstperson_frame( player_interface
*player
,
67 struct mixedcam_state
*mc
)
69 v3_lerp( mc
->vl
, mc
->vt
, 4.0f
*vg
.time_delta
, mc
->vl
);
72 VG_STATIC
void mixedcam_iterate_thirdperson_frame( player_interface
*player
,
73 struct mixedcam_state
*mc
)
75 v3f prev_pos
, origin
, target
, dir
;
77 v3_copy( mc
->pos
, prev_pos
);
82 m4x3_invert_affine( mc
->gate
->transport
, inverse
);
83 m4x3_mulv( inverse
, mc
->post
, origin
);
87 v3_copy( mc
->post
, origin
);
91 v3_add( origin
, (v3f
){0.0f
,1.35f
,0.0f
}, origin
);
92 v3_sub( origin
, mc
->pos
, dir
);
94 if( v3_length2( dir
) < 0.1f
*0.1f
)
95 v3_copy( (v3f
){ 0.0f
, 0.0f
, 1.0f
}, dir
); /* FIXME */
99 v3_muladds( origin
, dir
, -2.0f
, target
);
100 v3_lerp( mc
->pos
, target
, vg
.frame_delta
* 12.0f
, mc
->pos
);
101 v3_copy( dir
, mc
->dir
);
106 if( gate_intersect_plane( mc
->gate
, mc
->pos
, prev_pos
, _
) )
108 m4x3_mulv( mc
->gate
->transport
, mc
->pos
, mc
->pos
);
109 m3x3_mulv( mc
->gate
->transport
, mc
->dir
, mc
->dir
);
110 //player_apply_transport_to_cam( mc->gate->transport );
117 VG_STATIC
void mixedcam_iterate_frame( player_interface
*player
,
118 struct mixedcam_state
*mc
)
121 mixedcam_iterate_thirdperson_frame( player
, mc
);
123 mixedcam_iterate_firstperson_frame( player
, mc
);
126 VG_STATIC
void mixedcam_get_camera( struct mixedcam_state
*mc
)
131 #endif /* PLAYER_DEVICE_COMMON_H */