|
Keith, Newbie
Posted: 15 September 2011 02:56 PM Total Posts: 7
Hi all,
I have created a simple 3D model in Blender (2.5), and would like to use this model in Away3D in Flash. There are a few different export formats that Away3D can read. However, all of these are coming in with no texture or material data (basically, a completely white model).
I am using Prefab to test the importing process, by the way. The one file format that seems to export ‘more’ data from Blender (larger file size, anyway) is DAE, but it loads in with UV Mapping errors and triangular faces in Prefab.
What is the best way to export from Blender to Away3D, and still keep texturing/materials?
Thanks.
|
Alex Bogartz, Sr. Member
Posted: 15 September 2011 03:09 PM Total Posts: 216
[ # 1 ]
This is how I’ve got it working (but I’m pretty new to this process so there is probably a better way).
Select your model. Export from Blender as .obj, and uncheck ‘Materials’. Check “Selection Only”. Scale up 100 times. Then load the model as embedded and also embed the textures so you can create the material in code.
When I included the materials I was getting errors finding the .mtl file.
This is using v 4.0 of Away3D (I’m not going to worry about 3.6 since that’ll be obsolete soon, IMO).
|
Keith, Newbie
Posted: 22 September 2011 09:25 PM Total Posts: 7
[ # 2 ]
Hi Makai,
Thanks for the post, but I don’t understand this portion:
“Then load the model as embedded and also embed the textures so you can create the material in code.”
What do you mean by loading the model as embedded, or by embedding the textures? Does Blender has a way to ‘export’ just the textures that have been set on a model?
And when you import a texture and place it on your already-imported model with Away3D, does it know how to map it the same way you had it mapped in Blender?
Thanks.
|
Alex Bogartz, Sr. Member
Posted: 22 September 2011 09:29 PM Total Posts: 216
[ # 3 ]
Embedding the model means something like this at the top of your file:
[Embed(source='/../assets/models/myModel.obj',mimeType='application/octet-stream')] private var MyModel:Class;
Then loading that model using a parser:
_loader = new Loader3D(); _loader.addEventListener(AssetEvent.ASSET_COMPLETE, onResourceComplete); _loader.addEventListener(LoaderEvent.LOAD_ERROR, onResourceLoadingError); _loader.parseData(MyModel, null, new AssetLoaderContext(false));
Then assigning materials once the model loads:
_characterMesh = event.asset as Mesh; _characterMesh.scale(1); _characterMesh.y = 20; _characterMesh.material = _material;
_material will be a BitmapMaterial to which you can assign the normal map, specular map, diffuse map, etc.
|
Keith, Newbie
Posted: 23 September 2011 08:58 PM Total Posts: 7
[ # 4 ]
As you mentioned, I am trying to import an .OBJ exported from Blender, but I am getting texture errors when I load into Away3D 3.6. Does Away3D try to automatically load the corresponding .MTL file when you use Obj.load? If that’s what it’s attempting to do, something’s failing.
|
Alex Bogartz, Sr. Member
Posted: 23 September 2011 09:04 PM Total Posts: 216
[ # 5 ]
Yeah, the mtl file is reference in the obj file. So the way I got it to work is to make sure to not export materials in Blender.
|
Keith, Newbie
Posted: 23 September 2011 09:27 PM Total Posts: 7
[ # 6 ]
I have tried importing a different OBJ file, that did not have Materials/Material Groups exported - but loading that still gave me the same error…
|
Choons, Sr. Member
Posted: 24 September 2011 02:06 AM Total Posts: 281
[ # 7 ]
the mtl file is basically useless in Away3D and seems to cause a lot of problems from what I’ve seen (and experienced). A good trick is to open your OBJ file in a text editor like Notepad++ and remove every line that has ‘mtl’ in it. Seriously just delete them all. Then load your model in Away3D and assign materials from within Away3D
|
Keith, Newbie
Posted: 26 September 2011 04:11 PM Total Posts: 7
[ # 8 ]
Well, I have made some progress.
Blender outputs OBJ and MTL files that have odd line breaks that don’t show up in Notepad. So what I did, is opened it up in WordPad, and re-saved, and it added the correct line breaks.
After this, I reopened the OBJ in Prefab - and it included the texture I had applied in Blender! There were a few issues, though - it wasn’t mapped the same way, and it popped up some texture naming errors on load. Also, strangely enough, I had applied two different file textures in Blender, and when I first loaded into Prefab, both of those textures applied to the same sides of the cube as I had done in Blender - but then suddenly switched over so that every face of the cube had the one texture.
I’m happy to be making slow progress, but what I’m hearing is that MTL files don’t play nice with Away3D even when they are formatted correctly. So I guess it still comes back to my original question.
Texturing strictly in Away3D/Prefab really isn’t a viable solution for the workflow of the particular project I’m working on. I need to have the modeling and texturing linked very closely, so that when the time comes for using said 3D objects they just need a simple export from Blender, import in Away3D, and everything shows up correctly.
|
Choons, Sr. Member
Posted: 26 September 2011 06:27 PM Total Posts: 281
[ # 9 ]
have you tried using the 3DS format the same way? It is so much more compact than OBJ, and parses better. Have to keep those texture names at 8 characters or less though.
|
wagster, Member
Posted: 26 September 2011 06:59 PM Total Posts: 68
[ # 10 ]
Yeah - .obj gave me too much grief so I switched to .3ds. Much betterer. Was having a few problems retrieving “TableRound2m_8Chairs” from the AssetLibrary though. Is this because objects also have an 8 char limit?
|
Keith, Newbie
Posted: 28 September 2011 02:15 PM Total Posts: 7
[ # 11 ]
@Choons: As I recall, 3DS gave me the same issues with the textures/materials simply not loading in. I can give it another try, though…
|