[508] | 1 | // Copyright (C) 2016-2016 ChaosForge Ltd
|
---|
| 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
| 4 | // This file is part of Nova libraries.
|
---|
| 5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
| 6 |
|
---|
| 7 | #include "nv/engine/default_resource_manager.hh"
|
---|
| 8 |
|
---|
| 9 | using namespace nv;
|
---|
| 10 |
|
---|
[509] | 11 | default_resource_manager::default_resource_manager( context* context, bool clear_material_paths )
|
---|
[508] | 12 | {
|
---|
| 13 | m_images = register_resource_handler< image_data >( new image_manager );
|
---|
| 14 | m_meshes = register_resource_handler< data_channel_set >( new mesh_manager );
|
---|
| 15 | m_binds = register_resource_handler< animator_bind_data >( new animator_bind_manager );
|
---|
| 16 | m_animators = register_resource_handler< animator_data >( new animator_manager );
|
---|
[509] | 17 | m_materials = register_resource_handler< material >( new material_manager( clear_material_paths ) );
|
---|
[508] | 18 | m_programs = register_resource_handler< program >( new program_manager( context ) );
|
---|
| 19 | m_gpu_meshes = register_resource_handler< gpu_mesh >( new gpu_mesh_manager( context, m_meshes ) );
|
---|
| 20 | m_mesh_datas = register_resource_handler< mesh_data >( new mesh_data_manager( m_meshes ) );
|
---|
| 21 | m_gpu_materials = register_resource_handler< gpu_material >( new gpu_material_manager( context, m_materials, m_images ) );
|
---|
| 22 | m_models = register_resource_handler< model >( new model_manager( this, m_binds, m_mesh_datas ) );
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | void default_resource_manager::initialize( lua::state* lua )
|
---|
| 26 | {
|
---|
| 27 | m_lua = lua;
|
---|
| 28 |
|
---|
[509] | 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 |
|
---|
[508] | 44 | m_lua->register_enum( "INT_NONE", static_cast<int>( interpolation::NONE ) );
|
---|
| 45 | m_lua->register_enum( "INT_LINEAR", static_cast<int>( interpolation::LINEAR ) );
|
---|
| 46 | m_lua->register_enum( "INT_NORMALIZED", static_cast<int>( interpolation::NORMALIZED ) );
|
---|
| 47 | m_lua->register_enum( "INT_SPHERICAL", static_cast<int>( interpolation::SPHERICAL ) );
|
---|
| 48 | m_lua->register_enum( "INT_QUADRATIC", static_cast<int>( interpolation::QUADRATIC ) );
|
---|
| 49 | m_lua->register_enum( "INT_SQUADRATIC", static_cast<int>( interpolation::SQUADRATIC ) );
|
---|
| 50 |
|
---|
| 51 | m_lua->register_enum( "EASING_BACK", static_cast<int>( easing_type::BACK ) );
|
---|
| 52 | m_lua->register_enum( "EASING_BOUNCE", static_cast<int>( easing_type::BOUNCE ) );
|
---|
| 53 | m_lua->register_enum( "EASING_CIRC", static_cast<int>( easing_type::CIRC ) );
|
---|
| 54 | m_lua->register_enum( "EASING_CUBIC", static_cast<int>( easing_type::CUBIC ) );
|
---|
| 55 | m_lua->register_enum( "EASING_ELASTIC", static_cast<int>( easing_type::ELASTIC ) );
|
---|
| 56 | m_lua->register_enum( "EASING_EXPO", static_cast<int>( easing_type::EXPO ) );
|
---|
| 57 | m_lua->register_enum( "EASING_LINEAR", static_cast<int>( easing_type::LINEAR ) );
|
---|
| 58 | m_lua->register_enum( "EASING_QUAD", static_cast<int>( easing_type::QUAD ) );
|
---|
| 59 | m_lua->register_enum( "EASING_QUART", static_cast<int>( easing_type::QUART ) );
|
---|
| 60 | m_lua->register_enum( "EASING_QUINT", static_cast<int>( easing_type::QUINT ) );
|
---|
| 61 | m_lua->register_enum( "EASING_SINE", static_cast<int>( easing_type::SINE ) );
|
---|
| 62 |
|
---|
[510] | 63 | m_lua->register_enum( "CHOICE_ALL", static_cast<int>( model_node_choice::ALL ) );
|
---|
| 64 | m_lua->register_enum( "CHOICE_WEIGHTED", static_cast<int>( model_node_choice::WEIGHTED ) );
|
---|
| 65 | m_lua->register_enum( "CHOICE_PATTERN_CHECKER", static_cast<int>( model_node_choice::PATTERN_CHECKER ) );
|
---|
| 66 |
|
---|
[508] | 67 | m_materials->initialize( lua );
|
---|
| 68 | m_programs->initialize( lua );
|
---|
| 69 | m_animators->initialize( lua );
|
---|
| 70 | m_models->initialize( lua );
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | void default_resource_manager::reload_data()
|
---|
| 74 | {
|
---|
| 75 | m_materials->clear();
|
---|
| 76 | m_materials->load_all();
|
---|
| 77 | // m_models->load_all();
|
---|
| 78 | // m_programs->load_all();
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | void nv::default_resource_manager::add_path( const string_view& path )
|
---|
| 82 | {
|
---|
| 83 | m_images->add_base_path( path );
|
---|
| 84 | m_mesh_datas->add_base_path( path );
|
---|
| 85 | m_programs->add_base_path( path );
|
---|
| 86 | m_animators->add_base_path( path );
|
---|
| 87 | }
|
---|