ZIP compression of non-binary 3d content files

Software: Away3D 4.x

frukc, Newbie
Posted: 08 March 2012 10:38 PM   Total Posts: 8

would it be difficult to implement this in Loader module? like - if I load ‘file_name.obj.zip’ loader would unzip file first and then pass it to correstponding parser. as3 compression libraries are available for long time now, ‘text’ format 3d files are perfect for compression and grow huge, without it.
or maybe there allready is feature like this?
ty!

   

Avatar
loth, Sr. Member
Posted: 09 March 2012 12:06 AM   Total Posts: 236   [ # 1 ]

yosh
i use fzip and ByteArray something like this

 

File Attachments
Import.as  (File Size: 5KB - Downloads: 741)
   

jtopaz, Member
Posted: 09 March 2012 10:05 AM   Total Posts: 53   [ # 2 ]

For .obj format, if we only zip the .obj file, how it handle the .mtl file and it’s texture image file?

 

   

Avatar
loth, Sr. Member
Posted: 09 March 2012 10:15 AM   Total Posts: 236   [ # 3 ]

simply i don’t use .mtl i creat new texture for all
and in fact .obj is biger than .3ds
but .obj have better support of smoothing group

 

   

frukc, Newbie
Posted: 09 March 2012 10:42 AM   Total Posts: 8   [ # 4 ]

.mtl and texture files are handled as before. i had no problems with them.
my solution was to modify “SingleFileLoader.as” in loaders/misc/

by adding zip libraries…

import nochump.util.zip.ZipFile;
 
import nochump.util.zip.ZipEntry

and a little bit of code…

private function handleUrlLoaderComplete(event Event) : void
  {
   
var urlLoader URLLoader URLLoader(event.currentTarget);
   
removeListeners(urlLoader);
   
   
///////////////////// added
   
   
if (_req.url.toLowerCase().indexOf("zip") > -1)
   
{
    
var myZipFile:ZipFile = new ZipFile(urlLoader.data);
    
_data myZipFile.getInput(myZipFile.getEntry(myZipFile.entries[0]));
   
}
   
else
   
{
    _data 
urlLoader.data;
   
}
   
   
///////////////////// end added
   
   //_data = urlLoader.data;
....... 


in project code i changed:

Loader3D.enableParser(OBJParserN);
...
   
myLoader.load(new URLRequest('../lib/MODEL.obj')); 

to

Loader3D.enableParser(OBJParserN);
...
   
myLoader.load(new URLRequest('../lib/MODEL.zip')); 

(zip file contains single file - same ‘MODEL.obj’)

and all worked fine from that point! including .mtl and texture file loading (zipped is just .obj file) smile

 

   

frukc, Newbie
Posted: 09 March 2012 10:50 AM   Total Posts: 8   [ # 5 ]

p.s. reduction in size of OBJ file by zipping was 81% from 1.8Mb to 0.37Mb cool smirk

 

   

Avatar
loth, Sr. Member
Posted: 09 March 2012 11:47 AM   Total Posts: 236   [ # 6 ]

same for .3ds

 

   

Avatar
loth, Sr. Member
Posted: 09 March 2012 04:50 PM   Total Posts: 236   [ # 7 ]

i make basic tutorial about that
i add texture after

 

File Attachments
compressTutorial.zip  (File Size: 675KB - Downloads: 456)
   

frukc, Newbie
Posted: 09 March 2012 11:39 PM   Total Posts: 8   [ # 8 ]

good! can’t take a look at it now, but i guess, some as3 folks will appreciate your effort.

 

   

C., Newbie
Posted: 03 April 2012 06:48 PM   Total Posts: 9   [ # 9 ]

Hey guys,

Thats a really interesting topic. Exactly what I was looking for! Has anyone tried already to load the images from the zip file as well? So that you only have to upload a single file, including all assets.

Somehow I couldnt manage to get the JPG in the loader again. I assume it should work with assetLoaderContext. But I dont know how to do that exactly.

My approach was something like this:

else if (product.substring(product.length 4product.length).toLowerCase() == ".zip"{
var urlstream:URLStream = new URLStream();
urlstream.addEventListener(Event.COMPLETEzipCompleteHandler);
urlstream.load(new URLRequest(product));

...

private function zipCompleteHandler(event:Event):void
  {
   
var datastream:URLStream URLStream(event.target);
   var 
zipFile:ZipFile = new ZipFile(datastream);
   var 
assetcontext:AssetLoaderContext = new AssetLoaderContext(true);
   
zipImages = new Array();
   var 
data3ds:ByteArray = new ByteArray();
   for (var 
i:int 0zipFile.entries.lengthi++)
   
{
    
var entry:ZipEntry zipFile.entries[i];
    if (
entry.name.substring(entry.name.length 4entry.name.length).toLowerCase() == ".3ds")
    
{
     
//if 3ds
     
data3ds zipFile.getInput(entry);
     
trace("3ds-Url: " entry.name);
    
}
    
else if (entry.name.substring(entry.name.length 1entry.name.length).toLowerCase() == "/" || entry.name.substring(entry.name.length 1entry.name.length).toLowerCase() == "\\")
    
{
     
//if folder-> do nothing
     
trace("Folder Url: "+entry.name);
    
}
    
else
    
{
     
// images

     
zipImages[entry.name] tempLoader.loadBytes(zipFile.getInput(entry));
     
assetcontext.mapUrlToData(entry.namezipFile.getInput(entry));
     
trace("Image Url: "+entry.name);
    
}
   }
   loader
.loadData(data3dsassetcontextnull, new Max3DSParser());
  

Do I have to convert the Image from Bytearray back to jpg before putting it in assetloadercontext? If so, how do I do that?

Thanks a lot! smile

Best regards
C.

 

   

Avatar
loth, Sr. Member
Posted: 03 April 2012 11:47 PM   Total Posts: 236   [ # 10 ]

jpg are already compress
compress them is a nonsense
i think

 

   

C., Newbie
Posted: 04 April 2012 07:19 AM   Total Posts: 9   [ # 11 ]

Of course you are right and I have to admit that using JPG was a stupid example. But for BMP and PNG it would make sense. smile

Also I like the idea of having all assets in just one zip-file to load from instead of several folders.

 

   

Avatar
loth, Sr. Member
Posted: 04 April 2012 09:40 AM   Total Posts: 236   [ # 12 ]

for png is the same no compression and bmp not in flash

look at fzip codazure website they are a simple exemple
with 1000 icons

 

   

manlypullock, Newbie
Posted: 28 October 2015 05:58 AM   Total Posts: 1   [ # 13 ]

Check this one…..7-Zip 9.20

Pullock

 

   
   
‹‹ Please add layers.

X

Away3D Forum

Member Login

Username

Password

Remember_me



X