I'm testing it in the simplest way possible to start. I'll try with multiple
materials later, but for now, it's working as expected:
private function createMap(size:uint):void
{
var planeA:Mesh = new Plane(_material, 100, 100, 1, 1, false);
var planeB:Mesh = new Plane(_material, 100, 100, 1, 1, false);
var _merge:Merge = new Merge(false, false, false);
for (var i:uint = 0; i < size; ++i)
{
for (var j:uint = 0; j < size; ++j)
{
planeB.moveTo(100 * i, 0, 100 * j);
_merge.apply(planeA, planeB);
}
}
_map = planeA;
_view.scene.addChild(_map);
}
2011/5/11 rjgtav <[email protected]>
> New test: with no cloning, just adding the cubes, this time it took 5s less
> and uses a little less ram. This time i was able to control my character,
> and for my surprise, it looks like it filled all the empty space! I'll try
> to explain my map:
>
> My map is made of 5 layers:
> The 1st one is a 50x50 cubes, which represent the floor.
> Then the rest have only cubes around the 50x50 square created in the 1st
> layer.
>
> For example (the map is seen from above):
>
> Layer 1: The rest of the layers:
>
> [1, 1, 1, 1, 1] [2, 2, 2, 2, 2]
> [1, 1, 1, 1, 1] [2, 0, 0, 0, 2]
> [1, 1, 1, 1, 1] [2, 0, 0, 0, 2]
> [1, 1, 1, 1, 1] [2, 0, 0, 0, 2]
> [1, 1, 1, 1, 1] [2, 2, 2, 2, 2]
>
> Legend:
> 0 - Empty tile
> 1 - Floor
> 2 - Wall
>
> And when i test, the wall cubes fill the empty area and also seem to go
> much farther than the actual map size. Important Note: The ground and wall
> tiles have different materials and i'm applying them to *the same mesh*,
> and they show the correct materials.
>
> *UPDATE:*
>
> Just what i thought. Now i tried apllying the floor cubes to a *floorMesh*and
> the wallCubes to a
> *wallMesh* and all works smoothly (even better fps - 25 - over the max!,
> just 9mb of ram and the same 9000 polys).
>
> Conclusion: Is this a bug or do i really need to create a mesh for each
> type of cube?
>