('ent_menuitem', 'Menu Item', '', 15 ),
('ent_worldinfo', 'World Info', '', 16 ),
('ent_ccmd', 'CCmd', '', 17 ),
- ('ent_challenge', 'Challenge', '', 18 ),
- ('ent_unlock', 'Unlockable', '', 19 ),
+ ('ent_objective', 'Objective', '', 18 ),
+ ('ent_challenge', 'Challenge', '', 19 ),
('ent_relay', 'Relay', '', 20 )
]
MDL_VERSION_NR = 102
-SR_TRIGGERABLE = [ 'ent_audio', 'ent_ccmd', 'ent_gate', 'ent_unlock', \
- 'ent_relay', 'ent_skateshop', 'ent_challenge' ]
+SR_TRIGGERABLE = [ 'ent_audio', 'ent_ccmd', 'ent_gate', 'ent_challenge', \
+ 'ent_relay', 'ent_skateshop', 'ent_objective' ]
def get_entity_enum_id( alias ):
#{
_fields_ = [("pstr_command",c_uint32)]
#}
-class ent_challenge(Structure):#{
+class ent_objective(Structure):#{
_fields_ = [("transform",mdl_transform),
("submesh_start",c_uint32), ("submesh_count",c_uint32),
("flags",c_uint32),
("time_limit",c_float)]
sr_functions = { 0: 'trigger',
- 1: 'start_challenge',
2: 'show',
3: 'hide' }
#}
-class ent_unlock(Structure):#{
+class ent_challenge(Structure):#{
_fields_ = [("transform",mdl_transform),
("pstr_alias",c_uint32),
+ ("flags",c_uint32),
("target",c_uint32),
("target_event",c_uint32),
- ("status",c_uint32)]
- sr_functions = { 0: 'unlock' }
+ ("reset",c_uint32),
+ ("reset_event",c_uint32),
+ ("first",c_uint32),
+ ("camera",c_uint32),
+ ("status",c_uint32)] #runtime
+ sr_functions = { 0: 'unlock',
+ 1: 'view/reset' }
#}
class ent_relay(Structure):#{
if ent_type == 'ent_font': continue
if ent_type == 'ent_font_variant': continue
if ent_type == 'ent_menuitem': continue
- if ent_type == 'ent_challenge': continue
+ if ent_type == 'ent_objective': continue
#TODO: This is messy.
if ent_type == 'ent_gate':#{
ccmd.pstr_command = sr_compile_string( obj_data.command )
sr_ent_push( ccmd )
#}
+ elif ent_type == 'ent_objective':#{
+ objective = ent_objective()
+ obj_data = obj.SR_data.ent_objective[0]
+ objective.id_next = sr_entity_id( obj_data.proxima )
+ objective.id_win = sr_entity_id( obj_data.target )
+ objective.win_event = obj_data.target_event
+ objective.filter = int(obj_data.filtrar)
+ objective.filter2 = 0
+ objective.time_limit = obj_data.time_limit
+
+ compile_obj_transform( obj, objective.transform )
+ objective.submesh_start, objective.submesh_count, _ = \
+ sr_compile_mesh_internal( obj )
+
+ sr_ent_push( objective )
+ #}
elif ent_type == 'ent_challenge':#{
challenge = ent_challenge()
obj_data = obj.SR_data.ent_challenge[0]
- challenge.id_next = sr_entity_id( obj_data.proxima )
- challenge.id_win = sr_entity_id( obj_data.target )
- challenge.win_event = obj_data.target_event
- challenge.filter = int(obj_data.filtrar)
- challenge.filter2 = 0
- challenge.time_limit = obj_data.time_limit
-
compile_obj_transform( obj, challenge.transform )
- challenge.submesh_start, challenge.submesh_count, _ = \
- sr_compile_mesh_internal( obj )
-
+ challenge.pstr_alias = sr_compile_string( obj_data.alias )
+ challenge.target = sr_entity_id( obj_data.target )
+ challenge.target_event = obj_data.target_event
+ challenge.reset = sr_entity_id( obj_data.reset )
+ challenge.reset_event = obj_data.reset_event
+ challenge.first = sr_entity_id( obj_data.first )
+ challenge.flags = 0x00
+ challenge.camera = sr_entity_id( obj_data.camera )
+ if obj_data.time_limit: challenge.flags |= 0x01
+ challenge.status = 0
sr_ent_push( challenge )
#}
- elif ent_type == 'ent_unlock':#{
- unlock = ent_unlock()
- obj_data = obj.SR_data.ent_unlock[0]
- compile_obj_transform( obj, unlock.transform )
- unlock.pstr_alias = sr_compile_string( obj_data.alias )
- unlock.target = sr_entity_id( obj_data.target )
- unlock.target_event = obj_data.target_event
- unlock.status = 0
- sr_ent_push( unlock )
- #}
elif ent_type == 'ent_relay':#{
relay = ent_relay()
obj_data = obj.SR_data.ent_relay[0]
command: bpy.props.StringProperty(name="Command Line")
#}
-class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
+class SR_OBJECT_ENT_OBJECTIVE(bpy.types.PropertyGroup):#{
proxima: bpy.props.PointerProperty( \
type=bpy.types.Object, name="Next", \
- poll=lambda self,obj: sr_filter_ent_type(obj,['ent_challenge']))
+ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_objective']))
target: bpy.props.PointerProperty( \
type=bpy.types.Object, name="Win", \
poll=lambda self,obj: sr_filter_ent_type(obj,SR_TRIGGERABLE))
(str(0x20),'grind_truck_any',''),
(str(0x40),'grind_board_any',''),
(str(0x20|0x40),'grind_any',''),
- (str(0x80),'footplant','')
+ (str(0x80),'footplant',''),
+ (str(0x100),'passthrough',''),
])
@staticmethod
#}
#}
-class SR_OBJECT_ENT_UNLOCK(bpy.types.PropertyGroup):#{
+class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
alias: bpy.props.StringProperty( name="Alias" )
+
target: bpy.props.PointerProperty( \
- type=bpy.types.Object, name="Target", \
+ type=bpy.types.Object, name="On Complete", \
poll=lambda self,obj: sr_filter_ent_type(obj,SR_TRIGGERABLE))
target_event: bpy.props.IntProperty( name="Event/Method" )
+ reset: bpy.props.PointerProperty( \
+ type=bpy.types.Object, name="On Reset", \
+ poll=lambda self,obj: sr_filter_ent_type(obj,SR_TRIGGERABLE))
+ reset_event: bpy.props.IntProperty( name="Event/Method" )
+
+ time_limit: bpy.props.BoolProperty( name="Time Limit" )
+
+ first: bpy.props.PointerProperty( \
+ type=bpy.types.Object, name="First Objective", \
+ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_objective']))
+
+ camera: bpy.props.PointerProperty( \
+ type=bpy.types.Object, name="Camera", \
+ 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], 'camera' )
+ layout.prop( data[0], 'first' )
+ layout.prop( data[0], 'time_limit' )
SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target' )
+ SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'reset' )
#}
#}
ent_menuitem: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_MENU_ITEM)
ent_worldinfo: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_WORLD_INFO)
ent_ccmd: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CCMD)
+ ent_objective: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_OBJECTIVE)
ent_challenge: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CHALLENGE)
- ent_unlock: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_UNLOCK)
ent_relay: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_RELAY)
ent_type: bpy.props.EnumProperty(
elif ent_type == 'ent_volume':#{
cv_ent_volume( obj )
#}
- elif ent_type == 'ent_challenge':#{
- data = obj.SR_data.ent_challenge[0]
+ elif ent_type == 'ent_objective':#{
+ data = obj.SR_data.ent_objective[0]
if data.proxima:#{
- cv_draw_arrow( obj.location, data.proxima.location, (1,1,1) )
+ cv_draw_arrow( obj.location, data.proxima.location, (1,0.6,0.2) )
#}
if data.target:
cv_draw_arrow( obj.location, data.target.location, (1,1,1) )
if data.target3:
cv_draw_arrow( obj.location, data.target3.location, (1,1,1) )
#}
- elif ent_type == 'ent_unlock':#{
- data = obj.SR_data.ent_unlock[0]
+ elif ent_type == 'ent_challenge':#{
+ data = obj.SR_data.ent_challenge[0]
if data.target:
cv_draw_arrow( obj.location, data.target.location, (1,1,1) )
+ if data.reset:
+ cv_draw_arrow( obj.location, data.reset.location, (0.9,0,0) )
+ if data.first:
+ cv_draw_arrow( obj.location, data.first.location, (1,0.6,0.2) )
+
cc1 = (0.4,0.3,0.2)
info_cu = Vector((1.2,0.01,0.72))*0.5
info_co = Vector((0.0,0.0,0.72))*0.5
cv_draw_ucube( obj.matrix_world, cc1, info_cu, info_co)
+ if data.camera:
+ cv_draw_line_dotted( obj.location, data.camera.location, (1,1,1))
vs = [Vector((-0.2,0.0,0.10)),Vector((-0.2,0.0,0.62)),\
Vector(( 0.2,0.0,0.62)),Vector((-0.2,0.0,0.30)),\
info_cu = Vector((1.2,0.01,0.3))*0.5
info_co = Vector((0.0,0.0,0.0))*0.5
#}
+ elif data.tipo == '3':#{
+ rack = None
+ display = None
+ info = None
+ #}
if rack:
cv_draw_ucube( rack.matrix_world, cc, rack_cu, rack_co )
SR_OBJECT_ENT_FONT,SR_OBJECT_ENT_TRAFFIC,SR_OBJECT_ENT_SKATESHOP,\
SR_OBJECT_ENT_WORKSHOP_PREVIEW,SR_OBJECT_ENT_MENU_ITEM,\
SR_OBJECT_ENT_WORLD_INFO,SR_OBJECT_ENT_CCMD,\
- SR_OBJECT_ENT_CHALLENGE,SR_OBJECT_ENT_UNLOCK,SR_OBJECT_ENT_RELAY,\
+ SR_OBJECT_ENT_OBJECTIVE,SR_OBJECT_ENT_CHALLENGE,\
+ SR_OBJECT_ENT_RELAY,\
\
SR_OBJECT_PROPERTIES, SR_LIGHT_PROPERTIES, SR_BONE_PROPERTIES,
SR_MESH_PROPERTIES, SR_MATERIAL_PROPERTIES \
#ifndef ENT_CHALLENGE_C
#define ENT_CHALLENGE_C
-#include "world.h"
-#include "world_load.h"
#include "entity.h"
+#include "input.h"
-VG_STATIC void ent_challenge_pass( world_instance *world,
- ent_challenge *challenge ){
- if( challenge->id_next ){
- world->challenge_timer += challenge->filter;
-
- u32 index = mdl_entity_id_id( challenge->id_next );
- ent_challenge *next = mdl_arritm( &world->ent_challenge, index );
- world->challenge_target = next;
-
- vg_info( "pass challenge point\n" );
- }
- else {
- vg_success( "NYU Film school graduate SUCKAH\n" );
- world->challenge_target = NULL;
- world->challenge_timer = 0.0f;
+VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ){
+ u32 index = mdl_entity_id_id( call->id );
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
- if( challenge->id_win ){
+ if( call->function == 0 ){ /* challenge() */
+ if( !challenge->status ){
+ vg_info( "challenge( '%s' )\n",
+ mdl_pstr( &world->meta, challenge->pstr_alias) );
ent_call call;
call.data = NULL;
- call.function = challenge->win_event;
- call.id = challenge->id_win;
+ call.function = challenge->target_event;
+ call.id = challenge->target;
entity_call( world, &call );
}
+ challenge->status = 1;
}
-}
-
-VG_STATIC int ent_challenge_check_filter( ent_challenge *challenge ){
- if( challenge->filter ){
- struct player_skate_state *s = &localplayer._skate.state;
- enum trick_type trick = s->trick_type;
-
- u32 state = 0x00;
-
- if( trick == k_trick_type_shuvit )
- state |= k_ent_challenge_filter_trick_shuvit;
- if( trick == k_trick_type_treflip )
- state |= k_ent_challenge_filter_trick_treflip;
- if( trick == k_trick_type_kickflip )
- state |= k_ent_challenge_filter_trick_kickflip;
-
- if( s->flip_rate < -0.0001f ) state |= k_ent_challenge_filter_flip_back;
- if( s->flip_rate > 0.0001f ) state |= k_ent_challenge_filter_flip_front;
-
- if( s->activity == k_skate_activity_grind_5050 ||
- s->activity == k_skate_activity_grind_back50 ||
- s->activity == k_skate_activity_grind_front50 )
- state |= k_ent_challenge_filter_grind_truck_any;
-
- if( s->activity == k_skate_activity_grind_boardslide )
- state |= k_ent_challenge_filter_grind_board_any;
-
- return ((challenge->filter & state) || !challenge->filter) &&
- ((challenge->filter2 & state) || !challenge->filter2);
+ else if( call->function == 1 ){ /* view() */
+ world_entity_focus( call->id );
}
else {
- return 1;
+ vg_print_backtrace();
+ vg_error( "Unhandled function id: %u\n", call->function );
}
}
-VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ){
- u32 index = mdl_entity_id_id( call->id );
- ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge ){
+ world_instance *world = world_current_instance();
- if( call->function == 0 ){
- if( challenge->flags & k_ent_challenge_hidden ) 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 );
- if( world->challenge_target ){
- if( (world->challenge_target == challenge) &&
- ent_challenge_check_filter( challenge )){
- ent_challenge_pass( world, challenge );
- }
- else {
- vg_error( "womp womp\n" );
- world->challenge_target = NULL;
- world->challenge_timer = 0.0f;
- }
- }
+ /* 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 if( call->function == 1 ){
- if( challenge->flags & k_ent_challenge_hidden ) return;
-
- vg_info( "begin the challenge\n" );
- world->challenge_timer = 0.0f;
- ent_challenge_pass( world, challenge );
+ 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;
}
- else if( call->function == 2 ){
- challenge->flags &= ~k_ent_challenge_hidden;
- if( mdl_entity_id_type( challenge->id_next ) == k_ent_challenge ){
- call->id = challenge->id_next;
- entity_call( world, call );
- }
+ if( button_down( k_srbind_mback ) ){
+ world_entity_unfocus();
+ return;
}
- else if( call->function == 3 ){
- challenge->flags |= k_ent_challenge_hidden;
+}
- if( mdl_entity_id_type( challenge->id_next ) == k_ent_challenge ){
- call->id = challenge->id_next;
- entity_call( world, call );
- }
- }
- else {
- vg_print_backtrace();
- vg_error( "Unhandled function id: %u\n", call->function );
- }
+VG_STATIC void ent_challenge_render( ent_challenge *challenge ){
+
}
#endif /* ENT_CHALLENGE_C */
--- /dev/null
+#ifndef ENT_CHALLENGE_H
+#define ENT_CHALLENGE_H
+
+#include "entity.h"
+
+VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge );
+VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call );
+
+#endif /* ENT_CHALLENGE_H */
--- /dev/null
+#ifndef ENT_OBJECTIVE_C
+#define ENT_OBJECTIVE_C
+
+#include "world.h"
+#include "world_load.h"
+#include "entity.h"
+
+VG_STATIC void ent_objective_pass( world_instance *world,
+ ent_objective *objective ){
+ if( objective->id_next ){
+ world->challenge_timer += objective->filter;
+
+ u32 index = mdl_entity_id_id( objective->id_next );
+ ent_objective *next = mdl_arritm( &world->ent_objective, index );
+ world->challenge_target = next;
+
+ if( next->filter & k_ent_objective_filter_passthrough )
+ ent_objective_pass( world, next );
+ else
+ vg_info( "pass challenge point\n" );
+ }
+ else {
+ vg_success( "NYU Film school graduate SUCKAH\n" );
+ world->challenge_target = NULL;
+ world->challenge_timer = 0.0f;
+
+ if( objective->id_win ){
+ ent_call call;
+ call.data = NULL;
+ call.function = objective->win_event;
+ call.id = objective->id_win;
+ entity_call( world, &call );
+ }
+ }
+}
+
+VG_STATIC int ent_objective_check_filter( ent_objective *objective ){
+ if( objective->filter ){
+ struct player_skate_state *s = &localplayer._skate.state;
+ enum trick_type trick = s->trick_type;
+
+ u32 state = 0x00;
+
+ if( trick == k_trick_type_shuvit )
+ state |= k_ent_objective_filter_trick_shuvit;
+ if( trick == k_trick_type_treflip )
+ state |= k_ent_objective_filter_trick_treflip;
+ if( trick == k_trick_type_kickflip )
+ state |= k_ent_objective_filter_trick_kickflip;
+
+ if( s->flip_rate < -0.0001f ) state |= k_ent_objective_filter_flip_back;
+ if( s->flip_rate > 0.0001f ) state |= k_ent_objective_filter_flip_front;
+
+ if( s->activity == k_skate_activity_grind_5050 ||
+ s->activity == k_skate_activity_grind_back50 ||
+ s->activity == k_skate_activity_grind_front50 )
+ state |= k_ent_objective_filter_grind_truck_any;
+
+ if( s->activity == k_skate_activity_grind_boardslide )
+ state |= k_ent_objective_filter_grind_board_any;
+
+ return ((objective->filter & state) || !objective->filter) &&
+ ((objective->filter2 & state) || !objective->filter2);
+ }
+ else {
+ return 1;
+ }
+}
+
+VG_STATIC void ent_objective_call( world_instance *world, ent_call *call ){
+ u32 index = mdl_entity_id_id( call->id );
+ ent_objective *objective = mdl_arritm( &world->ent_objective, index );
+
+ if( call->function == 0 ){
+ if( objective->flags & k_ent_objective_hidden ) return;
+
+ if( world->challenge_target ){
+ if( (world->challenge_target == objective) &&
+ ent_objective_check_filter( objective )){
+ ent_objective_pass( world, objective );
+ }
+ else {
+ vg_error( "womp womp\n" );
+ world->challenge_target = NULL;
+ world->challenge_timer = 0.0f;
+ }
+ }
+ }
+#if 0
+ else if( call->function == 1 ){
+ if( objective->flags & k_ent_objective_hidden ) return;
+
+ vg_info( "begin the challenge\n" );
+ world->challenge_timer = 0.0f;
+ ent_objective_pass( world, objective );
+ }
+#endif
+ else if( call->function == 2 ){
+ objective->flags &= ~k_ent_objective_hidden;
+
+ if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
+ call->id = objective->id_next;
+ entity_call( world, call );
+ }
+ }
+ else if( call->function == 3 ){
+ objective->flags |= k_ent_objective_hidden;
+
+ if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
+ call->id = objective->id_next;
+ entity_call( world, call );
+ }
+ }
+ else {
+ vg_print_backtrace();
+ vg_error( "Unhandled function id: %u\n", call->function );
+ }
+}
+
+#endif /* ENT_OBJECTIVE_C */
* VG event preupdate
*/
void temp_update_playermodel(void);
-VG_STATIC void global_skateshop_preupdate(void){
- float rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f );
- int active = 0;
- if( skaterift.activity == k_skaterift_skateshop )
- active = 1;
-
- vg_slewf( &global_skateshop.factive, active,
- vg.time_frame_delta * (1.0f/0.5f) );
-
- if( !active ) return;
-
+VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop ){
/* input filter */
world_instance *world = world_current_instance();
- ent_skateshop *shop = global_skateshop.ptr_ent;
/* camera positioning */
ent_camera *ref = mdl_arritm( &world->ent_camera,
v3f dir = {0.0f,-1.0f,0.0f};
mdl_transform_vector( &ref->transform, dir, dir );
m3x3_mulv( localplayer.invbasis, dir, dir );
- player_vector_angles( global_skateshop.cam.angles, dir, 1.0f, 0.0f );
+ player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
v3f lookat;
if( shop->type == k_skateshop_type_boardshop ||
q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f},
atan2f(lookat[0],lookat[2]) );
- v3_copy( ref->transform.co, global_skateshop.cam.pos );
- global_skateshop.cam.fov = ref->fov;
+ v3_copy( ref->transform.co, world_static.focus_cam.pos );
+ world_static.focus_cam.fov = ref->fov;
/* input */
if( shop->type == k_skateshop_type_boardshop ){
addon_cache_watch( k_addon_type_board, cache_id );
localplayer.board_view_slot = cache_id;
- global_skateshop_exit();
+ world_entity_unfocus();
skaterift_autosave(1);
return;
}
}
if( button_down( k_srbind_maccept ) ){
- global_skateshop_exit();
+ world_entity_unfocus();
}
}
else if( shop->type == k_skateshop_type_worldshop ){
}
if( button_down( k_srbind_mback ) ){
- global_skateshop_exit();
+ world_entity_unfocus();
return;
}
}
-VG_STATIC void skateshop_render_boardshop(void){
+VG_STATIC void skateshop_render_boardshop( ent_skateshop *shop ){
world_instance *world = world_current_instance();
- ent_skateshop *shop = global_skateshop.ptr_ent;
-
u32 slot_count = vg_list_size(global_skateshop.shop_view_slots);
ent_marker *mark_rack = mdl_arritm( &world->ent_marker,
SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
}
-VG_STATIC void skateshop_render_charshop(void)
-{
+VG_STATIC void skateshop_render_charshop( ent_skateshop *shop ){
}
-VG_STATIC void skateshop_render_worldshop(void)
-{
+VG_STATIC void skateshop_render_worldshop( ent_skateshop *shop ){
world_instance *world = world_current_instance();
- ent_skateshop *shop = global_skateshop.ptr_ent;
ent_marker *mark_display = mdl_arritm( &world->ent_marker,
mdl_entity_id_id(shop->worlds.id_display)),
*mark_info = mdl_arritm( &world->ent_marker,
/*
* World: render event
*/
-VG_STATIC void skateshop_render(void){
- if( skaterift.activity != k_skaterift_skateshop ) return;
-
- ent_skateshop *shop = global_skateshop.ptr_ent;
-
- if( shop->type == k_skateshop_type_boardshop ){
- skateshop_render_boardshop();
- }
- else if( shop->type == k_skateshop_type_charshop ){
- skateshop_render_charshop();
- }
- else if( shop->type == k_skateshop_type_worldshop ){
- skateshop_render_worldshop();
- }
- else{
+VG_STATIC void skateshop_render( ent_skateshop *shop ){
+ if( shop->type == k_skateshop_type_boardshop )
+ skateshop_render_boardshop( shop );
+ else if( shop->type == k_skateshop_type_charshop )
+ skateshop_render_charshop( shop );
+ else if( shop->type == k_skateshop_type_worldshop )
+ skateshop_render_worldshop( shop );
+ else
vg_fatal_error( "Unknown store (%u)\n", shop->type );
- }
}
/*
* Entity logic: entrance event
*/
-VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
-{
+VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ){
u32 index = mdl_entity_id_id( call->id );
ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
vg_info( "skateshop_call\n" );
vg_info( "Entering skateshop\n" );
+ world_entity_focus( call->id );
+#if 0
localplayer.immobile = 1;
menu.disable_open = 1;
skaterift.activity = k_skaterift_skateshop;
v3_zero( localplayer.rb.w );
localplayer._walk.move_speed = 0.0f;
global_skateshop.ptr_ent = shop;
+#endif
if( shop->type == k_skateshop_type_boardshop ){
skateshop_update_viewpage();
}
}
-/*
- * Entity logic: exit event
- */
-VG_STATIC void global_skateshop_exit(void){
- vg_info( "exit skateshop\n" );
- localplayer.immobile = 0;
- skaterift.activity = k_skaterift_default;
- menu.disable_open = 0;
- srinput.enabled = 0;
-}
-
#endif /* ENT_SKATESHOP_C */
struct{
v3f look_target;
- ent_skateshop *ptr_ent;
- float factive;
+
+#if 0
+ ent_skateshop *ptr_ent; /* TODO */
+ float factive; /* TODO */
+ camera cam;
+#endif
struct shop_view_slot{
u16 cache_id;
u32 world_reg;
}
render;
-
- camera cam;
}
static global_skateshop={.render={.reg_id=0xffffffff,.world_reg=0xffffffff}};
-VG_STATIC void global_skateshop_exit(void);
+VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop );
+VG_STATIC void skateshop_render( ent_skateshop *shop );
#endif /* ENT_SKATESHOP_H */
+++ /dev/null
-#ifndef ENT_UNLOCK_C
-#define ENT_UNLOCK_C
-
-#include "entity.h"
-
-VG_STATIC void ent_unlock_call( world_instance *world, ent_call *call ){
- u32 index = mdl_entity_id_id( call->id );
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
-
- if( call->function == 0 ){ /* unlock() */
- if( !unlock->status ){
- vg_info( "unlock( '%s' )\n",
- mdl_pstr( &world->meta, unlock->pstr_alias) );
- ent_call call;
- call.data = NULL;
- call.function = unlock->target_event;
- call.id = unlock->target;
- entity_call( world, &call );
- }
- unlock->status = 1;
- }
- else {
- vg_print_backtrace();
- vg_error( "Unhandled function id: %u\n", call->function );
- }
-}
-
-#endif /* ENT_UNLOCK_C */
#include "world_entity.h"
#include "ent_skateshop.c"
+#include "ent_objective.c"
#include "ent_challenge.c"
-#include "ent_unlock.c"
#include "ent_relay.c"
typedef void (*fn_entity_call_handler)( world_instance *, ent_call *);
[k_ent_volume] = ent_volume_call,
[k_ent_audio] = ent_audio_call,
[k_ent_skateshop] = ent_skateshop_call,
- [k_ent_challenge] = ent_challenge_call,
+ [k_ent_objective] = ent_objective_call,
[k_ent_ccmd] = ent_ccmd_call,
[k_ent_gate] = ent_gate_call,
[k_ent_relay] = ent_relay_call,
- [k_ent_unlock] = ent_unlock_call
+ [k_ent_challenge] = ent_challenge_call
};
if( type >= vg_list_size(table) ){
typedef struct ent_swspreview ent_swspreview;
typedef struct ent_worldinfo ent_worldinfo;
typedef struct ent_ccmd ent_ccmd;
+typedef struct ent_objective ent_objective;
typedef struct ent_challenge ent_challenge;
-typedef struct ent_unlock ent_unlock;
typedef struct ent_relay ent_relay;
typedef struct ent_cubemap ent_cubemap;
k_ent_menuitem = 15,
k_ent_worldinfo = 16,
k_ent_ccmd = 17,
- k_ent_challenge = 18,
- k_ent_unlock = 19,
+ k_ent_objective = 18,
+ k_ent_challenge = 19,
k_ent_relay = 20,
k_ent_cubemap = 21
};
enum skateshop_type{
k_skateshop_type_boardshop,
k_skateshop_type_charshop,
- k_skateshop_type_worldshop
+ k_skateshop_type_worldshop,
};
struct ent_skateshop{
u32 pstr_command;
};
-enum ent_challenge_filter{
- k_ent_challenge_filter_none = 0x00000000,
- k_ent_challenge_filter_trick_shuvit = 0x00000001,
- k_ent_challenge_filter_trick_kickflip = 0x00000002,
- k_ent_challenge_filter_trick_treflip = 0x00000004,
- k_ent_challenge_filter_trick_any =
- k_ent_challenge_filter_trick_shuvit|
- k_ent_challenge_filter_trick_treflip|
- k_ent_challenge_filter_trick_kickflip,
- k_ent_challenge_filter_flip_back = 0x00000008,
- k_ent_challenge_filter_flip_front = 0x00000010,
- k_ent_challenge_filter_flip_any =
- k_ent_challenge_filter_flip_back|
- k_ent_challenge_filter_flip_front,
- k_ent_challenge_filter_grind_truck_any = 0x00000020,
- k_ent_challenge_filter_grind_board_any = 0x00000040,
- k_ent_challenge_filter_grind_any =
- k_ent_challenge_filter_grind_truck_any|
- k_ent_challenge_filter_grind_board_any,
- k_ent_challenge_filter_footplant = 0x00000080
-};
-
-enum ent_challenge_flag {
- k_ent_challenge_hidden = 0x1
-};
-
-struct ent_challenge{
+enum ent_objective_filter{
+ k_ent_objective_filter_none = 0x00000000,
+ k_ent_objective_filter_trick_shuvit = 0x00000001,
+ k_ent_objective_filter_trick_kickflip = 0x00000002,
+ k_ent_objective_filter_trick_treflip = 0x00000004,
+ k_ent_objective_filter_trick_any =
+ k_ent_objective_filter_trick_shuvit|
+ k_ent_objective_filter_trick_treflip|
+ k_ent_objective_filter_trick_kickflip,
+ k_ent_objective_filter_flip_back = 0x00000008,
+ k_ent_objective_filter_flip_front = 0x00000010,
+ k_ent_objective_filter_flip_any =
+ k_ent_objective_filter_flip_back|
+ k_ent_objective_filter_flip_front,
+ k_ent_objective_filter_grind_truck_any = 0x00000020,
+ k_ent_objective_filter_grind_board_any = 0x00000040,
+ k_ent_objective_filter_grind_any =
+ k_ent_objective_filter_grind_truck_any|
+ k_ent_objective_filter_grind_board_any,
+ k_ent_objective_filter_footplant = 0x00000080,
+ k_ent_objective_filter_passthrough = 0x00000100
+};
+
+enum ent_objective_flag {
+ k_ent_objective_hidden = 0x1
+};
+
+struct ent_objective{
mdl_transform transform;
u32 submesh_start,
submesh_count,
f32 time_limit;
};
-struct ent_unlock{
+enum ent_challenge_flag {
+ k_ent_challenge_timelimit = 0x1
+};
+
+struct ent_challenge{
mdl_transform transform;
u32 pstr_alias,
+ flags,
target,
target_event,
+ reset,
+ reset_event,
+ first,
+ camera,
status;
};
void font3d_begin( const char *text,
camera *cam, m4x3f transform, struct font3d_render *render )
{
- q_identity( render->offset );
+ v4_copy( (v4f){0.0f,0.0f,0.0f,1.0f}, render->offset );
m4x4f prev_mtx;
m4x3_expand( transform, prev_mtx );
shader_model_font_uMdl( transform );
}
else if( render->shader == k_font_shader_world ){
+
+
+ vg_info( "-----\n" );
+ for( int i=0; i<4; i++ ){
+ vg_info( PRINTF_v4f( prev_mtx[i] ) );
+ }
+
shader_scene_font_uPvmPrev( prev_mtx );
shader_scene_font_uMdl( transform );
}
render->u8pch = (u8*)text;
-
-#if 0
- render->font = font;
- render->variant_id = variant_id;
-#endif
}
-VG_STATIC void font3d_setoffset( struct font3d_render *render, v3f offset ){
+VG_STATIC void font3d_setoffset( struct font3d_render *render, v4f offset ){
if( render->shader == k_font_shader_default )
shader_model_font_uOffset( offset );
else if( render->shader == k_font_shader_world )
player__debugtext( 1, "activity: %s",
(const char *[]){ [k_skaterift_menu] = "menu",
[k_skaterift_replay] = "replay",
- [k_skaterift_skateshop] = "shop",
+ [k_skaterift_ent_focus] = "ent_focus",
[k_skaterift_default] = "default"
} [skaterift.activity] );
player__debugtext( 1, "time_rate: %.4f", skaterift.time_rate );
skaterift_replay_debug_info();
}
-VG_STATIC void global_skateshop_exit(void);
PLAYER_API void player__setpos( player_instance *player, v3f pos ){
v3_copy( pos, player->rb.co );
player->immobile = 0;
player->gate_waiting = NULL;
world_static.last_use = 0.0;
-
- global_skateshop_exit();
+ world_entity_unfocus();
if( _player_reset[ player->subsystem ] )
_player_reset[ player->subsystem ]( player, rp );
light_delta = normalize( light_delta );
float quadratic = dist2*100.0;
- float attenuation = 1.0f/( 1.0f + quadratic );
+ float attenuation = 1.0/( 1.0 + quadratic );
attenuation *= max( dot( light_delta, normal ), 0.0 );
float falloff = max( 0.0, 1.0-(dist2*light_co.w) );
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
void main(){
compute_motion_vectors();
-
vec3 vfrag = vec3(0.5,0.5,0.5);
vec3 qnorm = aNorm.xyz;
vec4 v1 = step( vec4(0.5), fract(vec4(a) + spread1) );
float d = ( v0.x+v0.y+v0.z+v0.w +
- v1.x+v1.y+v1.z+v1.w ) * 0.125f;
+ v1.x+v1.y+v1.z+v1.w ) * 0.125;
float dither = fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0);
float x = d*0.8+length(p)*0.3;
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
"\n"
"void main(){\n"
" compute_motion_vectors();\n"
-"\n"
" vec3 vfrag = vec3(0.5,0.5,0.5);\n"
" vec3 qnorm = aNorm.xyz;\n"
"\n"
" vec4 v1 = step( vec4(0.5), fract(vec4(a) + spread1) );\n"
"\n"
" float d = ( v0.x+v0.y+v0.z+v0.w +\n"
-" v1.x+v1.y+v1.z+v1.w ) * 0.125f;\n"
+" v1.x+v1.y+v1.z+v1.w ) * 0.125;\n"
" \n"
" float dither = fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0);\n"
" float x = d*0.8+length(p)*0.3;\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
" light_delta = normalize( light_delta );\n"
"\n"
" float quadratic = dist2*100.0;\n"
-" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+" float attenuation = 1.0/( 1.0 + quadratic );\n"
" attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
"\n"
" float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
vg.time_rate = vg_smoothstepf( skaterift.time_rate );
player__pre_update( &localplayer );
- global_skateshop_preupdate();
+ world_entity_focus_preupdate();
skaterift_replay_pre_update();
world_update( world_current_instance(), localplayer.rb.co );
}
VG_STATIC void skaterift_composite_maincamera(void){
- camera_lerp( &localplayer.cam, &global_skateshop.cam,
- vg_smoothstepf(global_skateshop.factive), &skaterift.cam );
+ camera_lerp( &localplayer.cam, &world_static.focus_cam,
+ vg_smoothstepf(world_static.focus_strength), &skaterift.cam );
if( skaterift.activity == k_skaterift_replay ){
skaterift_get_replay_camera( &skaterift.cam );
enum skaterift_activity {
k_skaterift_default = 0x00,
k_skaterift_replay = 0x01,
- k_skaterift_skateshop = 0x02,
+ k_skaterift_ent_focus = 0x02,
k_skaterift_menu = 0x04
}
activity;
ent_camera,
ent_swspreview,
ent_ccmd,
+ ent_objective,
ent_challenge,
- ent_unlock,
ent_relay,
ent_cubemap;
rb_object rb_geo;
- ent_challenge *challenge_target;
+ ent_objective *challenge_target;
f32 challenge_timer;
};
world_instance instances[4];
i32 active_instance;
+ /* TODO: FOCUSED_INSTANCE */
+ u32 focused_entity; /* like skateshop, challenge.. */
+ f32 focus_strength;
+ camera focus_cam;
+
addon_reg *addon_hub,
*addon_client;
#include "world_load.h"
#include "save.h"
#include "vg/vg_msg.h"
+#include "menu.h"
+#include "ent_challenge.h"
+#include "ent_skateshop.h"
+
+VG_STATIC void world_entity_focus( u32 entity_id ){
+ localplayer.immobile = 1;
+ menu.disable_open = 1;
+
+ v3_zero( localplayer.rb.v );
+ v3_zero( localplayer.rb.w );
+ localplayer._walk.move_speed = 0.0f;
+ world_static.focused_entity = entity_id;
+ skaterift.activity = k_skaterift_ent_focus;
+}
+
+VG_STATIC void world_entity_unfocus(void){
+ localplayer.immobile = 0;
+ skaterift.activity = k_skaterift_default;
+ menu.disable_open = 0;
+ srinput.enabled = 0;
+}
+
+/* logic preupdate */
+VG_STATIC void world_entity_focus_preupdate(void){
+ f32 rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f );
+ int active = 0;
+ if( skaterift.activity == k_skaterift_ent_focus )
+ active = 1;
+
+ vg_slewf( &world_static.focus_strength, active,
+ vg.time_frame_delta * (1.0f/0.5f) );
+
+ if( !active ) return;
+
+ u32 type = mdl_entity_id_type( world_static.focused_entity ),
+ index = mdl_entity_id_id( world_static.focused_entity );
+ world_instance *world = world_current_instance();
+
+ if( type == k_ent_skateshop ){
+ ent_skateshop *skateshop = mdl_arritm( &world->ent_skateshop, index );
+ ent_skateshop_preupdate( skateshop );
+ }
+ else if( type == k_ent_challenge ){
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+ ent_challenge_preupdate( challenge );
+ }
+ else {
+ vg_fatal_error( "Programming error\n" );
+ }
+}
+
+/* additional renderings like text etc.. */
+VG_STATIC void world_entity_focus_render(void){
+ if( skaterift.activity != k_skaterift_ent_focus )
+ return;
+
+ u32 type = mdl_entity_id_type( world_static.focused_entity ),
+ index = mdl_entity_id_id( world_static.focused_entity );
+ world_instance *world = world_current_instance();
+
+ if( type == k_ent_skateshop ){
+ ent_skateshop *skateshop = mdl_arritm( &world->ent_skateshop, index );
+ skateshop_render( skateshop );
+ }
+ else if( type == k_ent_challenge ){
+
+ }
+ else {
+ vg_fatal_error( "Programming error\n" );
+ }
+}
VG_STATIC void world_gen_entities_init( world_instance *world ){
/* lights */
}
indexables[] = {
{ k_ent_gate, &world->ent_gate },
- { k_ent_challenge, &world->ent_challenge },
+ { k_ent_objective, &world->ent_objective },
{ k_ent_volume, &world->ent_volume },
- { k_ent_unlock, &world->ent_unlock }
+ { k_ent_challenge, &world->ent_challenge }
};
for( u32 i=0; i<vg_list_size(indexables); i++ )
m4x3_expand_aabb_aabb( gate->to_world, bound, box );
}
- else if( type == k_ent_challenge ){
- ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+ else if( type == k_ent_objective ){
+ ent_objective *objective = mdl_arritm( &world->ent_objective, index );
/* TODO: This might be more work than necessary. could maybe just get
* away with representing them as points */
boxf box;
box_init_inf( box );
- for( u32 i=0; i<challenge->submesh_count; i++ ){
+ for( u32 i=0; i<objective->submesh_count; i++ ){
mdl_submesh *sm = mdl_arritm( &world->meta.submeshs,
- challenge->submesh_start+i );
+ objective->submesh_start+i );
box_concat( box, sm->bbx );
}
m4x3f transform;
- mdl_transform_m4x3( &challenge->transform, transform );
+ mdl_transform_m4x3( &objective->transform, transform );
m4x3_expand_aabb_aabb( transform, bound, box );
}
else if( type == k_ent_volume ){
m4x3_expand_aabb_aabb( volume->to_world, bound,
(boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}} );
}
- else if( type == k_ent_unlock ){
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+ else if( type == k_ent_challenge ){
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f},
{ 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}};
m4x3f transform;
- mdl_transform_m4x3( &unlock->transform, transform );
+ mdl_transform_m4x3( &challenge->transform, transform );
m4x3_expand_aabb_aabb( transform, bound, box );
}
else{
ent_gate *gate = mdl_arritm( &world->ent_gate, index );
return gate->to_world[3][axis];
}
- else if( type == k_ent_challenge ){
- ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
- return challenge->transform.co[axis];
+ else if( type == k_ent_objective ){
+ ent_objective *objective = mdl_arritm( &world->ent_objective, index );
+ return objective->transform.co[axis];
}
else if( type == k_ent_volume ){
ent_volume *volume = mdl_arritm( &world->ent_volume, index );
return volume->transform.co[axis];
}
- else if( type == k_ent_unlock ){
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
- return unlock->transform.co[axis];
+ else if( type == k_ent_challenge ){
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+ return challenge->transform.co[axis];
}
else {
vg_fatal_error( "Programming error\n" );
{ gate->dimensions[0], gate->dimensions[1], 0.1f }};
vg_line_boxf_transformed( gate->to_world, box, 0xf000ff00 );
}
- else if( type == k_ent_challenge ){
- ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+ else if( type == k_ent_objective ){
+ ent_objective *objective = mdl_arritm( &world->ent_objective, index );
boxf box;
box_init_inf( box );
- for( u32 i=0; i<challenge->submesh_count; i++ ){
+ for( u32 i=0; i<objective->submesh_count; i++ ){
mdl_submesh *sm = mdl_arritm( &world->meta.submeshs,
- challenge->submesh_start+i );
+ objective->submesh_start+i );
box_concat( box, sm->bbx );
}
m4x3f transform;
- mdl_transform_m4x3( &challenge->transform, transform );
+ mdl_transform_m4x3( &objective->transform, transform );
vg_line_boxf_transformed( transform, box, 0xf000ff00 );
}
else if( type == k_ent_volume ){
(boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}},
0xf000ff00 );
}
- else if( type == k_ent_unlock ){
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+ else if( type == k_ent_challenge ){
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f},
{ 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}};
m4x3f transform;
- mdl_transform_m4x3( &unlock->transform, transform );
+ mdl_transform_m4x3( &challenge->transform, transform );
vg_line_boxf_transformed( transform, box, 0xf0ff0000 );
}
else{
ent_gate *gate = mdl_arritm( &world->ent_gate, index );
v3_copy( gate->to_world[3], closest );
}
- else if( type == k_ent_challenge ){
- ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+ else if( type == k_ent_objective ){
+ ent_objective *challenge = mdl_arritm( &world->ent_objective, index );
v3_copy( challenge->transform.co, closest );
}
else if( type == k_ent_volume ){
ent_volume *volume = mdl_arritm( &world->ent_volume, index );
v3_copy( volume->to_world[3], closest );
}
- else if( type == k_ent_unlock ){
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
- v3_copy( unlock->transform.co, closest );
+ else if( type == k_ent_challenge ){
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+ v3_copy( challenge->transform.co, closest );
}
else{
vg_fatal_error( "Programming error\n" );
/* read savedata
* ----------------------------------------------------------------------- */
- for( u32 i=0; i<mdl_arrcount(&world->ent_unlock); i++ ){
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, i );
- const char *alias = mdl_pstr( &world->meta, unlock->pstr_alias );
+ for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
+ const char *alias = mdl_pstr( &world->meta, challenge->pstr_alias );
if( vg_msg_seekkvu32( sav, alias, k_vg_msg_first ) ){
ent_call call;
call.data = NULL;
call.function = 0;
- call.id = mdl_entity_id( k_ent_unlock, i );
+ call.id = mdl_entity_id( k_ent_challenge, i );
entity_call( world, &call );
}
}
}
VG_STATIC void world_entity_serialize( world_instance *world, vg_msg *sav ){
- for( u32 i=0; i<mdl_arrcount(&world->ent_unlock); i++ ){
- ent_unlock *unlock = mdl_arritm(&world->ent_unlock,i);
+ for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+ ent_challenge *challenge = mdl_arritm(&world->ent_challenge,i);
- const char *alias = mdl_pstr(&world->meta,unlock->pstr_alias);
- vg_msg_wkvu32( sav, alias, unlock->status );
+ const char *alias = mdl_pstr(&world->meta,challenge->pstr_alias);
+ vg_msg_wkvu32( sav, alias, challenge->status );
}
}
VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point,
v3f closest );
+VG_STATIC void world_entity_focus( u32 entity_id );
+VG_STATIC void world_entity_focus_preupdate(void);
+VG_STATIC void world_entity_focus_render(void);
+VG_STATIC void world_entity_unfocus();
+
static bh_system bh_system_entity_list = {
.expand_bound = entity_bh_expand_bound,
.item_centroid = entity_bh_centroid,
}
/* unpack challenge models */
- for( u32 i=0; i<mdl_arrcount( &world->ent_challenge ); i++ ){
- ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
+ for( u32 i=0; i<mdl_arrcount( &world->ent_objective ); i++ ){
+ ent_objective *objective = mdl_arritm( &world->ent_objective, i );
- for( u32 j=0; j<challenge->submesh_count; j ++ ){
+ for( u32 j=0; j<objective->submesh_count; j ++ ){
mdl_submesh *sm = mdl_arritm( &world->meta.submeshs,
- challenge->submesh_start+j );
+ objective->submesh_start+j );
world_unpack_submesh_dynamic( world, &world->scene_no_collide, sm );
}
}
mdl_load_array( meta, &world->ent_skateshop, "ent_skateshop", heap );
mdl_load_array( meta, &world->ent_swspreview,"ent_swspreview", heap );
mdl_load_array( meta, &world->ent_ccmd, "ent_ccmd", heap );
+ mdl_load_array( meta, &world->ent_objective, "ent_objective", heap );
mdl_load_array( meta, &world->ent_challenge, "ent_challenge", heap );
- mdl_load_array( meta, &world->ent_unlock, "ent_unlock", heap );
mdl_load_array( meta, &world->ent_relay, "ent_relay", heap );
mdl_load_array( meta, &world->ent_cubemap, "ent_cubemap", heap );
bh_iter_init_range( 0, &it, pos, radius+10.0f );
i32 idx;
- u32 challenge_list[ 32 ],
- unlock_list[ 32 ];
+ u32 objective_list[ 32 ],
+ challenge_list[ 16 ];
- u32 challenge_count = 0,
- unlock_count = 0;
+ u32 objective_count = 0,
+ challenge_count = 0;
while( bh_next( world->entity_bh, &it, &idx ) ){
u32 id = world->entity_list[ idx ],
type = mdl_entity_id_type( id ),
index = mdl_entity_id_id( id );
- if( type == k_ent_challenge ) {
+ if( type == k_ent_objective ) {
+ if( objective_count < vg_list_size(objective_list) )
+ objective_list[ objective_count ++ ] = index;
+ }
+ else if( type == k_ent_challenge ){
if( challenge_count < vg_list_size(challenge_list) )
challenge_list[ challenge_count ++ ] = index;
}
- else if( type == k_ent_unlock ){
- if( unlock_count < vg_list_size(unlock_list) )
- unlock_list[ unlock_count ++ ] = index;
- }
}
- /* render challenges */
+ /* render objectives */
glDisable( GL_CULL_FACE );
mesh_bind( &world->mesh_no_collide );
u32 last_material = 0;
- for( u32 i=0; i<challenge_count; i++ ){
- u32 index = challenge_list[ i ];
- ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
- if( challenge->flags & k_ent_challenge_hidden ) continue;
+ for( u32 i=0; i<objective_count; i++ ){
+ u32 index = objective_list[ i ];
+ ent_objective *objective = mdl_arritm( &world->ent_objective, index );
+ if( objective->flags & k_ent_objective_hidden ) continue;
- f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius),
+ f32 dist = v3_dist( objective->transform.co, pos ) * (1.0f/radius),
scale = vg_smoothstepf( vg_clampf( 5.0f-dist*5.0f, 0.0f,1.0f ) );
- v3_fill( challenge->transform.s, scale );
+ v3_fill( objective->transform.s, scale );
m4x3f mmdl;
- mdl_transform_m4x3( &challenge->transform, mmdl );
+ mdl_transform_m4x3( &objective->transform, mmdl );
shader_scene_fxglow_uMdl( mmdl );
- for( u32 j=0; j<challenge->submesh_count; j++ ){
+ for( u32 j=0; j<objective->submesh_count; j++ ){
mdl_submesh *sm = mdl_arritm( &world->meta.submeshs,
- challenge->submesh_start + j );
+ objective->submesh_start + j );
if( sm->material_id != last_material ){
last_material = sm->material_id;
shader_scene_font_use();
shader_scene_font_uTexGarbage(0);
shader_scene_font_uTexMain(1);
+
shader_scene_font_uPv( skaterift.cam.mtx.pv );
shader_scene_font_uTime( vg.time );
char buf[32];
u32 count = 0;
- for( u32 i=0; i<mdl_arrcount(&world->ent_unlock); i++ ){
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, i );
- vg_line_point( unlock->transform.co, 0.2f, VG__GREEN );
- if( unlock->status ) count ++;
+ for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
+ vg_line_point( challenge->transform.co, 0.2f, VG__GREEN );
+ if( challenge->status ) count ++;
}
int c=0;
c+=highscore_intl( buf+c, count, 3 );
buf[c++] = '/';
- c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_unlock), 3 );
+ c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_challenge), 3 );
buf[c++] = '\0';
f32 w = font3d_string_width( &gui.font, 1, buf );
m3x3_identity( mlocal );
mlocal[3][0] = -w*0.5f;
- for( u32 i=0; i<unlock_count; i++ ){
- u32 index = unlock_list[ i ];
- ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+ for( u32 i=0; i<challenge_count; i++ ){
+ u32 index = challenge_list[ i ];
+ ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
m4x3f mmdl;
- mdl_transform_m4x3( &unlock->transform, mmdl );
+ mdl_transform_m4x3( &challenge->transform, mmdl );
m4x3_mul( mmdl, mlocal, mmdl );
- vg_line_point( unlock->transform.co, 0.25f, VG__RED );
+ vg_line_point( challenge->transform.co, 0.25f, VG__RED );
- f32 dist = v3_dist( unlock->transform.co, pos ) * (1.0f/radius),
+ f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius),
scale = vg_smoothstepf( vg_clampf( 10.0f-dist*10.0f, 0.0f,1.0f ) ),
colour = 0.0f;
- if( unlock->status )
+ if( challenge->status )
colour = 1.0f;
shader_scene_font_uOpacity( scale );
sizeof(struct ub_world_lighting), &world->ub_lighting );
}
-VG_STATIC void skateshop_render(void);
VG_STATIC void render_world( world_instance *world, camera *cam,
int layer_depth )
{
render_world_vb( world, cam );
render_world_alphatest( world, cam );
- render_world_fxglow( world, cam, layer_depth );
render_terrain( world, cam );
+ if( layer_depth == -1 ) return;
if( layer_depth == 0 ){
- skateshop_render();
+ world_entity_focus_render();
/* Render SFD's */
u32 closest = 0;
float min_dist = INFINITY;
- if( !mdl_arrcount( &world->ent_route ) )
- return;
-
- for( u32 i=0; i<mdl_arrcount( &world->ent_route ); i++ ){
- ent_route *route = mdl_arritm( &world->ent_route, i );
- float dist = v3_dist2( route->board_transform[3], cam->pos );
+ if( mdl_arrcount( &world->ent_route ) ){
+ for( u32 i=0; i<mdl_arrcount( &world->ent_route ); i++ ){
+ ent_route *route = mdl_arritm( &world->ent_route, i );
+ float dist = v3_dist2( route->board_transform[3], cam->pos );
- if( dist < min_dist ){
- min_dist = dist;
- closest = i;
+ if( dist < min_dist ){
+ min_dist = dist;
+ closest = i;
+ }
}
+
+ ent_route *route = mdl_arritm( &world->ent_route, closest );
+ sfd_render( world, cam, route->board_transform );
}
+ }
- ent_route *route = mdl_arritm( &world->ent_route, closest );
- sfd_render( world, cam, route->board_transform );
+ f32 greyout = 0.0f;
+ if( mdl_entity_id_type(world_static.focused_entity) == k_ent_challenge )
+ greyout = world_static.focus_strength;
+
+ if( greyout > 0.0f ){
+ glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
+ glEnable(GL_BLEND);
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendEquation(GL_FUNC_ADD);
+
+ shader_blitcolour_use();
+ shader_blitcolour_uColour( (v4f){ 0.5f, 0.5f, 0.5f, greyout*0.5f } );
+ render_fsquad();
+
+ glDisable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(GL_TRUE);
+ glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0,
+ GL_COLOR_ATTACHMENT1 } );
}
+
+ render_world_fxglow( world, cam, layer_depth );
}
VG_STATIC void render_cubemap_side( world_instance *world, ent_cubemap *cm,
int slot );
VG_STATIC void render_world_position( world_instance *world, camera *cam );
VG_STATIC void render_world_depth( world_instance *world, camera *cam );
-VG_STATIC void render_world( world_instance *world, camera *cam,
+VG_STATIC void render_world( world_instance *world, camera *cam,
int layer_depth );
VG_STATIC void render_world_cubemaps( world_instance *world );