challange entitites
authorhgn <hgodden00@gmail.com>
Thu, 13 Jul 2023 15:16:52 +0000 (16:16 +0100)
committerhgn <hgodden00@gmail.com>
Thu, 13 Jul 2023 15:16:52 +0000 (16:16 +0100)
blender_export.py
entity.h
maps_src/mp_spawn/main.mdl
shaders/scene_fxglow.fs
shaders/scene_fxglow.h
skaterift.c
world.h
world_load.c
world_render.c

index 2b059d9730b125ccba52973a9c1cb8145ce80bec..ae8b641b3db7963004c5f706cc425e1dd1b0ac08 100644 (file)
@@ -35,7 +35,8 @@ sr_entity_list = [
    ('ent_swspreview', 'Workshop Preview', '', 14 ),
    ('ent_menuitem',     'Menu Item',      '', 15 ),
    ('ent_worldinfo',    'World Info',     '', 16 ),
-   ('ent_ccmd',         'CCmd',           '', 17 )
+   ('ent_ccmd',         'CCmd',           '', 17 ),
+   ('ent_challenge',    'Challenge',      '', 18 )
 ]
 
 def get_entity_enum_id( alias ):
@@ -445,6 +446,13 @@ class ent_ccmd(Structure):
    _fields_ = [("pstr_command",c_uint32)]
 #}
 
+class ent_challenge(Structure):#{
+   _fields_ = [("transform",mdl_transform),
+               ("submesh_start",c_uint32), ("submesh_count",c_uint32),
+               ("id_next",c_uint32),
+               ("filter",c_uint32)]
+#}
+
 def obj_ent_type( obj ):
 #{
    if obj.type == 'ARMATURE': return 'mdl_armature'
@@ -793,8 +801,9 @@ def sr_armature_bones( armature ):
          yield from _recurse_bone( b )
 #}
 
-def sr_entity_id( obj ):
-#{
+def sr_entity_id( obj ):#{
+   if not obj: return 0
+   
    tipo = get_entity_enum_id( obj_ent_type(obj) )
    index = sr_compile.entity_ids[ obj.name ]
 
@@ -1531,6 +1540,7 @@ def sr_compile( collection ):
          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
          #--------------------------
 
          print( F'[SR] {i: 3}/{mesh_count} {obj.name:<40}', end='\r' )
@@ -1743,6 +1753,17 @@ def sr_compile( collection ):
             ccmd.pstr_command = sr_compile_string( obj_data.command )
             sr_ent_push( ccmd )
          #}
+         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 )
+
+            compile_obj_transform( obj, challenge.transform )
+            challenge.submesh_start, challenge.submesh_count, _ = \
+                  sr_compile_mesh_internal( obj )
+
+            sr_ent_push( challenge )
+         #}
       #}
    #}
 
@@ -2982,6 +3003,16 @@ class SR_OBJECT_ENT_CCMD(bpy.types.PropertyGroup):
    command: bpy.props.StringProperty(name="Command Line")
 #}
 
+class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
+   proxima: bpy.props.PointerProperty( \
+            type=bpy.types.Object, name="Next", \
+            poll=lambda self,obj: sr_filter_ent_type(obj,['ent_challenge']))
+   target: bpy.props.PointerProperty( \
+           type=bpy.types.Object, name="Target", \
+           poll=lambda self,obj: sr_filter_ent_type(obj,\
+                                    ['ent_audio','ent_ccmd']))
+#}
+
 class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
 #{
    ent_gate: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_GATE)
