Custom polygon shape

Software: Away3D 4.x

yyovchev, Newbie
Posted: 13 July 2012 06:57 PM   Total Posts: 29

I am pretty sure I am doing it wrong but I don’t understand how this works. Please anyone explain to me what are indices and how are they calculated and how to get this example to work.

var vertexes:Vector.<Number> = new Vector.<Number>;
  
vertexes.push(4,0,-4);
 
vertexes.push(1014,0,-4);
 
vertexes.push(1014,0,-1623);
 
vertexes.push(727,0,-1794);
 
vertexes.push(291,0,-1794);
 
vertexes.push(4,0,-1623);


      var 
normals:Vector.<Number> = new Vector.<Number>;
        
normals.push(0,1,0);
        
normals.push(0,1,0);
 
normals.push(0,1,0);
 
normals.push(0,1,0);
 
normals.push(0,1,0);
 
normals.push(0,1,0);
   
      
      var 
uvs:Vector.<Number> = new Vector.<Number>;
      
uvs.push(0,1);
      
uvs.push(0,1);
      
uvs.push(0,1);
      
uvs.push(0,1);
      
uvs.push(0,1);
      
uvs.push(0,1);
     
      var 
indices:Vector.<uint> = Vector.<uint>([0,1,2,3,4,5]);
    
      var 
subGeometry:SubGeometry = new SubGeometry();
      
subGeometry.updateVertexData(vertexes);
      
subGeometry.updateVertexNormalData(normals);
      
subGeometry.updateUVData(uvs);
      
subGeometry.updateIndexData(indices);
      
      var 
geometry:Geometry = new Geometry();
      
geometry.addSubGeometry(subGeometry);
        
      var 
sphere:SphereGeometry = new SphereGeometry();
     
      var 
mesh:Mesh = new Mesh(geometryfloorMat);
      
scene.addChild(mesh); 
   

yyovchev, Newbie
Posted: 13 July 2012 09:24 PM   Total Posts: 29   [ # 1 ]

Ok I understood this by myself

var indices:Vector.<uint> = Vector.<uint>([0,1,20,2,30,3,40,4,5]); 

Is there any way this to be done dynamically because I receive vertex coordinates from elsewhere?

   

yyovchev, Newbie
Posted: 14 July 2012 12:38 AM   Total Posts: 29   [ # 2 ]

Its done. Using this: http://actionsnippet.com/?p=1462 for triangulation I make this dynamic and now I can draw custom surfaces!

   

lanceaeby, Newbie
Posted: 18 July 2012 07:26 PM   Total Posts: 8   [ # 3 ]

Did you get this working in 3D?  The example link you posted only deals with drawing a 2D polygon.  My team and I are also looking to draw custom shapes from a bunch of dynamically generated points.  Any help/insight you have would be greatly appreciated.

   

yyovchev, Newbie
Posted: 18 July 2012 07:48 PM   Total Posts: 29   [ # 4 ]

In my case I needed custom 2D polygon and this triangulation class was perfect for me. I am not shure for 3D maybe someone else could suggest something.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X