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 )
|
---|
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 );
|
---|
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 | m_lua->register_enum( "INT_NONE", static_cast<int>( interpolation::NONE ) );
|
---|
30 | m_lua->register_enum( "INT_LINEAR", static_cast<int>( interpolation::LINEAR ) );
|
---|
31 | m_lua->register_enum( "INT_NORMALIZED", static_cast<int>( interpolation::NORMALIZED ) );
|
---|
32 | m_lua->register_enum( "INT_SPHERICAL", static_cast<int>( interpolation::SPHERICAL ) );
|
---|
33 | m_lua->register_enum( "INT_QUADRATIC", static_cast<int>( interpolation::QUADRATIC ) );
|
---|
34 | m_lua->register_enum( "INT_SQUADRATIC", static_cast<int>( interpolation::SQUADRATIC ) );
|
---|
35 |
|
---|
36 | m_lua->register_enum( "EASING_BACK", static_cast<int>( easing_type::BACK ) );
|
---|
37 | m_lua->register_enum( "EASING_BOUNCE", static_cast<int>( easing_type::BOUNCE ) );
|
---|
38 | m_lua->register_enum( "EASING_CIRC", static_cast<int>( easing_type::CIRC ) );
|
---|
39 | m_lua->register_enum( "EASING_CUBIC", static_cast<int>( easing_type::CUBIC ) );
|
---|
40 | m_lua->register_enum( "EASING_ELASTIC", static_cast<int>( easing_type::ELASTIC ) );
|
---|
41 | m_lua->register_enum( "EASING_EXPO", static_cast<int>( easing_type::EXPO ) );
|
---|
42 | m_lua->register_enum( "EASING_LINEAR", static_cast<int>( easing_type::LINEAR ) );
|
---|
43 | m_lua->register_enum( "EASING_QUAD", static_cast<int>( easing_type::QUAD ) );
|
---|
44 | m_lua->register_enum( "EASING_QUART", static_cast<int>( easing_type::QUART ) );
|
---|
45 | m_lua->register_enum( "EASING_QUINT", static_cast<int>( easing_type::QUINT ) );
|
---|
46 | m_lua->register_enum( "EASING_SINE", static_cast<int>( easing_type::SINE ) );
|
---|
47 |
|
---|
48 | m_materials->initialize( lua );
|
---|
49 | m_programs->initialize( lua );
|
---|
50 | m_animators->initialize( lua );
|
---|
51 | m_models->initialize( lua );
|
---|
52 | }
|
---|
53 |
|
---|
54 | void default_resource_manager::reload_data()
|
---|
55 | {
|
---|
56 | m_materials->clear();
|
---|
57 | m_materials->load_all();
|
---|
58 | // m_models->load_all();
|
---|
59 | // m_programs->load_all();
|
---|
60 | }
|
---|
61 |
|
---|
62 | void nv::default_resource_manager::add_path( const string_view& path )
|
---|
63 | {
|
---|
64 | m_images->add_base_path( path );
|
---|
65 | m_mesh_datas->add_base_path( path );
|
---|
66 | m_programs->add_base_path( path );
|
---|
67 | m_animators->add_base_path( path );
|
---|
68 | }
|
---|