@@ -2999,6 +3030,7 @@ class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
    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_challenge: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CHALLENGE)
 
    ent_type: bpy.props.EnumProperty(
       name="Type",
@@ -4121,6 +4153,7 @@ classes = [ SR_INTERFACE, SR_MATERIAL_PANEL,\
             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_PROPERTIES, SR_LIGHT_PROPERTIES, SR_BONE_PROPERTIES, 
             SR_MESH_PROPERTIES, SR_MATERIAL_PROPERTIES \
index 7143a4130aaccadaa905fa55eaceebf664785f6a..487c4d390042104ca7fa133922fd7419c9840ee7 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -26,6 +26,7 @@ typedef struct ent_camera ent_camera;
 typedef struct ent_swspreview ent_swspreview;
 typedef struct ent_worldinfo ent_worldinfo;
 typedef struct ent_ccmd ent_ccmd;
+typedef struct ent_challenge ent_challenge;
 
 enum entity_alias{
    k_ent_none        = 0,
@@ -45,7 +46,8 @@ enum entity_alias{
    k_ent_swspreview  = 14,
    k_ent_menuitem    = 15,
    k_ent_worldinfo   = 16,
-   k_ent_ccmd        = 17
+   k_ent_ccmd        = 17,
+   k_ent_challenge   = 18
 };
 
 static u32 mdl_entity_id_type( u32 entity_id ){
@@ -378,6 +380,14 @@ struct ent_ccmd{
    u32 pstr_command;
 };
 
+struct ent_challenge{
+   mdl_transform transform;
+   u32 submesh_start,
+       submesh_count,
+       id_next,
+       filter;
+};
+
 typedef struct ent_call ent_call;
 struct ent_call{
    u32 id, function;
index bbb3004225d647fa5e265224734508cfa12d4503..f54719a991f9a0a29885410f10feb5ee5b6000a2 100644 (file)
Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ
index 6d7df91cc91b7eb0d1d4498aa7c8311693cc142f..5d1a5bbd769ca385427e5964469010663c3ac1b3 100644 (file)
@@ -4,9 +4,8 @@ uniform vec3 uCamera;
 #include "common_scene.glsl"
 #include "motion_vectors_fs.glsl"
 
-void main()
-{
-   compute_motion_vectors();
+void main(){
+   oMotionVec = vec2(0.0);
 
    vec4 vsamplemain = texture( uTexMain, aUv );
 
index e67c665709aa28ad647d1ff36a8cc089161cd0f9..3f5e0c69d0fe4e2ea8ba529d978af336980aeae2 100644 (file)
@@ -424,9 +424,8 @@ static struct vg_shader _shader_scene_fxglow = {
 "\n"
 "#line      6        0 \n"
 "\n"
-"void main()\n"
-"{\n"
-"   compute_motion_vectors();\n"
+"void main(){\n"
+"   oMotionVec = vec2(0.0);\n"
 "\n"
 "   vec4 vsamplemain = texture( uTexMain, aUv );\n"
 "\n"
index fa9459ca3557dbe235f965d72d713906ec7a369c..a575fc5486ca422850f9d77f7a1239454e2436cc 100644 (file)
@@ -411,16 +411,10 @@ VG_STATIC void render_player_transparent(void){
    camera_finalize( &small_cam );
 
    /* Draw player to window buffer and blend background ontop */
-   glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-   glViewport( 0,0, vg.window_x, vg.window_y );
    player__render( &small_cam, &localplayer );
 }
 
 VG_STATIC void render_scene(void){
-   render_fb_bind( gpipeline.fb_main, 1 );
-   glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
-   glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );
-
    /* Draw world */
    glEnable( GL_DEPTH_TEST );
 
@@ -493,15 +487,34 @@ VG_STATIC void render_main_game(void){
 
    skaterift_composite_maincamera();
 
-   render_scene();
+   /* --------------------------------------------------------------------- */
+
+   /* variable res target */
+   render_fb_bind( gpipeline.fb_main, 1 );
+   glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
+   glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );
 
+   render_scene();
    glEnable( GL_DEPTH_TEST );
 
-   render_player_transparent();
+   /* full res target */
+   glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+   glViewport( 0,0, vg.window_x, vg.window_y );
+
+   render_player_transparent(); /* needs to read the depth buffer before we fuck
+                                   it up with the oblique rendering inside the
+                                   portals */
+
+   world_render_challenges( localplayer.viewable_world );
+
+   /* continue with variable rate */
    render_scene_gate_subview();
 
+   /* composite */
    present_view_with_post_processing();
 
+   /* --------------------------------------------------------------------- */
+
    /* capture the current resume frame at the very last point */
    if( button_down( k_srbind_reset ) ){
       if( skaterift.activity == k_skaterift_default ){
diff --git a/world.h b/world.h
index ddb82e1be7c2b0e7547e14eea9d3ee3f6d876a75..7d513f9d0a768043cc7d3a63531614ab83cbb5b3 100644 (file)
--- a/world.h
+++ b/world.h
@@ -155,7 +155,8 @@ struct world_instance {
                  ent_marker,
                  ent_camera,
                  ent_swspreview,
-                 ent_ccmd;
+                 ent_ccmd,
+                 ent_challenge;
 
    ent_gate *rendering_gate;
 
index bbf5c91510c5a7d0b488b360f30b4479686b807f..9ca847c85d191f09707a7bd6a2fca92e38307b0f 100644 (file)
@@ -59,6 +59,7 @@ VG_STATIC void world_load_mdl( const char *path )
    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_challenge, "ent_challenge",  heap );
 
    mdl_array_ptr infos;
    mdl_load_array( meta, &infos, "ent_worldinfo", vg_mem.scratch );
index c332aced5431851cb0b0bf17e14e5c962e6a1547..950e35fe8855aa08ca12b1e649ecde3bd827a58f 100644 (file)
@@ -154,7 +154,10 @@ struct world_pass{
    void (*fn_set_uPvmPrev)( m4x4f pvm );
 };
 
-VG_STATIC void world_render_if( world_instance *world, struct world_pass *pass )
+/* TODO: high level control pass renders. */
+
+VG_STATIC 
+void world_render_if( world_instance *world, struct world_pass *pass )
 {
    for( int i=0; i<world->surface_count; i++ ){
       struct world_surface *mat = &world->surfaces[i];
@@ -202,6 +205,20 @@ VG_STATIC void world_render_if( world_instance *world, struct world_pass *pass )
    }
 }
 
+VG_STATIC
+void world_render_challenges( world_instance *world ){
+   if( !world ) return;
+
+   shader_scene_fxglow_use();
+   for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+      ent_challenge *challenge = mdl_arritm(&world->ent_challenge,i);
+      
+      m4x3f mmdl;
+      mdl_transform_m4x3( &challenge->transform, mmdl );
+      shader_scene_fxglow_uMdl( mmdl );
+   }
+}
+
 VG_STATIC 
 void world_render_both_stages( world_instance *world, struct world_pass *pass )
 {
@@ -320,7 +337,7 @@ VG_STATIC void render_world_alphatest( world_instance *world, camera *cam )
 }
 
 VG_STATIC void render_world_fxglow( world_instance *world, camera *cam ){
-   glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
+   //glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
 
    shader_scene_fxglow_use();
    shader_scene_fxglow_uTexMain(1);
@@ -348,7 +365,7 @@ VG_STATIC void render_world_fxglow( world_instance *world, camera *cam ){
    world_render_both_stages( world, &pass );
 
    glEnable(GL_CULL_FACE);
-   glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 } );
+   //glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 } );
 }
 
 VG_STATIC void bindpoint_terrain( world_instance *world,