Thank you for your reply.  I've taken a look at tools.Mirror.

>From what I can tell, it looks like it's a bad move for me to create a
SubMesh explicitly.  It's better (with the current API) to simply
create the Mesh, add the SubGeometry to Mesh.geometry, and let
Mesh.onSubGeometryAdded() create the SubMesh for me.

However, I need to be able to get to the SubMesh to apply the material
later, and specifically know which material should go on which
SubMesh.  The only way that I can think of doing this is very brittle
- store a reference SubGeometry node I created, and then retrieve the
list of SubMesh from the Mesh, and compare SubMesh.subGeometry to my
stored references, and if they match, then apply the material.

I will try this now.

-Dave


On Mar 22, 2:04 pm, Fabrice3D <[email protected]> wrote:
> 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

Reply via email to