PlaneGeometry segments understanding

Software: Away3D 4.x

rusoturisto, Newbie
Posted: 13 August 2013 08:35 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 of amount of segments?

   

rusoturisto, Newbie
Posted: 15 August 2013 08:13 AM   Total Posts: 5   [ # 1 ]

Seems like i start understand of something.
1005693 = (segmentsW+1)*(segmentsH+1)*vertexStride

 

   

Avatar
80prozent, Sr. Member
Posted: 15 August 2013 09:57 PM   Total Posts: 430   [ # 2 ]

Hi

yes
thats caused by the CompactSubGeometry

it has one big vector to store all the data needed (position/uv/normals/tangents)
this makes for a better performance on the GPU, but if you try to check the vertexData.length, it do not give back the correct number of vertices…
use the CompactSubGeometry.numVertices to get the acctual number of vertices.

hope that helps

 

 Signature 

sorry…i hope my actionscript is better than my english…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X