Hector, Sr. Member Posted: 24 October 2011 06:05 PM Total Posts: 137
Hi guys,
I’m very new to 3D and Away3D 4 and I don’t know if this questions has been solved already or they are very obvious:
I have a 3D model where the user can change his clothes textures (shirt, pants, etc.) and skin colour.
1 - So far I have been doing it by splitting the 3D model in different meshes, then I apply a different texture to every mesh. I’m not sure if this is the best way to do it, I think it takes so much resources?
2 - I have also used a single texture, changing the different areas in the bitmapData by using masks, before apply it to the 3D object. Maybe a better solution?
3 - In the Blender model I have the object in a single mesh and then ‘Vertext Groups’ for the UV maps. Are these groups or UV maps included when exporting to .3DS in a way that I can use them with Away3D 4? Maybe a format other than .3DS?
I was wondering if it’s possible to keep the 3D model in a single mesh and apply different textures to every vertex group.
I don’t know what option is the best one in order to make a good use of the resources or if there is a method to do this already.
Cheers,
Hector
Alex Bogartz, Sr. Member Posted: 24 October 2011 06:22 PM Total Posts: 216
[ # 1 ]
That’s funny, I was literally coming here to ask the same question!
My situation is that I was given a model that has different image files assigned under vertex groups. I’m not sure how to re-assign them in Away. Sounds similar to your problem. I could bake the whole texture to a single file, but I’m pretty sure that won’t look as good.
oulaboula, Newbie Posted: 24 October 2011 08:19 PM Total Posts: 15
[ # 2 ]
i think it’s possible but not tested yet.
when you load you 3ds model, you have a listener on the loader3ds that trigger the AssetCompleteEvent for each part of your model.
and in your listener function you can check what it’s really loaded like this :
private function onAssetComplete(event:AssetEvent):void { if (event.asset.assetType == AssetType.MESH) { trace("it's a mesh : " + event.asset.name ); var mesh:Mesh = event.asset as Mesh; mesh.material = material; // i think here you can do a switch on the name of your asset and apply the material your want }
for the others questions, i don’t have answer for you, sorry.
Hector, Sr. Member Posted: 25 October 2011 09:52 AM Total Posts: 137
[ # 3 ]
Thanks to both of you for your reply
Alex I’m glad to see I’m not the only one with that question, I hope it helps to find a solution faster.
Oulaboula, yes, something like that is what I’m using at the moment. It requires the object to be splitted on different meshes, but it has some cons.
oulaboula, Newbie Posted: 25 October 2011 10:02 AM Total Posts: 15
[ # 4 ]
which cons ?
80prozent, Sr. Member Posted: 25 October 2011 10:55 AM Total Posts: 430
[ # 5 ]
hi
i dont know if 3ds can export these vertexGroups you can see in Blender.
if they are exportet, they would show up in away3d as submeshes of the mesh.
just check if the mesh you are getting in away3d consist of multiple submeshes.
if (yourMesh.SubMeshes.length>1){ trace (“has multiple submeshes”);}
if there are multiple submeshes in your mesh, you can assign a material to each.
for (var i:uint=0;i
Hector, Sr. Member Posted: 26 October 2011 12:53 PM Total Posts: 137
[ # 6 ]
Thanks 80prozent, I will try it and post my results.
Alex Bogartz, Sr. Member Posted: 27 October 2011 02:24 AM Total Posts: 216
[ # 7 ]
This isn’t an answer so much as a different approach. In Blender, you can unwrap the model and bake the textures to a single image file. From there, you could load up the texture dynamically, or do a copyPixels from various images to composite a single texture. I did this today when I had to export the model to MD5 so I could animate it.
Hector, Sr. Member Posted: 28 October 2011 04:55 PM Total Posts: 137
[ # 8 ]
80prozent, I have tried subMeshes and there is only a single mesh in the model, but thanks for the tip, it has given me some clues to keep researching.
Alex, yes that’s the method I’m more confident about at the moment, but I’m not sure if it’s going to require more memory and cpu. Every time the user change shoes, hair, skin color, etc. I need to redo the whole texture and then apply it to about 20 models.
Not a problem with a good cpu and graphic card of course, but I just want to make sure I’m not missing a better method (and learn Away3D at the same time).
Btw, I have found away3d.materials.MaterialLibrary very useful to control the materials used in the application.
Simongg, Newbie Posted: 01 November 2011 09:19 AM Total Posts: 4
[ # 9 ]
After this you can export your Mesh as an 3Ds an import it into away3D and assign materials to parts of the mesh truh away3D. I did a quick example. Just a cube (one single mesh) with 6 different colorMaterials created with away3D: http://designbureau.de/simon/solution/
Hector, Sr. Member Posted: 02 November 2011 07:06 PM Total Posts: 137
[ # 10 ]
Thanks very much for your help Simon, I will try it and see what happens
Hector, Sr. Member Posted: 04 November 2011 12:03 PM Total Posts: 137
[ # 11 ]
It seems that the 3DS parser doesn’t support multiple materials at the moment:
Max3DSParser.as, line 464:
if (obj.materials.length > 1) trace(‘The Away3D 3DS parser does not support multiple materials per mesh at this point.’);
It loads all the materials from the file, but only applies the first one.
No choice for now with 3DS, maybe with other formats.
Simongg, Newbie Posted: 04 November 2011 02:21 PM Total Posts: 4
[ # 12 ]
Download the source files i posted and you will see that it is possible. I need this by myself for a actual project, so i tested it. You can acsess the materials thru the materialLibrary. eg:
model = loader.handle as ObjectContainer3D;
trace(model.materialLibrary.getMaterial(“mat1”));
trace(model.materialLibrary.getMaterial(“mat2”));
... etc.
Where mat1 and mat2 are materials assign within blender to the mesh.(see link postet befor) Now you can assign a material per away3d like this:
model.materialLibrary.getMaterial(“mat1”).material = new ColorMaterial(0xFF0000);
maybe post a link to your source files - and i can take a look
ciao simon
Hector, Sr. Member Posted: 04 November 2011 05:01 PM Total Posts: 137
[ # 13 ]
I’m sorry Simon, maybe I missed something or we are using a different Away3d version. There are no ‘away3d.loaders.Max3DS’ or ‘away3d.loaders.LoaderCube’ in my Away3D files. I’m using the one from GitHub.
Simongg, Newbie Posted: 04 November 2011 06:06 PM Total Posts: 4
[ # 14 ]
Ah okay sorry sorry. I am using the flashplayer 10 version. I think this is away3D 3.6.0. Dunno how this works in the new version. I tried to work with the newest version but it seems to be unstable at the moment ... at least for me. Keeping in mind that i have to finish my actual project within a month - i desided to use the older version.
sorry again
simon
Hector, Sr. Member Posted: 04 November 2011 06:46 PM Total Posts: 137
[ # 15 ]
No prob, it was a good tip and it gave me some new ideas to try, thanks for your help anyway