Texture on Irregular Polygon

Software: Away3D 4.x

edmunddantes, Newbie
Posted: 29 March 2013 01:41 PM   Total Posts: 1

Hi. I have a small problem with texturing polygon created from subgeometries.

My code :(argument array is array of points which are vertexes of the polygon in 2d)

public function drawFloor(tab:Array):Mesh {
 
var triangles:Array = EarCutting.cut(tab);
 var 
segments:Array = EarCutting.buildSegments(tab);
 var 
s:Segment;  
  
 var 
vertices:Vector.<Number> = new Vector.<Number>;
 var 
indices:Vector.<uint> = new Vector.<uint>;
 var 
uvs:Vector.<Number> = new Vector.<Number>;
     
 var 
t:Triangle;
 var 
count:uint 0;
 for 
eacht in triangles ){
  indices
.push(count,++count,++count);
  
vertices.push(t.p0.y0t.p0.xt.p1.y0t.p1.xt.p2.y0t.p2.x);
  
count++;
 
}    
 
var _numUvs:uint = (triangles.length 2) + (segments.length 2);
 for(var 
i:uint 0_numUvsi++){
  uvs
.push(000011);
         
}
   
 
var subGeometry:SubGeometry = new SubGeometry();
 
subGeometry.updateVertexData(vertices);
 
subGeometry.updateUVData(uvs);
 
subGeometry.updateIndexData(indices);
 
subGeometry.autoDeriveVertexTangents  true;
 
subGeometry.autoDeriveVertexNormals true
   
var 
colorMaterial:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(new TestPodloga),true,true)  
 
colorMaterial.bothSides true
 colorMaterial
.repeat true  
       
 
var geometry:Geometry = new Geometry();
 
geometry.addSubGeometry(subGeometry);        
 var 
mesh:Mesh MeshHelper.build(verticesindicesuvs"floor"colorMaterialtruefalse);

 
mesh.mouseEnabled true
 mesh
.addEventListener(MouseEvent3D.MOUSE_DOWNklik_floor)
 
mesh.name "floor"
 
return mesh
   

It draws polygon well, but texture is bad (left picture)
How can i get it right - like on the right side of the picture?
Is it possible in away3d 4 ?

 

   

tjart, Newbie
Posted: 25 April 2013 01:26 PM   Total Posts: 1   [ # 1 ]

Mesh.geometry.scaleUV(scaleNumX,scaleNumZ)

This may be the line of code you’re looking for.

   

baggaamit, Newbie
Posted: 21 August 2013 12:37 AM   Total Posts: 3   [ # 2 ]

where you able to solve the issue this?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X