Tweaks to binobj reader interface.
This commit is contained in:
parent
66650e4148
commit
49fc684885
2 changed files with 40 additions and 39 deletions
|
@ -946,8 +946,12 @@ int FGOptions::parse_option( const string& arg ) {
|
||||||
// $$$ end - added VS Renganathan, 14 Oct 2K
|
// $$$ end - added VS Renganathan, 14 Oct 2K
|
||||||
} else if ( arg.find( "--visibility=" ) != string::npos ) {
|
} else if ( arg.find( "--visibility=" ) != string::npos ) {
|
||||||
visibility = atof( arg.substr( 13 ) );
|
visibility = atof( arg.substr( 13 ) );
|
||||||
|
globals->get_props()->setDoubleValue("/environment/visibility",
|
||||||
|
visibility);
|
||||||
} else if ( arg.find( "--visibility-miles=" ) != string::npos ) {
|
} else if ( arg.find( "--visibility-miles=" ) != string::npos ) {
|
||||||
visibility = atof( arg.substr( 19 ) ) * 5280.0 * FEET_TO_METER;
|
visibility = atof( arg.substr( 19 ) ) * 5280.0 * FEET_TO_METER;
|
||||||
|
globals->get_props()->setDoubleValue("/environment/visibility",
|
||||||
|
visibility);
|
||||||
} else if ( arg.find( "--wp=" ) != string::npos ) {
|
} else if ( arg.find( "--wp=" ) != string::npos ) {
|
||||||
parse_wp( arg.substr( 5 ) );
|
parse_wp( arg.substr( 5 ) );
|
||||||
} else if ( arg.find( "--flight-plan=") != string::npos) {
|
} else if ( arg.find( "--flight-plan=") != string::npos) {
|
||||||
|
|
|
@ -909,70 +909,67 @@ static ssgBranch *fgBinObjLoad( const string& path, FGTileEntry *t,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Point3D gbs_center;
|
SGBinObject obj;
|
||||||
float gbs_radius;
|
bool result = sgReadBinObj( path, &obj );
|
||||||
|
|
||||||
point_list offset_nodes; offset_nodes.clear();
|
|
||||||
point_list normals; normals.clear();
|
|
||||||
point_list texcoords; texcoords.clear();
|
|
||||||
|
|
||||||
// allocate and initialize triangle group structures
|
|
||||||
group_list tris_v; group_list tris_tc; string_list tri_materials;
|
|
||||||
tris_v.clear(); tris_tc.clear(); tri_materials.clear();
|
|
||||||
|
|
||||||
group_list strips_v; group_list strips_tc; string_list strip_materials;
|
|
||||||
strips_v.clear(); strips_tc.clear(); strip_materials.clear();
|
|
||||||
|
|
||||||
group_list fans_v; group_list fans_tc; string_list fan_materials;
|
|
||||||
fans_v.clear(); fans_tc.clear(); fan_materials.clear();
|
|
||||||
|
|
||||||
bool result = sgReadBinObj( path, gbs_center, &gbs_radius,
|
|
||||||
offset_nodes, normals, texcoords,
|
|
||||||
tris_v, tris_tc, tri_materials,
|
|
||||||
strips_v, strips_tc, strip_materials,
|
|
||||||
fans_v, fans_tc, fan_materials );
|
|
||||||
|
|
||||||
if ( !result ) {
|
if ( !result ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "fans size = " << fans_v.size() << " fan_mats size = " <<
|
cout << "fans size = " << obj.get_fans_v().size() << " fan_mats size = " <<
|
||||||
fan_materials.size() << endl;
|
obj.get_fan_materials().size() << endl;
|
||||||
|
|
||||||
ssgBranch *object = new ssgBranch();
|
ssgBranch *object = new ssgBranch();
|
||||||
object->setName( (char *)path.c_str() );
|
object->setName( (char *)path.c_str() );
|
||||||
|
|
||||||
if ( is_base && t != NULL ) {
|
if ( is_base && t != NULL ) {
|
||||||
// reference point (center offset/bounding sphere)
|
// reference point (center offset/bounding sphere)
|
||||||
t->center = gbs_center;
|
t->center = obj.get_gbs_center();
|
||||||
t->bounding_radius = gbs_radius;
|
t->bounding_radius = obj.get_gbs_radius();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
point_list nodes = obj.get_wgs84_nodes();
|
||||||
|
point_list normals = obj.get_normals();
|
||||||
|
point_list texcoords = obj.get_texcoords();
|
||||||
|
|
||||||
|
string material;
|
||||||
|
int_list vertex_index;
|
||||||
|
int_list tex_index;
|
||||||
|
|
||||||
// generate triangles
|
// generate triangles
|
||||||
for ( i = 0; i < (int)tris_v.size(); ++i ) {
|
for ( i = 0; i < (int)obj.get_tris_v().size(); ++i ) {
|
||||||
ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLES, tri_materials[i],
|
material = obj.get_tri_materials()[i];
|
||||||
offset_nodes, normals, texcoords,
|
vertex_index = obj.get_tris_v()[i];
|
||||||
tris_v[i], tris_tc[i],
|
tex_index = obj.get_tris_tc()[i];
|
||||||
|
ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLES, material,
|
||||||
|
nodes, normals, texcoords,
|
||||||
|
vertex_index, tex_index,
|
||||||
is_base, lights );
|
is_base, lights );
|
||||||
|
|
||||||
object->addKid( leaf );
|
object->addKid( leaf );
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate strips
|
// generate strips
|
||||||
for ( i = 0; i < (int)strips_v.size(); ++i ) {
|
for ( i = 0; i < (int)obj.get_strips_v().size(); ++i ) {
|
||||||
ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, strip_materials[i],
|
material = obj.get_strip_materials()[i];
|
||||||
offset_nodes, normals, texcoords,
|
vertex_index = obj.get_strips_v()[i];
|
||||||
strips_v[i], strips_tc[i],
|
tex_index = obj.get_strips_tc()[i];
|
||||||
|
ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
|
||||||
|
nodes, normals, texcoords,
|
||||||
|
vertex_index, tex_index,
|
||||||
is_base, lights );
|
is_base, lights );
|
||||||
|
|
||||||
object->addKid( leaf );
|
object->addKid( leaf );
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate fans
|
// generate fans
|
||||||
for ( i = 0; i < (int)fans_v.size(); ++i ) {
|
for ( i = 0; i < (int)obj.get_fans_v().size(); ++i ) {
|
||||||
ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_FAN, fan_materials[i],
|
material = obj.get_fan_materials()[i];
|
||||||
offset_nodes, normals, texcoords,
|
vertex_index = obj.get_fans_v()[i];
|
||||||
fans_v[i], fans_tc[i],
|
tex_index = obj.get_fans_tc()[i];
|
||||||
|
ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_FAN, material,
|
||||||
|
nodes, normals, texcoords,
|
||||||
|
vertex_index, tex_index,
|
||||||
is_base, lights );
|
is_base, lights );
|
||||||
|
|
||||||
object->addKid( leaf );
|
object->addKid( leaf );
|
||||||
|
@ -986,7 +983,7 @@ static ssgBranch *fgBinObjLoad( const string& path, FGTileEntry *t,
|
||||||
ssgBranch *fgObjLoad( const string& path, FGTileEntry *t,
|
ssgBranch *fgObjLoad( const string& path, FGTileEntry *t,
|
||||||
ssgVertexArray *lights, const bool is_base)
|
ssgVertexArray *lights, const bool is_base)
|
||||||
{
|
{
|
||||||
ssgBranch *result;
|
ssgBranch *result = NULL;
|
||||||
|
|
||||||
// try loading binary format
|
// try loading binary format
|
||||||
result = fgBinObjLoad( path, t, lights, is_base );
|
result = fgBinObjLoad( path, t, lights, is_base );
|
||||||
|
|
Loading…
Add table
Reference in a new issue