Changeset 509 for trunk/src/engine


Ignore:
Timestamp:
07/26/16 20:24:02 (9 years ago)
Author:
epyon
Message:
  • random distributions
  • resource - rename/remove support
  • debug gizmo support
  • minor resource_manager upgrades
  • several minor changes
Location:
trunk/src/engine
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine/animation.cc

    r508 r509  
    3434
    3535        nv::animator_data* animator = new nv::animator_data;
     36        animator->id = table.get_string64( "id" );
    3637        animator->poses = poses;
    3738        if ( poses == nullptr )
  • trunk/src/engine/default_resource_manager.cc

    r508 r509  
    99using namespace nv;
    1010
    11 default_resource_manager::default_resource_manager( context* context )
     11default_resource_manager::default_resource_manager( context* context, bool clear_material_paths )
    1212{
    1313        m_images        = register_resource_handler< image_data >( new image_manager );
     
    1515        m_binds         = register_resource_handler< animator_bind_data >( new animator_bind_manager );
    1616        m_animators     = register_resource_handler< animator_data >( new animator_manager );
    17         m_materials     = register_resource_handler< material >( new material_manager );
     17        m_materials     = register_resource_handler< material >( new material_manager( clear_material_paths ) );
    1818        m_programs      = register_resource_handler< program >( new program_manager( context ) );
    1919        m_gpu_meshes    = register_resource_handler< gpu_mesh >( new gpu_mesh_manager( context, m_meshes ) );
     
    2727        m_lua = lua;
    2828
     29        m_lua->register_enum( "RND_LINEAR",     static_cast<int>( random_dist::LINEAR ) );
     30        m_lua->register_enum( "RND_GAUSSIAN",   static_cast<int>( random_dist::GAUSSIAN ) );
     31        m_lua->register_enum( "RND_RGAUSSIAN",  static_cast<int>( random_dist::RGAUSSIAN ) );
     32        m_lua->register_enum( "RND_STEP_1",     static_cast<int>( random_dist::STEP_1 ) );
     33        m_lua->register_enum( "RND_STEP_2",     static_cast<int>( random_dist::STEP_2 ) );
     34        m_lua->register_enum( "RND_STEP_3",     static_cast<int>( random_dist::STEP_3 ) );
     35        m_lua->register_enum( "RND_STEP_4",     static_cast<int>( random_dist::STEP_4 ) );
     36        m_lua->register_enum( "RND_LINEAR",     static_cast<int>( random_dist::LINEAR ) );
     37        m_lua->register_enum( "RND_MGAUSSIAN",  static_cast<int>( random_dist::MGAUSSIAN ) );
     38        m_lua->register_enum( "RND_MRGAUSSIAN", static_cast<int>( random_dist::MRGAUSSIAN ) );
     39        m_lua->register_enum( "RND_MSTEP_1",    static_cast<int>( random_dist::MSTEP_1 ) );
     40        m_lua->register_enum( "RND_MSTEP_2",    static_cast<int>( random_dist::MSTEP_2 ) );
     41        m_lua->register_enum( "RND_MSTEP_3",    static_cast<int>( random_dist::MSTEP_3 ) );
     42        m_lua->register_enum( "RND_MSTEP_4",    static_cast<int>( random_dist::MSTEP_4 ) );
     43       
    2944        m_lua->register_enum( "INT_NONE",       static_cast<int>( interpolation::NONE ) );
    3045        m_lua->register_enum( "INT_LINEAR",     static_cast<int>( interpolation::LINEAR ) );
  • trunk/src/engine/material_manager.cc

    r508 r509  
    6363        if ( table.is_string( "path" ) )
    6464        {
     65                m->id = table.get_string128( "id" );
    6566                string128 path = table.get_string128( "path" );
    6667                for ( uint32 i = 0; i < 5; ++i )
     
    7778                                if ( i != TEX_EMISSIVE )
    7879                                        NV_LOG_ERROR( "Texture file not found! : ", m->paths[i] );
    79                                 //m->paths[i].clear();
     80                                if ( m_clear_paths )
     81                                        m->paths[i].clear();
    8082                        }
    8183                }
  • trunk/src/engine/mesh_manager.cc

    r508 r509  
    114114                        result->node_names[(*nd)[i].name] = i;
    115115        }
     116       
     117        resource< mesh_data > rmesh = add( id, result );
     118
    116119        for ( uint32 i = 0; i < loader->get_mesh_count(); ++i )
    117120        {
     
    122125                auto mesh = m_mesh_manager->add( shash64( id.get_hash() + i ), data );
    123126                result->meshes.push_back( mesh );
     127                m_source_map[mesh.id()] = mesh_source{ rmesh, i };
    124128        }
     129        result->path.assign( id );
    125130        delete loader;
    126         if ( result )
    127                 add( id, result );
    128131        return result != nullptr;
    129132}
  • trunk/src/engine/model_manager.cc

    r508 r509  
    1313bool nv::model_manager::load_resource( lua::table_guard& table, shash64 id )
    1414{
     15        auto vec4_to_quat = [] ( const vec4& v ) { return quat( v.w, v.x, v.y, v.z ); };
     16
    1517        model* gm = new model;
    1618        gm->attach = table.get_string_hash_64( "attach" );
    17         gm->root = transform( table.get<vec3>( "position", vec3() ) );
    18 
     19        gm->root.set_position( table.get<vec3>( "root_position", vec3() ) );
     20        gm->root.set_orientation( vec4_to_quat( table.get<vec4>( "root_orientation", vec4(0.0f,0.0f,0.0f,1.0f) ) ) );
     21       
    1922        resource< mesh_data > def_data;
    2023        if ( table.is_string( "path" ) )
     
    4548void nv::model_manager::read_model_node( lua::table_guard& table, model_node* node, resource< mesh_data > def_data )
    4649{
     50        auto vec4_to_quat = [] ( const vec4& v ) { return quat( v.w, v.x, v.y, v.z ); };
     51
    4752        resource< data_channel_set > cmesh;
    4853        resource< material >         cmaterial;
     
    5964                attach_id = info.parent_id;
    6065        }
     66
     67        if ( table.has_field( "local_position" ) )
     68                node->local.set_position( table.get<vec3>( "local_position", vec3() ) );
     69        if ( table.has_field( "local_orientation" ) )
     70                node->local.set_orientation( vec4_to_quat( table.get<vec4>( "local_orientation", vec4( 0.0f, 0.0f, 0.0f, 1.0f ) ) ) );
     71
     72        if ( table.has_field( "position" ) )
     73        {
     74                node->position.min = table.get<vec3>( "position", vec3() );
     75                node->position.max = node->position.min;
     76        }
     77        if ( table.has_field( "rotation" ) )
     78        {
     79                node->rotation.min = table.get<vec3>( "rotation", vec3() );
     80                node->rotation.max = node->rotation.min;
     81        }
     82        if ( table.has_field( "position_min" ) )  node->position.min  = table.get<vec3>( "position_min", vec3() );
     83        if ( table.has_field( "position_max" ) )  node->position.max  = table.get<vec3>( "position_max", vec3() );
     84        if ( table.has_field( "position_dist" ) ) node->position.dist = random_dist( table.get_unsigned( "position_dist", 0 ) );
     85        if ( table.has_field( "rotation_min" ) )  node->rotation.min  = table.get<vec3>( "rotation_min", vec3() );
     86        if ( table.has_field( "rotation_max" ) )  node->rotation.max  = table.get<vec3>( "rotation_max", vec3() );
     87        if ( table.has_field( "rotation_dist" ) ) node->rotation.dist = random_dist( table.get_unsigned( "rotation_dist", 0 ) );
    6188
    6289        if ( table.has_field( "attach" ) )
     
    76103        }
    77104
    78         node->force = table.get_boolean( "force", false );
    79         node->chance = table.get_float( "chance", 1.0f );
    80         node->random_rotate_y = table.get_boolean( "random_rotate", false );
    81 
    82         node->mesh = cmesh;
     105        node->force     = table.get_boolean( "force", false );
     106        node->choice    = table.get_boolean( "choice", false );
     107        node->chance    = table.get_float( "chance", 1.0f );
     108        node->weight    = table.get_unsigned( "weight", 1 );
     109        node->mesh      = cmesh;
    83110        node->attach_id = attach_id;
    84         node->material = cmaterial;
     111        node->material  = cmaterial;
    85112
    86113        for ( uint32 i = 1; i <= table.get_size(); ++i )
Note: See TracChangeset for help on using the changeset viewer.