]> git.mxchange.org Git - flightgear.git/commitdiff
Moved material property and texture management back to Simulator/Objects/
authorcurt <curt>
Thu, 13 May 1999 02:24:55 +0000 (02:24 +0000)
committercurt <curt>
Thu, 13 May 1999 02:24:55 +0000 (02:24 +0000)
Working on scalable texture sizes.

Simulator/Objects/Makefile.am
Simulator/Objects/materialmgr.cxx
Simulator/Objects/materialmgr.hxx
Simulator/Objects/obj.cxx

index f2582f3069125b20e180e7929f94710cf5ef6167..9a8e5665e0f0a42345c4e3c30dfd0d63944f6d3c 100644 (file)
@@ -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
index c282d66722b3e1a3088031c4d1495e1859205d01..c4828bd4496be2d90f24c9194e0d7437dff1e98d 100644 (file)
@@ -46,7 +46,6 @@
 #include <Misc/fgstream.hxx>
 #include <Main/options.hxx>
 #include <Main/views.hxx>
-#include <Misc/texload.h>
 #include <Scenery/tile.hxx>
 
 #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;
index 9f9389077b82e675a96d4c1e213fd4741f89c606..a5fefa561415b6ee5917efccf874176022d52ac3 100644 (file)
@@ -46,7 +46,7 @@
 #include <map>           // STL associative "array"
 #include <vector>        // STL "array"
 
-#include <Misc/material.hxx>
+#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; }
 };
 
index d2c41ca9c48c0c48fc59c1856cae571b2b395624..cb9e379f735b1e14c83a6e2573b0c930c240fee0 100644 (file)
@@ -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);