PlaneGeometry segments understanding

Software: Away3D 4.x

rusoturisto, Newbie
Posted: 13 August 2013 08:32 PM   Total Posts: 5

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());
        
+= pointCloud.readUnsignedByte() << 8;
        var 
y:Number Number(pointCloud.readUnsignedByte());
        
+= pointCloud.readUnsignedByte() << 8;
        var 
z:Number Number(pointCloud.readUnsignedByte());
        
+= 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. RangeError: Error #1125: The index 230400 is out of range 230400.
    
renderPointCloud();

Why the amount of vertex is less then amount of segments?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X