no, the uv's are like percentage, except its 0/1
you can use distance, take a look at pathExtrude but its there to
distribute evenly on one plan.
basically
x on map, from left = u 0 --> 1 right
y on map, from top = v 1 --> 0 down
Fabrice
On Jun 25, 2009, at 4:00 PM, routine wrote:
Hey guys,
there's something wrong with my UV coordinate calculation.
Just imagine the following setup:
I have a bitmap with the size of 100x100px.
For simplicitys sake I just want to draw a plane with the size of
100x100px
with this bitmap as material on its faces.
To draw the plane I'm using away3d's Mesh class and its mehtod
"addFace()".
I know I can get a plane much easier when using away3d's Plane class,
but I only try to draw a plane right now, later-on it will be a much
more complex Mesh.
To build the vertices for the first face I did this:
var v0 : Vertex = new Vertex(0,0,0);
var v1 : Vertex = new Vertex(0,100,0);
var v2 : Vertex = new Vertex(100,0,0);
to set up the uv's I have to calclulate the distances between the
vertices, right?
so I did something like this...
var v0v1dist:Number = Math.sqrt((v1.x - v0.x) * (v2.x - v0.x) +
(v1.y - v0.y) * (v1.y - v0.y) + (v1.z - v0.z) * (v1.z - v0.z));
trace(v0v1dist) -> 100
var v0v2dist:Number = Math.sqrt((v2.x - v1.x) * (v2.x - v1.x) +
(v2.y - v1.y) * (v2.y - v1.y) + (v2.z - v1.z) * (v2.z - v1.z));
trace(v0v2dist) -> 100
to set up the uv's like this
var u0 : UV = new UV(0,0);
var u1 : UV = new UV( v0v1dist, 0);
var u2 : UV = new UV( v0v1dist, v0v2dist );
finally I've added the first face like this while "material" is my
bitmap material i've setted up before.
front.addFace(new Face( v0, v1, v2, material, u0, u1, u2));
The problem resulting from this is, that the face only shows the
first pixel of the bitmap material.
I know this, because I've tested it with drawing a red pixel on x=1
and y=1 on the bitmap and it is not displayed.
When I draw it on x=0 and y=0 the whole face will be displayed red.
Can you see where I make misstakes? Any suggestions?
Thank you