How to create a polygon with a texture?

Software: Away3D 3.x

Oleg1984, Newbie
Posted: 21 February 2012 01:39 PM   Total Posts: 11

Hello,
I’m using away3d 3.6 and try to create a simply polygon with a texture. It’s an simply 2D-square with 8 3D-points and a hole inside. I can’t use the plane primitive or something else because I also have to create planes with rounded corners.
I’ve created a mesh and added a Face with 8 points (with moveTo and lineTo). When I use the WireColorMaterial as material, it looks fine. I see my square with the specified line and fill color. The hole in the square is also ok.
Then I used the BitmapMaterial as material. I have set the uv0, uv1 and uv2 coordinates of the face. But I just see the top-left triangle of my square with the selected bitmap. How can I draw a custom polygon(or Face) and put a texture on it? I tried to use RegularPolygon but it does not work for me because I have random connected points and have to put a texture on it. I have uploaded a screenshot and the code is below. Thanks for help!

var away3DMaterial:BitmapMaterial = new BitmapMaterial(Cast.bitmap(away3DBitmap), {smooth:trueprecision:2});
   var 
lineMaterial WireColorMaterial= new WireColorMaterial();
   
lineMaterial.color 0xFFFFFF;
   
lineMaterial.wireColor 0x00FF00;
   
lineMaterial.thickness 1;
   
   var 
mesh Mesh = new Mesh();
   
mesh.bothsides true;
   
   var 
polygonFace = new Face();
   
polygon.material=away3DMaterial
   
   
polygon.moveTo(-50,-50,0);
   
polygon.lineTo(-50,50,0);
   
polygon.lineTo(50,50,0);
   
polygon.lineTo(50,-50,0);
   
polygon.lineTo(-50,-50,0);   
   
polygon.moveTo(-25,-25,0);
   
polygon.lineTo(-25,25,0);
   
polygon.lineTo(25,25,0);
   
polygon.lineTo(25,-25,0);
   
polygon.lineTo(-25,-25,0);
   
   
polygon.uv0=new UV(0,0);
   
polygon.uv1=new UV(0,1); 
   
polygon.uv2=new UV(1,1);

   
mesh.addFace(polygon);
   
group.addChild(mesh); 

 

 

   

Oleg1984, Newbie
Posted: 22 February 2012 09:10 AM   Total Posts: 11   [ # 1 ]

Is this not possible in away3d? The problem is, that I can’t use external applicatons to create the mesh data and import it in away3d, because the coordinates are loaded dynamicly from a xml-file…
Or is it possible to convert the face to triangles? I saw it in the Facehelper in version 4 but I would like to use 3.6…

   

Oleg1984, Newbie
Posted: 24 February 2012 11:51 AM   Total Posts: 11   [ # 2 ]

Ok, I don’t need help because I solved my problem grin Now I can create and triangulate custom polygons with a texture…

   

RiaanWest, Newbie
Posted: 05 March 2012 03:31 PM   Total Posts: 3   [ # 3 ]

Hey Oleg1984, would you mind sharing some of your new-found knowledge? I’m trying to do something similar to you… smile

   

DigitalVanilla, Newbie
Posted: 20 April 2012 08:05 AM   Total Posts: 9   [ # 4 ]

Guys, im havign the same problem.
Oleg, how did you sove it?

   

JinGT, Newbie
Posted: 23 April 2012 08:54 PM   Total Posts: 1   [ # 5 ]

//soy nuevo en away no se si este sea el metodo que deba usarse o no
//pero es de la forma que me funciono
//espero les ayude en algo

//creando el material
var away3DMaterial:BitmapMaterial = new BitmapMaterial(Cast.bitmap(away3DBitmap), {smooth:true, precision:2});
var lineMaterial : WireColorMaterial= new WireColorMaterial();
lineMaterial.color = 0xFFFFFF;
lineMaterial.wireColor = 0x00FF00;
lineMaterial.thickness = 1;

//creando el mesh object
var mesh:Mesh = new Mesh();
mesh.bothsides = true;//creo que esto es para crear las dor caras
//para la prueba esta bien pero en
//solidos completos no creo que sea necesario

//creando los verics para el cuadrado
//el editor 3d debe calcular las posiciones de los veritces
var a:Vertex = new Vertex(-50,50,50);
var b:Vertex = new Vertex(-50,-50,50);
var c:Vertex = new Vertex(50,-50,50);
var d:Vertex = new Vertex(50,50,50);

//las axisUVs no son las UVs, las UVs se calculan en base a las AxisUV
//creando las uv, estas deben estar calculadas en funcion al axisUV
//del programa editor usado, con rotacion y zoom,
//y al ancho y alto de la imagen
var uva=new UV(0,0);
var uvb=new UV(0,1);
var uvc=new UV(1,1);
var uvd=new UV(1,0);

//creando una face triangular
var tFace1:Face = new Face();
tFace1.material=away3DMaterial;

//asignando los vertices
tFace1.v0 = a;
tFace1.v1 = b;
tFace1.v2 = c;
//asignando las uv para cada vertice
tFace1.uv0=uva;
tFace1.uv1=uvb;
tFace1.uv2=uvc;

//creando una face triangular
var tFace2:Face = new Face();
tFace2.material=away3DMaterial;

//asignando los vertices
tFace2.v0 = a;
tFace2.v1 = c;
tFace2.v2 = d;
//asignando las uv para cada vertice
tFace2.uv0=uva;
tFace2.uv1=uvc;
tFace2.uv2=uvd;

//agregando las face triangulares al mesh y creando el cuadrado
//el mesh tendra tantos triangulos como sean necesarios
mesh.addFace(tFace1);
mesh.addFace(tFace2);
scene.addChild(mesh);

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X