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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.