diff --git a/Simulator/Objects/Makefile.am b/Simulator/Objects/Makefile.am index f2582f306..9a8e5665e 100644 --- a/Simulator/Objects/Makefile.am +++ b/Simulator/Objects/Makefile.am @@ -2,7 +2,9 @@ noinst_LIBRARIES = libObjects.a libObjects_a_SOURCES = \ fragment.cxx fragment.hxx \ + material.cxx material.hxx \ materialmgr.cxx materialmgr.hxx \ - obj.cxx obj.hxx + obj.cxx obj.hxx \ + texload.c texload.h colours.h INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator diff --git a/Simulator/Objects/materialmgr.cxx b/Simulator/Objects/materialmgr.cxx index c282d6672..c4828bd44 100644 --- a/Simulator/Objects/materialmgr.cxx +++ b/Simulator/Objects/materialmgr.cxx @@ -46,7 +46,6 @@ #include #include
#include
-#include #include #include "materialmgr.hxx" @@ -62,6 +61,7 @@ fgMATERIAL_MGR material_mgr; // Constructor FGMaterialSlot::FGMaterialSlot ( void ) { } + // Destructor FGMaterialSlot::~FGMaterialSlot ( void ) { } @@ -158,7 +158,7 @@ fgMATERIAL_MGR::load_lib ( void ) in >> m; // if ( current_options.get_textures() ) { - // m.load_texture( current_options.get_fg_root() ); + // m.load_texture( current_options.get_fg_root() ); // } FGMaterialSlot m_slot; diff --git a/Simulator/Objects/materialmgr.hxx b/Simulator/Objects/materialmgr.hxx index 9f9389077..a5fefa561 100644 --- a/Simulator/Objects/materialmgr.hxx +++ b/Simulator/Objects/materialmgr.hxx @@ -46,7 +46,7 @@ #include // STL associative "array" #include // STL "array" -#include +#include "material.hxx" FG_USING_STD(string); FG_USING_STD(map); @@ -123,6 +123,7 @@ public: // friend istream& operator >> ( istream& in, FGMaterialSlot& m ); + inline FGMaterial get_m() const { return m; } inline void set_m( FGMaterial new_m ) { m = new_m; } }; diff --git a/Simulator/Objects/obj.cxx b/Simulator/Objects/obj.cxx index d2c41ca9c..cb9e379f7 100644 --- a/Simulator/Objects/obj.cxx +++ b/Simulator/Objects/obj.cxx @@ -142,6 +142,7 @@ int fgObjLoad( const string& path, fgTILE *t) { int last1 = 0, last2 = 0, odd = 0; double (*nodes)[3]; Point3D center; + double tex_width = 1000.0, tex_height = 1000.0; // printf("loading %s\n", path.c_str() ); @@ -242,7 +243,13 @@ int fgObjLoad( const string& path, fgTILE *t) { "Ack! unknown usemtl name = " << material << " in " << path ); } - + + // set the texture width and height values for this + // material + FGMaterial m = fragment.material_ptr->get_m(); + tex_width = m.get_xsize(); + tex_height = m.get_ysize(); + cout << "(w) = " << tex_width << " (h) = " << tex_width << endl; // initialize the fragment transformation matrix /* for ( i = 0; i < 16; i++ ) { @@ -414,8 +421,8 @@ int fgObjLoad( const string& path, fgTILE *t) { xglNormal3dv(normals[n1]); if ( in.get( c ) && c == '/' ) { in >> tex; - pp.setx( tex_coords[tex][0] ); - pp.sety( tex_coords[tex][1] ); + pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) ); + pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) ); } else { in.putback( c ); pp = calc_tex_coords(nodes[n1], center); @@ -427,8 +434,8 @@ int fgObjLoad( const string& path, fgTILE *t) { xglNormal3dv(normals[n2]); if ( in.get( c ) && c == '/' ) { in >> tex; - pp.setx( tex_coords[tex][0] ); - pp.sety( tex_coords[tex][1] ); + pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) ); + pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) ); } else { in.putback( c ); pp = calc_tex_coords(nodes[n2], center); @@ -454,8 +461,8 @@ int fgObjLoad( const string& path, fgTILE *t) { xglNormal3dv(normals[n3]); if ( in.get( c ) && c == '/' ) { in >> tex; - pp.setx( tex_coords[tex][0] ); - pp.sety( tex_coords[tex][1] ); + pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) ); + pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) ); } else { in.putback( c ); pp = calc_tex_coords(nodes[n3], center);