Hi guys!
I’m trying to merge a group of textured planes. Some with the same materials and others with the unique materials.
I can’t figure out how to get a vertices of 1 separate plane to move it.
This is working for all planes (modified MergeTest.as example):
private function populateWithVectorsMass() : void {
..
{
..
meshes.push(Mesh(plane));
}
..
meshResult = merge.applyToMeshes(Mesh(meshes.shift()), meshes);
private function handleEnterFrame(e:Event):void {
..
for each(var sub:SubMesh in meshResult.subMeshes)
{
var buffer:VertexBuffer3D = sub.getVertexBuffer(Stage3DManager.getInstance(stage).getStage3DProxy(0));
var vec:Vector.<Number> = sub.subGeometry.vertexData;
var random:Number = Math.random();
for(var i:uint = 0 ; i < vec.length ; i += 3)
{
var amount:Number = random * 40 - 20;
vec[i] += amount; //x
vec[i + 1] += amount; //y
vec[i + 2] += amount; //z
}
buffer.uploadFromVector(vec, 0, vec.length / 3);
}
I thought that 1 segment plane has 12 vertex coordinates (4 vertices * 3 coordinates). So, first at 0-12, second at 12-24 and so on. But I was wrong. First at 0-12, but second at 12-28 and third at 28-46! Wtf, I can’t understand that((
Another problem with materials. plane.material that was before merging != sub.material :( So I don’t know how to get vertex coordinates for a plane and how to get a proper subMesh from a merged mesh. Any ideas?