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 |
|
---|
11 | default_resource_manager::default_resource_manager( context* context, bool clear_material_paths )
|
---|
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 );
|
---|
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 ) );
|
---|
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 |
|
---|
29 | int below_already_registered;
|
---|
30 | m_lua->register_enum( "RND_LINEAR", static_cast<int>( random_dist::LINEAR ) );
|
---|
31 | m_lua->register_enum( "RND_GAUSSIAN", static_cast<int>( random_dist::GAUSSIAN ) );
|
---|
32 | m_lua->register_enum( "RND_RGAUSSIAN", static_cast<int>( random_dist::RGAUSSIAN ) );
|
---|
33 | m_lua->register_enum( "RND_STEP_1", static_cast<int>( random_dist::STEP_1 ) );
|
---|
34 | m_lua->register_enum( "RND_STEP_2", static_cast<int>( random_dist::STEP_2 ) );
|
---|
35 | m_lua->register_enum( "RND_STEP_3", static_cast<int>( random_dist::STEP_3 ) );
|
---|
36 | m_lua->register_enum( "RND_STEP_4", static_cast<int>( random_dist::STEP_4 ) );
|
---|
37 | m_lua->register_enum( "RND_LINEAR", static_cast<int>( random_dist::LINEAR ) );
|
---|
38 | m_lua->register_enum( "RND_MGAUSSIAN", static_cast<int>( random_dist::MGAUSSIAN ) );
|
---|
39 | m_lua->register_enum( "RND_MRGAUSSIAN", static_cast<int>( random_dist::MRGAUSSIAN ) );
|
---|
40 | m_lua->register_enum( "RND_MSTEP_1", static_cast<int>( random_dist::MSTEP_1 ) );
|
---|
41 | m_lua->register_enum( "RND_MSTEP_2", static_cast<int>( random_dist::MSTEP_2 ) );
|
---|
42 | m_lua->register_enum( "RND_MSTEP_3", static_cast<int>( random_dist::MSTEP_3 ) );
|
---|
43 | m_lua->register_enum( "RND_MSTEP_4", static_cast<int>( random_dist::MSTEP_4 ) );
|
---|
44 |
|
---|
45 | m_lua->register_enum( "INT_NONE", static_cast<int>( interpolation::NONE ) );
|
---|
46 | m_lua->register_enum( "INT_LINEAR", static_cast<int>( interpolation::LINEAR ) );
|
---|
47 | m_lua->register_enum( "INT_NORMALIZED", static_cast<int>( interpolation::NORMALIZED ) );
|
---|
48 | m_lua->register_enum( "INT_SPHERICAL", static_cast<int>( interpolation::SPHERICAL ) );
|
---|
49 | m_lua->register_enum( "INT_QUADRATIC", static_cast<int>( interpolation::QUADRATIC ) );
|
---|
50 | m_lua->register_enum( "INT_SQUADRATIC", static_cast<int>( interpolation::SQUADRATIC ) );
|
---|
51 |
|
---|
52 | m_lua->register_enum( "EASING_BACK", static_cast<int>( easing_type::BACK ) );
|
---|
53 | m_lua->register_enum( "EASING_BOUNCE", static_cast<int>( easing_type::BOUNCE ) );
|
---|
54 | m_lua->register_enum( "EASING_CIRC", static_cast<int>( easing_type::CIRC ) );
|
---|
55 | m_lua->register_enum( "EASING_CUBIC", static_cast<int>( easing_type::CUBIC ) );
|
---|
56 | m_lua->register_enum( "EASING_ELASTIC", static_cast<int>( easing_type::ELASTIC ) );
|
---|
57 | m_lua->register_enum( "EASING_EXPO", static_cast<int>( easing_type::EXPO ) );
|
---|
58 | m_lua->register_enum( "EASING_LINEAR", static_cast<int>( easing_type::LINEAR ) );
|
---|
59 | m_lua->register_enum( "EASING_QUAD", static_cast<int>( easing_type::QUAD ) );
|
---|
60 | m_lua->register_enum( "EASING_QUART", static_cast<int>( easing_type::QUART ) );
|
---|
61 | m_lua->register_enum( "EASING_QUINT", static_cast<int>( easing_type::QUINT ) );
|
---|
62 | m_lua->register_enum( "EASING_SINE", static_cast<int>( easing_type::SINE ) );
|
---|
63 |
|
---|
64 | m_lua->register_enum( "CHOICE_ALL", static_cast<int>( model_node_choice::ALL ) );
|
---|
65 | m_lua->register_enum( "CHOICE_WEIGHTED", static_cast<int>( model_node_choice::WEIGHTED ) );
|
---|
66 | m_lua->register_enum( "CHOICE_PATTERN_CHECKER", static_cast<int>( model_node_choice::PATTERN_CHECKER ) );
|
---|
67 |
|
---|
68 | m_materials->initialize( lua );
|
---|
69 | m_programs->initialize( lua );
|
---|
70 | m_animators->initialize( lua );
|
---|
71 | m_models->initialize( lua );
|
---|
72 | }
|
---|
73 |
|
---|
74 | void default_resource_manager::reload_data()
|
---|
75 | {
|
---|
76 | m_materials->clear();
|
---|
77 | m_materials->load_all();
|
---|
78 | // m_models->load_all();
|
---|
79 | // m_programs->load_all();
|
---|
80 | }
|
---|
81 |
|
---|
82 | void nv::default_resource_manager::add_path( const string_view& path )
|
---|
83 | {
|
---|
84 | m_images->add_base_path( path );
|
---|
85 | m_mesh_datas->add_base_path( path );
|
---|
86 | m_programs->add_base_path( path );
|
---|
87 | m_animators->add_base_path( path );
|
---|
88 | }
|
---|