VG_STATIC void gate_transform_update( teleport_gate *gate )
{
- m4x3f to_local;
+ m4x3f to_local, recv_to_world;
q_m3x3( gate->q[0], gate->to_world );
v3_copy( gate->co[0], gate->to_world[3] );
m4x3_invert_affine( gate->to_world, to_local );
- q_m3x3( gate->q[1], gate->recv_to_world );
- v3_copy( gate->co[1], gate->recv_to_world[3] );
- m4x3_mul( gate->recv_to_world, to_local, gate->transport );
+ q_m3x3( gate->q[1], recv_to_world );
+ v3_copy( gate->co[1], recv_to_world[3] );
+ m4x3_mul( recv_to_world, to_local, gate->transport );
+
+ m4x3_scalev( gate->to_world, (v3f){ gate->dims[0], gate->dims[1], 1.0f } );
}
VG_STATIC void world_gates_init(void)
{
v3f viewdir, gatedir;
m3x3_mulv( cam->transform, (v3f){0.0f,0.0f,-1.0f}, viewdir );
- m3x3_mulv( gate->to_world, (v3f){0.0f,0.0f,-1.0f}, gatedir );
+ q_mulv( gate->q[0], (v3f){0.0f,0.0f,-1.0f}, gatedir );
v3f v0;
v3_sub( cam->pos, gate->co[0], v0 );
{
v3f a,b,c,d;
- float sx = gate->dims[0],
- sy = gate->dims[1];
- m4x3_mulv( gate->to_world, (v3f){-sx,-sy,0.0f}, a );
- m4x3_mulv( gate->to_world, (v3f){ sx,-sy,0.0f}, b );
- m4x3_mulv( gate->to_world, (v3f){ sx, sy,0.0f}, c );
- m4x3_mulv( gate->to_world, (v3f){-sx, sy,0.0f}, d );
+ m4x3_mulv( gate->to_world, (v3f){-1.0f,-1.0f,0.0f}, a );
+ m4x3_mulv( gate->to_world, (v3f){ 1.0f,-1.0f,0.0f}, b );
+ m4x3_mulv( gate->to_world, (v3f){ 1.0f, 1.0f,0.0f}, c );
+ m4x3_mulv( gate->to_world, (v3f){-1.0f, 1.0f,0.0f}, d );
vg_line( a,b, 0xffffa000 );
vg_line( b,c, 0xffffa000 );
/* Add special clipping plane to projection */
v4f surface;
- m3x3_mulv( gate->recv_to_world, (v3f){0.0f,0.0f,-1.0f}, surface );
+ q_mulv( gate->q[1], (v3f){0.0f,0.0f,-1.0f}, surface );
surface[3] = v3_dot( surface, gate->co[1] );
m4x3_mulp( gate_camera.transform_inverse, surface, surface );
vg_line_pt3( gate_camera.transform[3], 0.3f, 0xff00ff00 );
{
- m4x3f gate_xform;
- m4x3_copy( gate->to_world, gate_xform );
- m4x3_scalev( gate_xform, (v3f){ gate->dims[0], gate->dims[1], 1.0f } );
-
shader_model_gate_use();
shader_model_gate_uPv( cam->mtx.pv );
- shader_model_gate_uMdl( gate_xform );
+ shader_model_gate_uMdl( gate->to_world );
shader_model_gate_uCam( cam->pos );
shader_model_gate_uTime( vg.time*0.25f );
shader_model_gate_uInvRes( (v2f){
v2f where )
{
v4f surface;
- m3x3_mulv( gate->to_world, (v3f){0.0f,0.0f,-1.0f}, surface );
+ q_mulv( gate->q[0], (v3f){0.0f,0.0f,-1.0f}, surface );
surface[3] = v3_dot( surface, gate->co[0] );
v3f v0, c, delta, p0;
v3_muladds( last, v0, t, local );
v3_sub( gate->co[0], local, rel );
- v3f vup, vside;
- m3x3_mulv( gate->to_world, (v3f){0.0f,1.0f,0.0f}, vup );
- m3x3_mulv( gate->to_world, (v3f){1.0f,0.0f,0.0f}, vside );
+ where[0] = v3_dot( rel, gate->to_world[0] );
+ where[1] = v3_dot( rel, gate->to_world[1] );
- where[0] = v3_dot( rel, vside );
- where[1] = v3_dot( rel, vup );
+ where[0] /= v3_dot( gate->to_world[0], gate->to_world[0] );
+ where[1] /= v3_dot( gate->to_world[1], gate->to_world[1] );
return 1;
}
if( gate_intersect_plane( gate, pos, last, xy ) )
{
- if( fabsf(xy[0]) <= gate->dims[0] && fabsf(xy[1]) <= gate->dims[1] )
+ vg_info( "%f %f\n", xy[0], xy[1] );
+ if( fabsf(xy[0]) <= 1.0f && fabsf(xy[1]) <= 1.0f )
{
return 1;
}