Re: [Flightgear-devel] Bug in SGBinObject write_bin() function?

2007-11-12 Thread Ralf Gerlich
Hi Christian!

Christian Buchner wrote:
 This code loads the largest (non-airport) BTG file from the World
 scenery disk 1 (mounted on drive S: on Windows) and tries to save it back.

I don't have that disk, but I downloaded the respective chunk from the
FlightGear scenery download site to try and reproduce the problem.

I'll try it with the respective tile from that download and if I can't
reproduce it, we'll compare hashes or somebody will have to send me that
tile.

Cheers,
Ralf

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Bug in SGBinObject write_bin() function?

2007-11-12 Thread Christian Buchner
2007/11/12, Ralf Gerlich [EMAIL PROTECTED]:

 Hi Christian!

 Christian Buchner wrote:
  This code loads the largest (non-airport) BTG file from the World
  scenery disk 1 (mounted on drive S: on Windows) and tries to save it
 back.

 I don't have that disk, but I downloaded the respective chunk from the
 FlightGear scenery download site to try and reproduce the problem.

 I'll try it with the respective tile from that download and if I can't
 reproduce it, we'll compare hashes or somebody will have to send me that
 tile.


I think I already know what the problem is. There is no normal vector index
attached to the SG_TRIANGLE_FANS object.

Each vertex stored in the BTG file appears to get implicitly mapped to a
normal vector index. Of course that only works if the number of normal
vectors stored in the file matches exactly number of vertices. This
appears to be true for all existing scenery files.

The write_bin subroutine tries to write out the index nevertheless, although

the fans_n index vector' has 0 length. Then you get the crash.

I've fixed this bug by adding additional checks before deciding whether
to write the index or not. The check for tris_n[0].size() is new.

if ( tris_n.size()   tris_n[0].size()  ) { idx_mask |= SG_IDX_NORMALS;
++idx_size; }

and later when writing out the indices I check the corresponding bit flag in
the idx_mask

if ( idx_mask  SG_IDX_NORMALS ) {
sgWriteUShort( fp, (unsigned short)tris_n[i][j] );
}

I added checks like this to all primitives ( fans, stripes, faces and
points)
and also to the COLORS, TEXCOORDS, VERTICES indices.

I am now working to achieve on a higher compressing storage format using
some variable
length coding, quantization and some differential/predictive encoding of
indices and
coordinates.

Christian
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


[Flightgear-devel] Bug in SGBinObject write_bin() function?

2007-11-11 Thread Christian Buchner
Hi,

I am trying to understand the SGBinObject binary format (BTG files) and for
this purpose I wrote a short test program to load a file and save it back to
disk.

SGBinObject source;
bool result = source.read_bin
(S:\\scenery\\Terrain\\w090n30\\w087n39\\1532019.btg);
if (result == true)
{
SGBucket bucket(SGGeod::fromCart(SGVec3double(
source.get_gbs_center2().sg(;
source.write_bin(C:\\, test.btg, bucket);
}

This code loads the largest (non-airport) BTG file from the World scenery
disk 1 (mounted on drive S: on Windows) and tries to save it back.

The program crashes in line 1015 of sg_binobj.cxx trying to access the
member variable fans_n[i][j]  with a vector subscript out of range debug
error inside the STL vector class.

I was kind of wondering if my use of write_bin is incorrect, or if there is
a serious bug in the write_bin() implementation. Maybe this function is used
so seldom that no-one noticed so far?

I was trying this on Windows based on the CVS/HEAD SimGear release under
Visual C++ 2005 Express Edition. The flightgear binary produced with this
compiler works just fine.

My mid term goal is to come up with a more efficiently compressed binary
format to save some disk space and possible squeeze the world scenery on two
DVDs or less. I plan to achieve this goal by using some quantization and
entropy coding. It might also be possible to obtain some LOD support by
encoding the mesh progressively (i.e. from coarse to full precision) and by
specifying a cutoff point during read_bin()
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel