ok, a basic triangle:
a face has 3 points defining its corners in space.
each point has 3 values: x,y,z
these coordinates are stored in vector<Number> that you can get via Subgeometry vertexData method.
so in the vector if we have a 1 face you have [x,y,z,x,y,z,x,y,z]
Now in order to pinpoint a given vertex in this vector, we have another buffer (Vector): the indices. Each entry represent the x value of a vertex into the vertices vector. So for a single face the entries will be [0,1,2]
indice[0] *3 give us 0—> the x of first vertex
indice[1] *3 give us 3—> the x of the second
indice[2] *3 give us of course the last one.
if you would want to trace the “v1.x” (the second vertex x value)
you would need to do this: vertices[indices[1]]
by reading an indice[index] and multiplying by 3, you can this way know where a vertex is stored. You could be able as well to retreive its uv value by muliplying by 2 instead of 3 as uvs are stored per pair.
But in your case, you do not work at vertex level… Good news is, its exactly the same. Let take a cube or whatever mesh you have. Its definition is nothing else than long series of vertices, uvs, indices, normals etc… all perfectly ordered with each other.
Your original question was: I have now made a big long vector of all the cubes I’ve made. Now I want retrieve one of them and change some props on one of them.
k, lets change cube1 position on x.
so again, lets store the data has we build/merge
loop
make a cubeData object
cubedata.startIndex = receivermesh.geometry.subGeometries[0].verdataData.length;
Merge.apply(receivermesh, cube);
cubedata.endIndex = receivermesh.geometry.subGeometries[0].verdataData.length;
we save the cubedata. cubesData.push(cubedata);
you have now a cubesdata[cubedata,cubedata,cubedata,cubedata etc]
now you want move the representation of the second one in your big merged mesh on x.
secondCube = cubesdata[1];
where does this baby starts to exists in the vertices buffer? at cubesdata[1].startIndex
so now if you do:
var vertices:Vector.<Number> - receivermesh.geometry.subGeometries[0].vertexData;
loop over vertices while its lower than cubedata.endIndex
you can alter each values of the cube…
but wait, how do you tell for sure its the x value that we want to update?
If your mesh has shared vertices (like the cubeGeometry), how do you make sure you are updating what you want? simply by “extrapolating” the indice by the info that do have.
indice = cubedata.startIndex/3;
the indice of the first vertice, the x value is indices[cubedata.startIndex/3]
the equivallent of
receivermesh.geometry.subGeometries[0].indices[cubedata.startIndex/3];
so if you loop over the receiver indices buffer from this pointer instead of the vertices. and iterate with a i+=3, you can for sure update the x value the exact cube that you want.
once done, you need to update the subgeometry:
receivermesh.geometry.subGeometries[0].updateVertexData;
It was a long answer… Hope it wil help you to undertand the principle. You could try to build a simple face using MeshHelper build method to see how it works…
k, now time to enjoy a beer…