Now after a serious massage, so far I can test on my machine, it's now doing the expected:
- (new) respects of smoothing surface. (you can merge flat and smooth shaded meshes)
- supports single and (new) multiple materials
- its even bits faster than previous version while doing more.
- (new) its filling submeshes up to their noses to prevent to submeshes generation unless necessary for shared materials cases.
- supports auto generation of extra submeshes in case of bufferlimit hit.
Thinks to know: where the previous one was adding submeshes as found in source mesh, if you would want to keep track of the merged geometry,
it will be necessary for you to keep track of the submeshes/vertices indices to id shapes where previously a simple submesh offset count was required.
Reason is simply smaller memory footprint and less uploads.
That having said, even if I've tested many combos of different meshes and I'm pretty confident it should be robust.
Its still possible something might go wrong. So please if you have a case where it fails, deliver me the code+sources so I can debug/enhance it.
In meanwhile, I'll be updating/cleaning here and there few details and will write a little demo code that I'll upload asap.
The baby is in svn.
Fabrice
in this example, I was trying a similar case as was discussed with cubes
so in this case, it would be stupid to build first loads of cubes and then merge them
in this particular case, you would, if you would use my demo code, simply alter the uv's of the source cube during the loop
and offset its position. See this test more as a stress test rather than what you would usually do.
John for instance, he makes a city add to a container --> pass the whole micmac to the merge class. Thats the most common use of it.
if you would use PathDuplicator, and pass a tree, and a container, you could pass this container to the class and name it MyForest...
Fabrice
Just runned a test where I try after a merge with dispose on, to reuse the same source, and got null error. So Obvioulsy the problem lays else where.
> Works great, single mesh and multiple materials :)
really happy about that, this method was a serious pain :)
I have just noticed a little problem on merges mega unsanely huge meshes with multiple materials, no errors, but not propper display.
Will fix later on, it should probably not occur in most "normal" cases.
Fabrice
hum.. What do you mean? Does it work if you use the original code, with no changes?
where it was doing
loop
parse
merge
it now does
loop
parse & collect data
merge
It does not speed up a single merging of two objects.
It prevents a parsing*n loops for reciever object and all the vectors/var generation
which can be pretty significant boost.
looking now at the massive meshes issue.
@rjgtav
Even if the above update will probably speed up your case, I think generating new cubes
each iteration is not the way to go...
Fabrice
Fabrice
As I'm gonna move on to other classes now, if you think of something that should ease or help make it better,
let me know .
oh btw, a little detail on your snippet
scaleUV(c, new Point((bmd.width), (bmd.height)));
incrementUV(c, new Point(x / (bmd.width ), y / (bmd.height )));
you could spare "new Point()" 9706 times. the first one could be declared once outside.
and the second could be a simple holder point that just need new x,y values each iteration...
the scaleUV seams pretty constant as well, may be could be done just once before loop...
Fabrice
just added a little thingy. For the merge with containers, as the class picks the first mesh it encounters to use it as reciever mesh.
It can be in some cases not that obvious to know who became the donkey, to eventually loop over the others to destroy them for instance if the remove was not left to the class.
so now you have an optional mesh name param for this. To reuse your snippet
it could become.
scene.addChild(merge.applyToContainer(imgHolder, "marge"));
same result but thought I could become handy if you merge from unknown loaded content or work without id's.
Fabrice
On May 12, 2011, at 4:06 PM, John Brookes wrote:
> good point ;)
>
the trick is simply to offset the vertice count by the amount of cube vertices.
in speudo you will have first if you want to later vertices of a cube representation
to
1 isolate the sb, a floor %64998
2 diif to count from geo target
3 alter the vertices
4 update all the sg's
Fabrice
if i set its material to null, the loop never ends