]> git.mxchange.org Git - flightgear.git/commitdiff
Fixed a problem with the object loader ignoring custom texture dimensions
authorcurt <curt>
Mon, 29 Jan 2001 04:36:46 +0000 (04:36 +0000)
committercurt <curt>
Mon, 29 Jan 2001 04:36:46 +0000 (04:36 +0000)
specifiec in the materials file.

src/Objects/obj.cxx

index 43c5b959b0abfaf657990ad74953a10e662adf08..e18bfa9aaedb31e19e763e8bd2ce9e1549ddd819 100644 (file)
@@ -805,42 +805,6 @@ static ssgLeaf *gen_leaf( const string& path,
     ssgSimpleState *state = NULL;
     float coverage = -1;
 
-    int size = node_index.size();
-    ssgVertexArray   *vl = new ssgVertexArray( size );
-    ssgNormalArray   *nl = new ssgNormalArray( size );
-    ssgTexCoordArray *tl = new ssgTexCoordArray( size );
-    ssgColourArray   *cl = new ssgColourArray( 1 );
-
-    sgVec4 color;
-    sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
-    cl->add( color );
-
-    sgVec2 tmp2;
-    sgVec3 tmp3;
-    int i;
-    for ( i = 0; i < size; ++i ) {
-       Point3D node = nodes[ node_index[i] ];
-       sgSetVec3( tmp3, node[0], node[1], node[2] );
-       vl -> add( tmp3 );
-
-       Point3D normal = normals[ node_index[i] ];
-       sgSetVec3( tmp3, normal[0], normal[1], normal[2] );
-       nl -> add( tmp3 );
-
-       Point3D texcoord = texcoords[ tex_index[i] ];
-       sgSetVec2( tmp2, texcoord[0], texcoord[1] );
-       tl -> add( tmp2 );
-    }
-
-    // cout << "before leaf create" << endl;
-    ssgLeaf *leaf = new ssgVtxTable ( ty, vl, nl, tl, cl );
-    // cout << "after leaf create" << endl;
-
-    // lookup the state record
-    // cout << "looking up material = " << endl;
-    // cout << material << endl;
-    // cout << "'" << endl;
-
     FGNewMat *newmat = material_lib.find( material );
     if ( newmat == NULL ) {
        // see if this is an on the fly texture
@@ -879,6 +843,48 @@ static ssgLeaf *gen_leaf( const string& path,
        coverage = -1;
     }
 
+    int size = node_index.size();
+    ssgVertexArray   *vl = new ssgVertexArray( size );
+    ssgNormalArray   *nl = new ssgNormalArray( size );
+    ssgTexCoordArray *tl = new ssgTexCoordArray( size );
+    ssgColourArray   *cl = new ssgColourArray( 1 );
+
+    sgVec4 color;
+    sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
+    cl->add( color );
+
+    sgVec2 tmp2;
+    sgVec3 tmp3;
+    int i;
+    for ( i = 0; i < size; ++i ) {
+       Point3D node = nodes[ node_index[i] ];
+       sgSetVec3( tmp3, node[0], node[1], node[2] );
+       vl -> add( tmp3 );
+
+       Point3D normal = normals[ node_index[i] ];
+       sgSetVec3( tmp3, normal[0], normal[1], normal[2] );
+       nl -> add( tmp3 );
+
+       Point3D texcoord = texcoords[ tex_index[i] ];
+       sgSetVec2( tmp2, texcoord[0], texcoord[1] );
+       if ( tex_width > 0 ) {
+           tmp2[0] *= (1000.0 / tex_width);
+       }
+       if ( tex_height > 0 ) {
+           tmp2[1] *= (1000.0 / tex_height);
+       }
+       tl -> add( tmp2 );
+    }
+
+    // cout << "before leaf create" << endl;
+    ssgLeaf *leaf = new ssgVtxTable ( ty, vl, nl, tl, cl );
+    // cout << "after leaf create" << endl;
+
+    // lookup the state record
+    // cout << "looking up material = " << endl;
+    // cout << material << endl;
+    // cout << "'" << endl;
+
     leaf->setState( state );
 
     if ( calc_lights ) {