Hi every one. I’m trying render pointCloud from kinect device using planeGeometry vertexData. And i’m get stuck with understanding of amount of vertices.
function initPointCloud():void
{
//Create plane geaometry with 320/240 width/height & equal segments
var geometry:PlaneGeometry = new PlaneGeometry(320,240,320,240);
//Create plane mesh (planeMaterial is defined earlier)
var mesh:Mesh = new Mesh(geometry,planeMaterial);
//Create vector for my pointCloud vertices
var vertices:Vector.<Number> = new Vector.<Number>();
//pointCloud instance of ByteArray
pointCloud.position=0;
//Filling vertices by data
while(pointCloud.bytesAvailable>0)
{
var x:Number = Number(pointCloud.readUnsignedByte());
x += pointCloud.readUnsignedByte() << 8;
var y:Number = Number(pointCloud.readUnsignedByte());
y += pointCloud.readUnsignedByte() << 8;
var z:Number = Number(pointCloud.readUnsignedByte());
z += pointCloud.readUnsignedByte() << 8;
vertices.push(x);
vertices.push(y);
vertices.push(z*0.1);
}
//Here is the part that i can not understand and which contains an issue
//new vertices length = 76800 (yes because 320*240 = 76800),
//old vertices length = 1005693 !!!!!!!!!!!!!!!!!!!!! WHY????? i was created a plane geometry whit 320/240 segments! How!
log("new vertices length =",vertices.length,"old vertices length =",(mesh.geometry.subGeometries[0] as CompactSubGeometry).vertexData.length);
(mesh.geometry.subGeometries[0] as CompactSubGeometry).updateData(vertices);
pointCloudContainer.addChild(mesh);
view.scene.addChild(pointCloudContainer);
//logging
log("initPointCloud OK");
//Render 3d. Here i get an error.
renderPointCloud();
}