unlock rendering
authorhgn <hgodden00@gmail.com>
Mon, 7 Aug 2023 17:54:34 +0000 (18:54 +0100)
committerhgn <hgodden00@gmail.com>
Mon, 7 Aug 2023 17:54:34 +0000 (18:54 +0100)
blender_export.py
entity.h
maps_src/mp_spawn/main.mdl
shaders/model_font.fs
shaders/model_font.h
world_entity.c
world_render.c

index 70bb5ef494d9db15433bd6159e945fde98a4bdb5..52f674f73ba4042a0b308ce01822e23daeb42bb5 100644 (file)
@@ -476,7 +476,8 @@ class ent_challenge(Structure):#{
 #}
 
 class ent_unlock(Structure):#{
-   _fields_ = [("pstr_alias",c_uint32),
+   _fields_ = [("transform",mdl_transform),
+               ("pstr_alias",c_uint32),
                ("target",c_uint32),
                ("target_event",c_uint32),
                ("status",c_uint32)]
@@ -1874,6 +1875,7 @@ def sr_compile( collection ):
          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
index 9e0424fc8704684d1abfde4bbc429e70bfca7593..8920eef3ab5fed3438bf145d53c35222b489a66a 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -440,6 +440,7 @@ struct ent_challenge{
 };
 
 struct ent_unlock{
+   mdl_transform transform;
    u32 pstr_alias,
        target,
        target_event,
index fcd2e0ac4af4797c8e40807158d3cb7caf410968..6c489f8bbf0592fffd58110788b0bc065d2c2dbd 100644 (file)
Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ
index 31e4e8dd39b6e9fe0a1d3ff6e2f5f0cdc33cce9d..d2f1438d5701fd643ccce26b3df64c4b1b1d71b7 100644 (file)
@@ -1,4 +1,4 @@
-out vec4 FragColor;
+layout (location = 0) out vec4 oColour;
 
 uniform sampler2D uTexMain;
 uniform vec4 uColour;
@@ -13,5 +13,5 @@ in vec3 aCo;
 void main()
 {
    compute_motion_vectors();
-   FragColor = texture( uTexMain, aUv ) * uColour;
+   oColour = texture( uTexMain, aUv ) * uColour;
 }
index 65d53e3f83d1a1a43d97cdbb0661af2643e5a1cb..6c6027d62df129c4cd0b6e70e48bc21d67ff5497 100644 (file)
@@ -68,7 +68,7 @@ static struct vg_shader _shader_model_font = {
 {
 .orig_file = "shaders/model_font.fs",
 .static_src = 
-"out vec4 FragColor;\n"
+"layout (location = 0) out vec4 oColour;\n"
 "\n"
 "uniform sampler2D uTexMain;\n"
 "uniform vec4 uColour;\n"
@@ -102,7 +102,7 @@ static struct vg_shader _shader_model_font = {
 "void main()\n"
 "{\n"
 "   compute_motion_vectors();\n"
-"   FragColor = texture( uTexMain, aUv ) * uColour;\n"
+"   oColour = texture( uTexMain, aUv ) * uColour;\n"
 "}\n"
 ""},
 };
index b95961df49060157c39361bde609f4d9b7ff0195..5ec52f774dd8b983c25a23a0148bea53407e2d01 100644 (file)
@@ -97,7 +97,8 @@ VG_STATIC void world_gen_entities_init( world_instance *world ){
    indexables[] = {
       { k_ent_gate, &world->ent_gate },
       { k_ent_challenge, &world->ent_challenge },
-      { k_ent_volume, &world->ent_volume }
+      { k_ent_volume, &world->ent_volume },
+      { k_ent_unlock, &world->ent_unlock }
    };
 
    for( u32 i=0; i<vg_list_size(indexables); i++ )
@@ -360,6 +361,10 @@ VG_STATIC float entity_bh_centroid( void *user, u32 item_index, int axis ){
       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 {
       vg_fatal_error( "Programming error\n" );
       return INFINITY;
index 0b5b399303bf3039db9d70928c1631ed14509984..ec2ec8a263bfa206557edcbbcb2aff1fb0b0d391 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "world.h"
 #include "world_render.h"
+#include "font.h"
+#include "gui.h"
 
 static int ccmd_set_time( int argc, const char *argv[] ){
    if( argc == 1 ){
@@ -410,28 +412,43 @@ VG_STATIC void render_world_alphatest( world_instance *world, camera *cam ){
 
 VG_STATIC
 void world_render_challenges( world_instance *world, struct world_pass *pass,
-                              v3f pos ){
+                              v3f pos, int layer_depth ){
    if( !world ) return;
 
-   glDisable( GL_CULL_FACE );
-   mesh_bind( &world->mesh_no_collide );
-
-   u32 last_material = 0;
-
+   /* sort lists */
    const f32 radius = 40.0f;
-
    bh_iter it;
    bh_iter_init_range( 0, &it, pos, radius );
    i32 idx;
 
+   u32 challenge_list[ 32 ],
+       unlock_list[ 32 ];
+
+   u32 challenge_count = 0,
+       unlock_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 ) continue;
+      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;
+      }
+   }
 
-      ent_challenge *challenge = mdl_arritm(&world->ent_challenge,index);
+   /* render challenges */
+   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;
 
       f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius),
@@ -456,11 +473,22 @@ void world_render_challenges( world_instance *world, struct world_pass *pass,
          mdl_draw_submesh( sm );
       }
    }
-}
 
-VG_STATIC void render_world_fxglow( world_instance *world, camera *cam ){
-   //glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
+   /* render texts */
+   font3d_bind( &gui.font, &skaterift.cam );
+   shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} );
+
+   for( u32 i=0; i<unlock_count; i++ ){
+      u32 index = unlock_list[ i ];
+      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+      m4x3f mmdl;
+      mdl_transform_m4x3( &unlock->transform, mmdl );
+      font3d_simple_draw( &gui.font, 0, "Test!", &skaterift.cam, mmdl );
+   }
+}
 
+VG_STATIC void render_world_fxglow( world_instance *world, camera *cam,
+                                    int layer_depth ){
    shader_scene_fxglow_use();
    shader_scene_fxglow_uTexMain(1);
    shader_scene_fxglow_uPv( cam->mtx.pv );
@@ -485,10 +513,9 @@ VG_STATIC void render_world_fxglow( world_instance *world, camera *cam ){
    };
 
    world_render_both_stages( world, &pass );
-   world_render_challenges( world, &pass, cam->pos );
+   world_render_challenges( world, &pass, cam->pos, layer_depth );
 
    glEnable(GL_CULL_FACE);
-   //glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 } );
 }
 
 VG_STATIC void bindpoint_terrain( world_instance *world,
@@ -678,7 +705,7 @@ VG_STATIC void render_world( world_instance *world, camera *cam,
 
    render_world_vb( world, cam );
    render_world_alphatest( world, cam );
-   render_world_fxglow( world, cam );
+   render_world_fxglow( world, cam, layer_depth );
    render_terrain( world, cam );
 
    if( layer_depth == 0 ){