|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Max3DS parser broken? - can't get materialsHey,
Is anyone successfully using the Max3DS parser? I can't get my model materials from it and I think it is a problem in the class itself. If I add a trace inside the Max3DS class, it traces my materials, but if I try to use ANY of the inherited functions (like materialsList() or materials.toString() ) from another class, I get an empty materialsList. If anyone has done this successfully, please let me know what the code is. Thanks, Andy ===============================================
Check out my blog for Flash, AS3, and web development stuff: http://www.wastedpotential.com |
|
|
Re: Max3DS parser broken? - can't get materialsOkay, after more investigation, here is what I've found:
You can create a materialsList with the names of materials in the 3DS model and send the materialslist to the model in the constructor as follows: fmat = new ColorMaterial(0x0000ff); fmat2 = new ColorMaterial(0xffff00); matList = new MaterialsList(); matList.addMaterial(fmat, "redmaterial"); //redmaterial is the material name in my 3DS file matList.addMaterial(fmat2, "blackmaterial"); //blackmaterial is the material name in my 3DS file shape = new Max3DS(); shape.load("models/wagon4.3DS", matList); holder.addChild(shape); This correctly assigns the colormaterials and I can trace the material data with this: trace(shape.materials.toString()); //THIS WORKS! or this: trace(shape.materials.numMaterials); So, here are my questions: 1) If I load my model without a materialslist as follows: shape.load("models/wagon4.3DS"); ...then my traces (see above) don't work. I get no materials tracing and the numMaterials returns zero. WTF? Shouldn't I be able to see the materials without assigning a materialslist? It displays the wireframe, so why doesn't it return wireframe materials? Is this a bug in the parser? Speaking of bugs in the parser, why can't I assign a FlatShadeMaterial to the Max3DS materials list? It throws a bunch of errors when I do this. It has no trouble with ColorMaterials. Tim, do you have any insight on this? I know you ported this parser from Away3D. Thanks, Andy
===============================================
Check out my blog for Flash, AS3, and web development stuff: http://www.wastedpotential.com |
|
|
Re: Max3DS parser broken? - can't get materialsAfter even more investigation, I found a problem in the Max3DS parser - in the buildMesh() function:
The way it works is this: if you have sent a materialsList to the Max3DS constructor, it looks for the material name and assigns that material to the mesh if it is found. If the mesh material does not match up to a name in the provided materialsList, it creates a wireframe material instead. But... AND HERE IS THE PROBLEM... It does NOT add that wireframe material to the Max3DS object's materialsList! You can fix it by replacing the following lines of code (line 120, more or less): var mat:MaterialData = meshData.materials[i]; var material:MaterialObject3D = this.materials.getMaterialByName(mat.name) || MaterialObject3D.DEFAULT; with this: var mat:MaterialData = meshData.materials[i]; var material:MaterialObject3D if (this.materials.getMaterialByName(mat.name)) { material = this.materials.getMaterialByName(mat.name) } else { material = MaterialObject3D.DEFAULT; this.materials.addMaterial(material, mat.name); } Then, after the file is completely loaded, you can get an accurate materialsList from the Max3DS object (allowing you to replace the materials by name). There is probably a more efficient way to code this, but it gets the job done. The sweet thing is that it only adds a wireframe material to the list if a material by that name doesn't exist yet. Now, I need to figure out why the ShadeMaterials didn't work. -Andy ===============================================
Check out my blog for Flash, AS3, and web development stuff: http://www.wastedpotential.com |
| Free embeddable forum powered by Nabble | Forum Help |