look at tools.Mirror class.
Its supporting multiple materials.
Note I need to add a method MesshHelper.reOrganize(); (or something like that)
to optimize this class and of course others.
the issue:
a mesh is defined as following
subgeom[0] has first material and holds 50k verts
subgeom[1] has second material and holds 5k verts
during mirroring or if you add faces/vectors. For the ease lets use Mirror case
where data doubles
you get now 2 extra subgeometries in case of materials because of the maxvert
split and because each buffer must have a unique material.
while it should become 3.
1 holding 10k with second material
1 holding 65k with first material
1 holding 35k with first material
tho Adobe increased the amount of resources that can be uploaded, its
prefferable to have something good...
This is on my todo, and will unlikely give you issues in your application. Just
wanted explain the little nuance that is coming soon
into MeshHelper... the method will do this for you.
Fabrice
On Mar 22, 2011, at 9:02 PM, Dave wrote:
> I've constructed a SubMesh like so:
>
> var subMesh:SubMesh = new SubMesh(subGeometry, parentMesh);
>
> If I assign a material to the SubMesh, I get the following exception/
> stackdump:
>
> Main Thread (Suspended: TypeError: Error #1009: Cannot access a
> property or method of a null object reference.)
> away3d.core.base::SubGeometry/get animation
> away3d.core.base::SubMesh/get animation
> away3d.materials::MaterialBase/addOwner
> away3d.core.base::SubMesh/set material
> <snip>
>
> public function get animation() : AnimationBase
> {
> return _parentGeometry._animation;
> }
>
> _parentGeometry is null. This is only set in
> Geometry.addSubGeometry().
>
> When I add a SubGeometry to a SubMesh, am I also supposed to add the
> same SubGeometry to Mesh.geometry also?
>
> I suspect I'm running into a slightly underdeveloped part of the API,
> and I'm trying to figure out how best to steer around this error.
>
> I need to have one object, with multiple materials. I'm happy to
> achieve this however I can with the current API.
>
> -Dave
>