]> git.mxchange.org Git - flightgear.git/blobdiff - src/Objects/obj.cxx
Add a key mapping (F3) for taking a screen snap shot.
[flightgear.git] / src / Objects / obj.cxx
index 4d3cdfb17dbc634d8a63b34c62a30a4a54e2b4ed..6c91c59ee7a2941785f4c4abd18b51aeb0c1cf82 100644 (file)
@@ -55,6 +55,7 @@
 #include <Math/polar3d.hxx>
 #include <Misc/stopwatch.hxx>
 #include <Scenery/tileentry.hxx>
+#include <Clouds/cloudobj.hxx>
 
 #include "materialmgr.hxx"
 #include "obj.hxx"
@@ -233,7 +234,9 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
     }
     
     unsigned short *vindex = new unsigned short [ 4 ];
+    t->free_ptrs.push_back( vindex );
     unsigned short *tindex = new unsigned short [ 4 ];
+    t->free_ptrs.push_back( tindex );
     for ( i = 0; i < 4; ++i ) {
        vindex[i] = i;
        tindex[i] = i;
@@ -248,6 +251,9 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
     leaf->setState( state );
 
     tile->addKid( leaf );
+    if ( current_options.get_clouds() ) {
+       fgGenCloudTile(path, t, tile);
+    }
 
     return tile;
 }
@@ -280,6 +286,7 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t) {
     ssgSimpleState *state = NULL;
 
     ssgBranch *tile = new ssgBranch () ;
+
     tile -> setName ( (char *)path.c_str() ) ;
 
     // Attempt to open "path.gz" or "path"
@@ -700,15 +707,21 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t) {
                    // xglTexCoord2f(pp.x(), pp.y());
                    // xglVertex3dv(nodes[n3].get_n());
 
-                   if ( odd ) {
+                   if ( token == "tf" ) {
+                       // triangle fan
                        fragment.add_face(n1, n2, n3);
+                       n2 = n3;
                    } else {
-                       fragment.add_face(n2, n1, n3);
+                       // triangle strip
+                       if ( odd ) {
+                           fragment.add_face(n1, n2, n3);
+                       } else {
+                           fragment.add_face(n2, n1, n3);
+                       }
+                       odd = !odd;
+                       n1 = n2;
+                       n2 = n3;
                    }
-
-                   odd = !odd;
-                   n1 = n2;
-                   n2 = n3;
                }
 
                // xglEnd();
@@ -716,8 +729,12 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t) {
                // build the ssg entity
                unsigned short *vindex = 
                    new unsigned short [ fan_vertices.size() ];
+               t->free_ptrs.push_back( vindex );
+
                unsigned short *tindex = 
                    new unsigned short [ fan_tex_coords.size() ];
+               t->free_ptrs.push_back( tindex );
+
                for ( i = 0; i < (int)fan_vertices.size(); ++i ) {
                    vindex[i] = fan_vertices[i];
                }
@@ -912,7 +929,11 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t) {
     FG_LOG( FG_TERRAIN, FG_DEBUG, 
            "Loaded " << path << " in " 
            << stopwatch.elapsedSeconds() << " seconds" );
-    
+
+    // Generate a cloud layer above the tiles
+    if ( current_options.get_clouds() ) {
+       fgGenCloudTile(path, t, tile);
+    }
     return tile;
 }