3DS Parser Added To Papervision From Away3D

Good news, I meant to post this a few days ago last weekend Tim Knip added 3DS parsing support to Papervision3D. Here is the thread with the quick howto.

Thread in nabble

Added a simple 3DS parser to the Great White trunk.
=> org.papervision3d.objects.parsers.Max3DS

…USAGE:


// where to find textures
var textureDir:String = "./images/";  // use a trailing slash!

// optional materialsList
var materials:MaterialsList = new MaterialsList();

// the 3DS file
var fileName:String = "[path-to-3ds-file]";

// load it!
_3ds.load(fileName, materials, textureDir);

// add to scene
scene.addChild(_3ds);

Also, one other golden nugget is Den Ivanov’s newest demo with Papervision portals! This is a very smooth demo, be sure to enter into the portals to see the seasons change.

Also here is a  non papervision 3ds parser.

Tags: , , , , , , , , , ,

  • http://mrdoob.com Mr.doob

    This is good because 3DS is one of the tiniest formats available. I did some tests and I think it was even smaller than .dae zipped.

  • http://drawlogic.com/ drawk

    Yeh dae/collada is awesome but it is xml based == bloat. Makes it a good transport format but runtime format has lots of overhead. At some point making models directly to swf or in multiple formats easily will be needed for flash 3d. 3ds is good because there are lots and lots of 3ds out there as you know and it is crunched down. Still the parsing time for dae, 3ds, md2 etc could use a caching layer there to swf on the fly so loading and memory could be lower maybe. Hrm parsing time, sound like a good little study.

  • http://www.juniovitorino.com Junio Vitorino

    With this isn’t necessary export to collada format?

  • Bart Claessens

    Hi, thanks for the parser but I don’t get it to work yet.
    I made a simple box in Cinema4D and exported it to .3DS, no textures attached.

    When I use your code in combination with the basic code to set up a papervision3D scene: http://www.insideria.com/2008/02/papervision3d-part-1-foundatio.html

    I get the following error at:
    _3ds.load(fileName, materials, textureDir);

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at be.billy.site.controller::MainController/initPapervision3D()
    at be.billy.site.controller::MainController()

    Why is it that the texture map has a default value of ./images/ in the method .load?

    Can’t I load shapes without textures?

    Thanks in advance
    Bart

  • http://drawlogic.com/ drawk

    Hey Bart,

    Do you have the latest and greatest from the PV3d SVN? I will try to post some tutorials on 3d formats for flash in the coming weeks. I think this is one of the stickiest hurdles when using 3d in flash.

  • http://www.shockbase.de c0nk3r

    hi drawk … thanks for parser .. but my model is only viewed in
    wireframe because it has no texture. how i can add a shader/color/bitmap (what ever) on it ?

  • DoomGoober

    Yeah, the 3DS loader is choking on my textures too so everything is rendering in wire frame. I debugged the code and it isn’t even finding the MAT_TEXMAP chunks, so my guess is that the file read position is getting messed up before then.

  • http://www.tyleregeto.com Tyler Egeto

    Hey guys, this is great news, were are working on something in the office and we’re working with .dae format, this really is nice! Love the file size difference. We were getting the wire frames too, however after I set the path in Papervision rather than relying on the parser to find it, it all worked great!

  • DoomGoober

    Tyler — Can you please explain what you mean when you say you set the path in Papervision? Are you saying you hardcoded the textures into the MaterialList?

  • DoomGoober

    I tracked down the bug in Max3DS.as that is causing the textures to parse incorrectly. The fix is simple:
    In the file Max3DS.as in the function parseMaterial() remove all instances of the following two lines of code:
    p = _data.position;
    _data.position = p;
    These lines are moving the pointer in the data stream which is making the chunks read incorrectly.

  • Yakazoo

    Hey guys,
    I have some problems here.

    I am not able to load my 3ds file and dont know why.
    I commented out euch line wiht p = _date.position
    and _data.position = p + colorChunk.length from the MAX3DS.as file
    And i am always getting this Error
    TypeError: Error #1009: Cannot access a property or method of a null object reference.

    I just want to load the object without any textures. What to do?
    THXs

  • http://tomaterial.blogspot.com George Profenza

    I had a look at MAX3DS.as and it fetches the vertices, faces, etc. and draw them in a single DisplayObject3D. That means there is not way to fetch nested objects, right ? At the moment I’m thinking I should export a 3d object intro several 3ds files and regroup them once their 3ds’ are parsed. Is there a better way of accessing child elements using the 3ds format ?

  • http://cune.ema.lv cyberprodigy

    Bart. if you get error message

    TypeError: Error #1009: Cannot access a property or method of a null object reference.

    then probably you have forgot to convert exported object from 3Dmax in Mesh. To convert object to mesh right click on object, and choose “Convert to -> Convert to editable mesh”

    Hope this helps

  • Pingback: Away3D - Getting Started | Harry Northover - The Blog

  • PlaneSailing

    Similar to C0nk3r – I loaded in my 3DS model ok but got a multicoloured wireframe with no Max material colours, what’s the best way to add colours in Papervision without using textures?

  • artur

    I’m loading a 3ds in the correct way, it has not texture embedded, I wanna assign it via Actionscript, I mean I have a basic texture in the flash Library and I use it like BitmapAssetMaterial, I added to materialist object, but I still see the model in wireframes, someone can help me or tell me how add texture to a 3ds via papervision?

  • http://www.tamarabernad.com tamarinda

    Hi Artur,

    I had the same problem, I solved it printing the name of the materials of the objects in the Max3DS object.
    //
    In class Max3DS (line aprox 122):
    var mat:MaterialData = meshData.materials[i];
    var material:MaterialObject3D = this.materials.getMaterialByName(mat.name) || MaterialObject3D.DEFAULT;
    trace(mat.name);
    //

    so you know each name of the materials given in MAX3DS, each material in the material list should have the corresponding name shown at the output.

    I hope that helps!

    ·:· ·:·;
    tamarinda

  • Artur

    Hi Tamarinda

    That works perfect :) . Tks so much !

  • Norby

    Hello guys,

    I’m having a stupid problem, and a brain f*rt, so I can’t seem to solve it.
    When I import the Max3ds parser, I get all kinds of errors, starting with
    Max3DS.as:111: 1178: Attempted access of inaccessible property _textureExtensionReplacements through a reference with static type org.papervision3d.objects.parsers:Max3DS

    Any idea why? I know that it’s a stupid mistake I made somewhere, just can’t figure out what. I JUST updated papervision from svn, using great white.

    Any help is greatly appriciated

    Thanks!

  • http://none Serj

    Hi everybody !

    I have some problems with Max3ds.
    When i load my model.3ds (some faces, vertex of Mesh) are on some distance from another faces and vertex same Mesh.

    Alternativa Engine have special function to fix this bug (autoWeldVerticles). But Papervision ?

    How can i fix this bug ?

  • Josh

    This class does not compile with Flash CS4 – I believe this is the problem Norby is having. Is there a simple fix? Thanks.

  • Josh L

    In response to my own question, there is a simple fix, which is to copy and paste each of the data structure mini classes at the end of the file into their own classfiles and import them in Max3DS.as. Obviously the CS4 compiler handles multiple classes per file differently from CS3, which sucks.

  • http://charmandedd.spaces.live.com flamander

    hias! Does the parser reads the animation info of a 3ds?.. I mean… Can I load the animation info of a 3ds and play on Papervision? I have seen the parser and have chunks for animations keyframes.. but.. I am not sure if it read only the first keyframe or how it parse the file and stores the data… on away3d the Max3DS.as parser loads material and geometry info and puts it on a property called “materialData” and its accesed via getMaterial()…

    which are the features of the 3ds parser for Papervision, what else do that away3d parser can’t?

    P.S. The point was… This parser reads the animation data of a 3ds to be used on Papervision? ( away3d Max3ds parser can’t load animation data of a 3ds file)

  • Pingback: Jesse Gomez » Blog Archive » Fix for papervision 3ds parser

  • http://thecoho.net Jesse Gomez

    I’ve been coming to this site for help for a long time and never posted. I’d like to make my first community message helpful by adding to this conversation….

    If you are using CS4 and you 3ds parser broke, or just never got it to work. download the zip on my site with fixed code – thecoho.net
    at this post specifically – http://thecoho.net/?p=41

    Josh L was right, you just had to subclass some stuff. I zipped up the solution and added instructions on my site for those of us (like me until ten minutes ago) don’t really get what he was talking about or know how to fix it.

    Thanks everyone for being so constantly helpful, I hope this helps

  • http://drawk.com drawk

    Jesse,

    Nice one I might revisit this and include your info soon. Parsing common formats is still a pretty big issue in Flash 3D engines.

  • http://thecoho.net Jesse Gomez

    yeah. it’s kind of a mess. Even with collada, which everyone seems to love, you have to make sure your setup is just perfect. Jim Foley has had a tough time too. http://www.madvertices.com/2008/11/animated-dae-files-ascollada.html

    But at least with collada, there seems to be some way of getting your UV names easily. I did the “trace” hack listed above, but I’m trying to make an XML based interface (which means the people adding models wont have the flash ide or even know what to do with it ) and I’ve had tons of trouble getting that data up the chain so to speak so i can display it in a text field. Of course I’m still a hack, and I’m also mixing it up with FLARmanager, which sits on FLARtoolkit, so I’m asking for complications.

    If anyone has a solution, let me know, and thanks!