[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 | {
|
---|
[520] | 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 );
|
---|
| 17 | m_materials = register_resource_handler< material >( new material_manager( clear_material_paths ) );
|
---|
| 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 ) );
|
---|
[508] | 21 | m_gpu_materials = register_resource_handler< gpu_material >( new gpu_material_manager( context, m_materials, m_images ) );
|
---|
[520] | 22 | m_models = register_resource_handler< model >( new model_manager( this, m_binds, m_mesh_datas ) );
|
---|
| 23 | m_particles = register_resource_handler< particle_system_data >( new particle_manager );
|
---|
| 24 | m_ragdolls = register_resource_handler< ragdoll_data >( new ragdoll_manager( m_models ) );
|
---|
[508] | 25 | }
|
---|
| 26 |
|
---|
[520] | 27 | void default_resource_manager::initialize( lua::state* lua, physics_world* world )
|
---|
[508] | 28 | {
|
---|
| 29 | m_lua = lua;
|
---|
| 30 |
|
---|
[512] | 31 | int below_already_registered;
|
---|
[509] | 32 | m_lua->register_enum( "RND_LINEAR", static_cast<int>( random_dist::LINEAR ) );
|
---|
| 33 | m_lua->register_enum( "RND_GAUSSIAN", static_cast<int>( random_dist::GAUSSIAN ) );
|
---|
| 34 | m_lua->register_enum( "RND_RGAUSSIAN", static_cast<int>( random_dist::RGAUSSIAN ) );
|
---|
| 35 | m_lua->register_enum( "RND_STEP_1", static_cast<int>( random_dist::STEP_1 ) );
|
---|
| 36 | m_lua->register_enum( "RND_STEP_2", static_cast<int>( random_dist::STEP_2 ) );
|
---|
| 37 | m_lua->register_enum( "RND_STEP_3", static_cast<int>( random_dist::STEP_3 ) );
|
---|
| 38 | m_lua->register_enum( "RND_STEP_4", static_cast<int>( random_dist::STEP_4 ) );
|
---|
| 39 | m_lua->register_enum( "RND_LINEAR", static_cast<int>( random_dist::LINEAR ) );
|
---|
| 40 | m_lua->register_enum( "RND_MGAUSSIAN", static_cast<int>( random_dist::MGAUSSIAN ) );
|
---|
| 41 | m_lua->register_enum( "RND_MRGAUSSIAN", static_cast<int>( random_dist::MRGAUSSIAN ) );
|
---|
| 42 | m_lua->register_enum( "RND_MSTEP_1", static_cast<int>( random_dist::MSTEP_1 ) );
|
---|
| 43 | m_lua->register_enum( "RND_MSTEP_2", static_cast<int>( random_dist::MSTEP_2 ) );
|
---|
| 44 | m_lua->register_enum( "RND_MSTEP_3", static_cast<int>( random_dist::MSTEP_3 ) );
|
---|
| 45 | m_lua->register_enum( "RND_MSTEP_4", static_cast<int>( random_dist::MSTEP_4 ) );
|
---|
| 46 |
|
---|
[508] | 47 | m_lua->register_enum( "INT_NONE", static_cast<int>( interpolation::NONE ) );
|
---|
| 48 | m_lua->register_enum( "INT_LINEAR", static_cast<int>( interpolation::LINEAR ) );
|
---|
| 49 | m_lua->register_enum( "INT_NORMALIZED", static_cast<int>( interpolation::NORMALIZED ) );
|
---|
| 50 | m_lua->register_enum( "INT_SPHERICAL", static_cast<int>( interpolation::SPHERICAL ) );
|
---|
| 51 | m_lua->register_enum( "INT_QUADRATIC", static_cast<int>( interpolation::QUADRATIC ) );
|
---|
| 52 | m_lua->register_enum( "INT_SQUADRATIC", static_cast<int>( interpolation::SQUADRATIC ) );
|
---|
| 53 |
|
---|
| 54 | m_lua->register_enum( "EASING_BACK", static_cast<int>( easing_type::BACK ) );
|
---|
| 55 | m_lua->register_enum( "EASING_BOUNCE", static_cast<int>( easing_type::BOUNCE ) );
|
---|
| 56 | m_lua->register_enum( "EASING_CIRC", static_cast<int>( easing_type::CIRC ) );
|
---|
| 57 | m_lua->register_enum( "EASING_CUBIC", static_cast<int>( easing_type::CUBIC ) );
|
---|
| 58 | m_lua->register_enum( "EASING_ELASTIC", static_cast<int>( easing_type::ELASTIC ) );
|
---|
| 59 | m_lua->register_enum( "EASING_EXPO", static_cast<int>( easing_type::EXPO ) );
|
---|
| 60 | m_lua->register_enum( "EASING_LINEAR", static_cast<int>( easing_type::LINEAR ) );
|
---|
| 61 | m_lua->register_enum( "EASING_QUAD", static_cast<int>( easing_type::QUAD ) );
|
---|
| 62 | m_lua->register_enum( "EASING_QUART", static_cast<int>( easing_type::QUART ) );
|
---|
| 63 | m_lua->register_enum( "EASING_QUINT", static_cast<int>( easing_type::QUINT ) );
|
---|
| 64 | m_lua->register_enum( "EASING_SINE", static_cast<int>( easing_type::SINE ) );
|
---|
| 65 |
|
---|
[510] | 66 | m_lua->register_enum( "CHOICE_ALL", static_cast<int>( model_node_choice::ALL ) );
|
---|
| 67 | m_lua->register_enum( "CHOICE_WEIGHTED", static_cast<int>( model_node_choice::WEIGHTED ) );
|
---|
| 68 | m_lua->register_enum( "CHOICE_PATTERN_CHECKER", static_cast<int>( model_node_choice::PATTERN_CHECKER ) );
|
---|
| 69 |
|
---|
[508] | 70 | m_materials->initialize( lua );
|
---|
| 71 | m_programs->initialize( lua );
|
---|
| 72 | m_animators->initialize( lua );
|
---|
| 73 | m_models->initialize( lua );
|
---|
[518] | 74 | m_particles->initialize( lua );
|
---|
[520] | 75 | m_ragdolls->initialize( lua );
|
---|
| 76 | m_ragdolls->initialize( world );
|
---|
[508] | 77 | }
|
---|
| 78 |
|
---|
| 79 | void default_resource_manager::reload_data()
|
---|
| 80 | {
|
---|
| 81 | m_materials->clear();
|
---|
| 82 | m_materials->load_all();
|
---|
| 83 | // m_models->load_all();
|
---|
| 84 | // m_programs->load_all();
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | void nv::default_resource_manager::add_path( const string_view& path )
|
---|
| 88 | {
|
---|
| 89 | m_images->add_base_path( path );
|
---|
| 90 | m_mesh_datas->add_base_path( path );
|
---|
| 91 | m_programs->add_base_path( path );
|
---|
| 92 | m_animators->add_base_path( path );
|
---|
| 93 | }
|
---|