ben
unread,Sep 11, 2009, 7:35:15 PM9/11/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to away3d.dev
ALL APOLOGIZE !! ! !!!
I know where it comes from :
I have some custom fx property on my bitmapMaterial, it achieves
interesting material render or fake some others at low perf, all takin
place in the renderTriangle methid of the session and based on matrix
transformation.
With f10 I had to change my method and let the bitmapMaterial choose
btw two way of render depending on how fx property was set:
ex: the "refract" property is set :
in the renderTriangle method of BitmapMaterial I can swap btw two
renderTriangleBitmap Method (wher i can manage my matrix tricks), the
old and the F10 :
if(refract){
_session.renderTriangleBitmap(_bitmap, getMapping(tri), tri.v0,
tri.v1, tri.v2, smooth, repeat, _graphics,"refract");}
else {_session.renderTriangleBitmapF10(_renderBitmap, getUVData(tri),
_screenVertices, _screenIndices, tri.startIndex, tri.endIndex, smooth,
repeat, _graphics);}
what I forgot, is that I'm a lazy boy:
when creating it as I couldn't find the old v0,v1,v2 of face, (or
something like that) in the old renderTriangleBitmap, I made some
change to it :
/**
* Draws a triangle element with a bitmap texture into the graphics
object.
*/
//public function renderTriangleBitmap(bitmap:BitmapData,
map:Matrix, screenVertices:Array, screenIndices:Array,
startIndex:Number, endIndex:Number, smooth:Boolean, repeat:Boolean,
layerGraphics:Graphics = null):void
public function renderTriangleBitmap(bitmap:BitmapData,
map:Matrix, v0:ScreenVertex, v1:ScreenVertex, v2:ScreenVertex,
smooth:Boolean, repeat:Boolean, layerGraphics:Graphics =
null,fx:Boolean = false):void
{
if (!layerGraphics && _layerDirty)
createLayer();
//// <----------ben mod, in order to use screenVertex
a2 = (v1x = v1.x) - (v0x = v0.x);
b2 = (v1y = v1.y) - (v0y = v0.y);
c2 = (v2x = v2.x) - v0x;
d2 = (v2y = v2.y) - v0y;
m.a = (a = map.a)*a2 + (b = map.b)*c2;
m.b = a*b2 + b*d2;
m.c = (c = map.c)*a2 + (d = map.d)*c2;
m.d = c*b2 + d*d2;
m.tx = (tx = map.tx)*a2 + (ty = map.ty)*c2 + v0x;
m.ty = tx*b2 + ty*d2 + v0y;
//<---------------END
/*
_index0 = screenIndices[startIndex]*3;
_index1 = screenIndices[startIndex+1]*3;
_index2 = screenIndices[startIndex+2]*3;
a2 = (v1x = screenVertices[_index1]) - (v0x = screenVertices
[_index0]);
b2 = (v1y = screenVertices[_index1+1]) - (v0y = screenVertices
[_index0+1]);
c2 = (v2x = screenVertices[_index2]) - v0x;
d2 = (v2y = screenVertices[_index2+1]) - v0y;
m.a = (a = map.a)*a2 + (b = map.b)*c2;
m.b = a*b2 + b*d2;
m.c = (c = map.c)*a2 + (d = map.d)*c2;
m.d = c*b2 + d*d2;
m.tx = (tx = map.tx)*a2 + (ty = map.ty)*c2 + v0x;
m.ty = tx*b2 + ty*d2 + v0y;
*/
///// just a trick for fx
if(fx) {m.scale(.5,.5);repeat = true;};
area = v0x*(d2 - b2) - v1x*d2 + v2x*b2;
if (area < 0)
area = -area;
if (layerGraphics) {
layerGraphics.lineStyle();
layerGraphics.moveTo(v0x, v0y);
layerGraphics.beginBitmapFill(bitmap, m, repeat, smooth
&& area > 400);
layerGraphics.lineTo(v1x, v1y);
layerGraphics.lineTo(v2x, v2y);
layerGraphics.endFill();
} else {
graphics.lineStyle();
graphics.moveTo(v0x, v0y);
graphics.beginBitmapFill(bitmap, m, repeat, smooth &&
area > 400);
graphics.lineTo(v1x, v1y);
graphics.lineTo(v2x, v2y);
graphics.endFill();
}
}
and the fact is that go back to the old v0,v1 seems to make the z
sorting incorrect.
I have to pass screenVertices, screenIndices, startIndex,... instead.
And I don't understand why I didn't ???
I'll have to take a look at it because it seems that I could use them
at first... Lazyness, or something that is out of my mind when writing
now...
I'll maybe have questions about it !
thanks again Rob !