('ent_relay', 'Relay', '', 20 )
]
-MDL_VERSION_NR = 102
+MDL_VERSION_NR = 103
SR_TRIGGERABLE = [ 'ent_audio', 'ent_ccmd', 'ent_gate', 'ent_challenge', \
- 'ent_relay', 'ent_skateshop', 'ent_objective' ]
+ 'ent_relay', 'ent_skateshop', 'ent_objective', 'ent_route' ]
def get_entity_enum_id( alias ):
#{
("factive",c_float),
("board_transform",(c_float*3)*4),
("sm",mdl_submesh),
- ("latest_pass",c_double)]
+ ("latest_pass",c_double),
+ ("id_camera",c_uint32), # v103+
+ ]
+
+ sr_functions = { 0: 'view' }
#}
class ent_water(Structure):
route.pstr_name = sr_compile_string( obj_data.alias )
route.checkpoints_start = checkpoint_count
route.checkpoints_count = 0
+ route.id_camera = sr_entity_id( obj_data.cam )
for ci in range(3):
route.colour[ci] = obj_data.colour[ci]
name="Alias",\
default="Untitled Course")
+ cam: bpy.props.PointerProperty( \
+ type=bpy.types.Object, name="Viewpoint", \
+ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_camera']))
+
@staticmethod
def sr_inspector( layout, data ):
#{
layout.prop( data[0], 'alias' )
layout.prop( data[0], 'colour' )
+ layout.prop( data[0], 'cam' )
layout.label( text='Checkpoints' )
layout.template_list('SR_UL_ROUTE_NODE_LIST', 'Checkpoints', \
return;
}
- if( mdl_entity_id_type( challenge->camera ) == k_ent_camera ){
- u32 index = mdl_entity_id_id( challenge->camera );
- ent_camera *cam = mdl_arritm( &world->ent_camera, index );
-
- /* TODO COMPRESSION */
- v3f dir = {0.0f,-1.0f,0.0f};
- mdl_transform_vector( &cam->transform, dir, dir );
- m3x3_mulv( localplayer.invbasis, dir, dir );
- player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
- v3_copy( cam->transform.co, world_static.focus_cam.pos );
- world_static.focus_cam.fov = cam->fov;
- }
- else {
- /* TODO COMPRESSION */
- v3_copy( localplayer.cam.pos, world_static.focus_cam.pos );
- v3_copy( localplayer.cam.angles, world_static.focus_cam.angles );
- world_static.focus_cam.fov = localplayer.cam.fov;
- world_static.focus_cam.nearz = localplayer.cam.nearz;
- world_static.focus_cam.farz = localplayer.cam.farz;
- }
+ world_entity_focus_camera( world, challenge->camera );
gui_helper_action( button_display_string( k_srbind_maccept ), "start" );
gui_helper_action( button_display_string( k_srbind_mback ), "exit" );
--- /dev/null
+#ifndef ENT_ROUTE_C
+#define ENT_ROUTE_C
+
+#include "ent_route.h"
+#include "input.h"
+#include "gui.h"
+
+static void ent_route_call( world_instance *world, ent_call *call ){
+ u32 index = mdl_entity_id_id( call->id );
+ ent_route *route = mdl_arritm( &world->ent_route, index );
+
+ if( call->function == 0 ){ /* view() */
+ if( localplayer.subsystem == k_player_subsystem_walk ){
+ world_entity_focus( call->id );
+ }
+ }
+ else {
+ /* TODO: Comrpession */
+ vg_print_backtrace();
+ vg_error( "Unhandled function id: %u\n", call->function );
+ }
+}
+
+/* TODO: these should recieve the world instance */
+static void ent_route_preupdate( ent_route *route, int active ){
+ if( !active ) return;
+
+ world_instance *world = world_current_instance();
+ u32 cam_id = 0;
+
+ if( __builtin_expect( world->meta.info.version >= 103, 1 ) )
+ cam_id = route->id_camera;
+
+ world_entity_focus_camera( world, cam_id );
+
+ gui_helper_action( button_display_string( k_srbind_mleft ), "weekly" );
+ gui_helper_action( button_display_string( k_srbind_mright ), "all time" );
+
+ gui_helper_action( button_display_string( k_srbind_mback ), "exit" );
+
+ if( button_down( k_srbind_mback ) ){
+ world_entity_unfocus();
+ return;
+ }
+}
+
+#endif /* ENT_ROUTE_C */
--- /dev/null
+#ifndef ENT_ROUTE_H
+#define ENT_ROUTE_H
+
+#include "entity.h"
+
+static void ent_route_call( world_instance *world, ent_call *call );
+static void ent_route_preupdate( ent_route *route, int active );
+
+#endif /* ENT_ROUTE_H */
#include "ent_objective.c"
#include "ent_challenge.c"
#include "ent_relay.c"
+#include "ent_route.c"
typedef void (*fn_entity_call_handler)( world_instance *, ent_call *);
[k_ent_ccmd] = ent_ccmd_call,
[k_ent_gate] = ent_gate_call,
[k_ent_relay] = ent_relay_call,
- [k_ent_challenge] = ent_challenge_call
+ [k_ent_challenge] = ent_challenge_call,
+ [k_ent_route] = ent_route_call
};
if( type >= vg_list_size(table) ){
u16 active_checkpoint,
valid_checkpoints;
- float factive;
+ f32 factive;
m4x3f board_transform;
mdl_submesh sm;
- double timing_base;
+ f64 timing_base;
+
+ u32 id_camera; /* v103+ */
};
struct ent_water{
#include "skaterift.h"
#define MDL_VERSION_MIN 101
-#define MDL_VERSION_NR 102
+#define MDL_VERSION_NR 103
enum mdl_shader{
k_shader_standard = 0,
#include "menu.h"
#include "ent_challenge.h"
#include "ent_skateshop.h"
+#include "ent_route.h"
static void world_entity_focus( u32 entity_id ){
localplayer.immobile = 1;
srinput.enabled = 0;
}
+static void world_entity_focus_camera( world_instance *world, u32 uid ){
+ if( mdl_entity_id_type( uid ) == k_ent_camera ){
+ u32 index = mdl_entity_id_id( uid );
+ ent_camera *cam = mdl_arritm( &world->ent_camera, index );
+
+ v3f dir = {0.0f,-1.0f,0.0f};
+ mdl_transform_vector( &cam->transform, dir, dir );
+ m3x3_mulv( localplayer.invbasis, dir, dir );
+ player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
+ v3_copy( cam->transform.co, world_static.focus_cam.pos );
+ world_static.focus_cam.fov = cam->fov;
+ }
+ else {
+ camera_copy( &localplayer.cam, &world_static.focus_cam );
+
+ /* TODO ? */
+ world_static.focus_cam.nearz = localplayer.cam.nearz;
+ world_static.focus_cam.farz = localplayer.cam.farz;
+ }
+}
+
/* logic preupdate */
static void world_entity_focus_preupdate(void){
f32 rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f );
index = mdl_entity_id_id( world_static.focused_entity );
world_instance *world = world_current_instance();
+ /* TODO: Table. */
if( type == k_ent_skateshop ){
ent_skateshop *skateshop = mdl_arritm( &world->ent_skateshop, index );
ent_skateshop_preupdate( skateshop, active );
ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
ent_challenge_preupdate( challenge, active );
}
+ else if( type == k_ent_route ){
+ ent_route *route = mdl_arritm( &world->ent_route, index );
+ ent_route_preupdate( route, active );
+ }
}
/* additional renderings like text etc.. */
skateshop_render( skateshop );
}
else if( type == k_ent_challenge ){
-
+ }
+ else if( type == k_ent_route ){
}
else {
vg_fatal_error( "Programming error\n" );
static void world_entity_focus_preupdate(void);
static void world_entity_focus_render(void);
static void world_entity_unfocus();
+static void world_entity_focus_camera( world_instance *world, u32 uid );
static bh_system bh_system_entity_list = {
.expand_bound = entity_bh_expand_bound,