Hello people,
I’m trying to make a sphere of wich each poly is skinnable with a different texture. So what I’m trying to do is to get each poly of a SphereGeometry in a different SubMesh.
I’m stuck on the vertexNormalData and the UV’s, I don’t see the cohesion of the number of poly’s and the number of vertexNormalData and UV’s.
The code below works, and the AwayStats tool tells me the correct number of poly’s is on the stage, but I don’t see anything. As I understand I need too add the UV’s and normalData also.
Can somebody help me out? Thanks in advance!
var indexData:Vector.<uint> = sph.subGeometries[0].indexData;
var vertexData:Vector.<Number> = sph.subGeometries[0].vertexData;
var UVData:Vector.<Number> = sph.subGeometries[0].UVData;
var vertexNormalData:Vector.<Number> = sph.subGeometries[0].vertexNormalData;
var newIndexData:Vector.<uint> = new Vector.<uint>();
newIndexData.push(0,1,2,3,4,5,6,7,8);
var newVertexData:Vector.<Number> = new Vector.<Number>();
var newVertexNormalData:Vector.<Number> = new Vector.<Number>();
trace (indexData.length + " " + vertexNormalData.length +" "+ sph.subGeometries[0].numVertices +" "+ sph.subGeometries[0].numTriangles +" "+ UVData.length);
for(var i:int = 0; i < indexData.length / 3; ++i){//each i is one triangle
var v0index:int = indexData[i * 3] * 3;//3 numbers per vertex, so index 1, starts at index 3 in the vector
var v1index:int = indexData[i * 3 + 1] * 3;
var v2index:int = indexData[i * 3 + 2] * 3;
var v0:Vertex = new Vertex(
vertexData[v0index],//x
vertexData[v0index+1],//y
vertexData[v0index+2]);//z
var v1:Vertex = new Vertex(
vertexData[v1index],//x
vertexData[v1index+1],//y
vertexData[v1index+2]);//z
var v2:Vertex = new Vertex(
vertexData[v2index],//x
vertexData[v2index+1],//y
vertexData[v2index+2]);//z
newVertexData.push(v0.x,v0.y,v0.z,v1.x,v1.y,v1.z,v2.x,v2.y,v2.z);
var sub:SubGeometry = new SubGeometry();
sub.updateIndexData(newIndexData);
sub.updateVertexData(newVertexData);
//sub.updateUVData(UVData);
//sub.updateVertexNormalData(vertexNormalData);
msh.geometry.addSubGeometry(sub);
newVertexData = new Vector.<Number>();
}
View.scene.addChild(msh);