It is currently Thu Sep 09, 2010 2:10 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Want Code Segment of 3DSimED which expands and compress .gtr
PostPosted: Tue Jul 20, 2010 7:48 am 
Offline
Jackman
Jackman

Joined: Sat Jul 17, 2010 6:23 am
Posts: 4
Can any one help me out with this. I am working on a project in university in which i want algorithm to compress Models and Texture maps of gtr2 game into .gtr file.
Can i get the code of 3dSimed for use :)
I would b very thankfull and give full acknowlogement to 3dSimED team
thanks


Top
 Profile  
 
 Post subject: Re: Want Code Segment of 3DSimED which expands and compress
PostPosted: Tue Jul 20, 2010 11:45 am 
Offline
Tirechanger
Tirechanger

Joined: Fri Jan 04, 2008 3:50 pm
Posts: 38
Have you tried writing it yourself ? I managed to figure out rfactor's MAS file format and the details are in another post I made here. Almost all of the various ISI-based games have a very similar format so you can probably figure it out if you study it for a while. Remember to use my previous post for reference as it has some hints about what GTR2's format likely is.

Sorry, I am working on many projects of my own so I can't help you.


Top
 Profile  
 
 Post subject: Re: Want Code Segment of 3DSimED which expands and compress
PostPosted: Wed Jul 21, 2010 3:34 am 
Offline
Jackman
Jackman

Joined: Sat Jul 17, 2010 6:23 am
Posts: 4
@V. Klortho
ok i understand.
i have read ur post of rfactor mas file .. i am working on the .gtr file format.i ll figure it out
i knw its not co0l i asking u fr the code.i am working on a product , will launch it soon . can u give me the code of rfactor mas file format of compression and uncompression , i ll give acknowlegement to u when i launch it.


Top
 Profile  
 
 Post subject: Re: Want Code Segment of 3DSimED which expands and compress
PostPosted: Wed Jul 21, 2010 7:35 pm 
Offline
Tirechanger
Tirechanger

Joined: Fri Jan 04, 2008 3:50 pm
Posts: 38
No, I will not give you code to use in your product.

ISI has provided a command-line utilty that will do this and it is very easy to use. It's called files2mas.


Top
 Profile  
 
 Post subject: Re: Want Code Segment of 3DSimED which expands and compress
PostPosted: Mon Jul 26, 2010 12:55 am 
Offline
Tirechanger
Tirechanger

Joined: Fri Jan 04, 2008 3:50 pm
Posts: 38
Here's something I saved that was orginally posted at racesimcentral a few years ago.

Code:
#!/usr/bin/perl -w
#
use strict;
use Compress::Zlib;

my $file = shift;
my $file_size = -s $file;
my $number_of_files;
my $address = 0;

open MAS, $file;
binmode(MAS);

print "header:", unpack("A11", &get_field( ($address + 0),11)), "\n";
print "Number Of Files: ", unpack("L1", &get_field( ($address+16),4)), "\n";
$number_of_files = unpack("L1", &get_field( ($address+16),4));
print "Length Files Data: ", unpack("L1", &get_field( ($address+20),4)), "\n";
my $file_data_size = unpack("L1", &get_field( ($address+20),4));
print "***************************************\n";

#This is where the file headers start in GTR/GTL MAS File.
my $next = 24;
my $file_offset = $file_size - $file_data_size;

my $file_count = 0;
while (($file_count < $number_of_files) && ($number_of_files > 0) )
{
   ($next, my $typeid, my $offset, my $dfsize, my $cfsize, my $fname) = &get_file_header($next);
   $file_count++;
   &get_file( $fname, ($offset+$file_offset), $cfsize);
}

close MAS;
exit(0);

sub get_field()
{
   my $address = $_[0];
   my $size = $_[1];
   my $tmp;

   seek(MAS,$address,0);
   read(MAS,$tmp,$size);

   return ($tmp);
}

sub get_file_header()
{
   my $address = $_[0];
   my @file;

   $file[0] = unpack("L1", &get_field( ($address),4)); #File Type ID
   $file[1] = unpack("L1", &get_field( ($address+4),4)); #File Offset
   $file[2] = unpack("L1", &get_field( ($address+8),4)); #Decompressed File Size
   $file[3] = unpack("L1", &get_field( ($address+12),4)); #Compressed File Size
   $file[4] = unpack("A240", &get_field( ($address+16),240)); #File Name

   return ((256+$address), @file);
}

sub print_file_headers()
{
   my $address = $_[0];
   print "Files Type ID: ", unpack("L1", &get_field( ($address),4)), "\n";
   print "File Offset: ", unpack("L1", &get_field( ($address+4),4)), "\n";
   print "Decompressed File Size: ", unpack("L1", &get_field( ($address+8),4)), "\n";
   print "Compressed File Size: ", unpack("L1", &get_field( ($address+12),4)), "\n";
   my $compressed_file_size = unpack("L1", &get_field( ($address+12),4));
   print "File Name: ", unpack("A240", &get_field( ($address+16),240)), "\n";
   print "***************************************\n";
   return (256+$address);
}

sub get_file()
{
   my $file_name = $_[0];
   my $offset = $_[1];
   my $csize = $_[2];
   my $exit_code = 1;

   my $file = &get_field( $offset, $csize);
   my $output = uncompress($file);

   if (defined $output)
   {
      open FILE, ">$file_name";
      binmode(FILE);

      print FILE $output;
      print FILE $file;
      close FILE;
      print "$file_name\n";
   }
   else
   {
      print "uncompress Failed\n";
   }

   return ($exit_code);
}


Top
 Profile  
 
 Post subject: Re: Want Code Segment of 3DSimED which expands and compress
PostPosted: Mon Aug 02, 2010 5:34 pm 
Offline
Jackman
Jackman

Joined: Sat Jul 17, 2010 6:23 am
Posts: 4
@V. Klortho
i hope now i ll figure out an algo fr gtr2 game
thnks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group