hey Jordi,
this was bugging me,
so spend few minutes to see...
works perfectly :)
Fabrice
code :
private function buildTest():void
{
var mat:BitmapMaterial = new BitmapMaterial(somebitmapdatafor
map6); //for test on my machine
var subd:int = 6;
var cube:Cube = new Cube({map6:true, width:1500, height:1500, depth:
1500, material:mat, segmentsW:subd, segmentsH:subd});
var startH:Number = 1000;
var factor:Number = 1500/startH;
var step:Number = factor/subd;
var sortedV:Array = (cube as Mesh).vertices.concat();
sortedV.sortOn("x", 16);
var basex:Number;
var l:int = sortedV.length;
var dico:Dictionary = new Dictionary();
for (var i:int = 0;i< l;++i){
basex = Math.floor(sortedV[i].x);
while(i<l && Math.floor(sortedV[i].x) == basex){
//make sure its applied only once
if(!dico[sortedV[i]]){
dico[sortedV[i]] = true;
(cube as Mesh).updateVertex(sortedV[i], sortedV[i].x,
sortedV[i].y*factor, sortedV[i].z);
}
i++;
}
i--;
if(!dico[sortedV[i]]){
dico[sortedV[i]] = true;
(cube as Mesh).updateVertex(sortedV[i], sortedV[i].x,
sortedV[i].y*factor, sortedV[i].z);
}
factor+= step;
}
this.scene.addChild(cube);
}
On Nov 3, 2009, at 10:10 AM, jordi monty wrote:
Hi,
I've a cube that I transform to a "trapezoid":
cube = new Cube( {ownCanvas:true});
cube.width=5;
cube.height=20;
cube.depth=2;
cube.vertices[0].y*=0.5;
cube.vertices[1].y*=0.5;
cube.vertices[4].y*=0.5;
cube.vertices[5].y*=0.5;
I want to apply this matrix texture:
http://marcosamedida.tecnopixel.com/texture.jpg
When my cube is a cube, the texture remains as a matrix, but when I
modify the vertices, the texture is deformed.
You can see it:
http://marcosamedida.tecnopixel.com/away3d.swf
I've also tried with TransformBitmapMaterial with globalprojections
and projectionvector, but I cannot get it.
Can anyone help me,please?