There is a bug in Cylinder.as which causes the UV mapping to be off-by-
one segment. Instead of V going from 0-1, it goes from 0 to
(segmentsH-1)/segmentsH.
There is also a loop invariant I factored out.
Here is the patch. Since the PV3D source is read-only I wasn't sure
how else to propagate this change. Please advise on correct process
for submitting patches.
Alan
Index: papervision3d/objects/primitives/Cylinder.as
===================================================================
--- papervision3d/objects/primitives/Cylinder.as (revision 910)
+++ papervision3d/objects/primitives/Cylinder.as (working copy)
@@ -136,17 +136,24 @@
for (j=0;j<iVerNum;j++) {
var iHorNum:int = aVtc[j].length;
+ // UV-mapping for Y
+ // y vertice now is z from above;
normalize it to height of cylinder
+ //var fJ0:Number = (aVtc[j][0].y +
(fHeight/2)) / fHeight;
+ //var fJ1:Number = (aVtc[j-1][0].y +
(fHeight/2)) / fHeight; // refactors to below
+ if(j>0)
+ {
+ var fJ0:Number = aVtc[j][0].y/
fHeight + 0.5; // move outside this loop
+ var fJ1:Number = aVtc[j-1]
[0].y/fHeight + 0.5; // move outside this loop
+ }
for (i=0;i<iHorNum;i++) {
if (j>0&&i>=0) {
+ var
lastIVertex:Boolean = (i === iHorNum - 1);
// select vertices
- var bEnd:Boolean =
i==(iHorNum-0);
- aP1 = aVtc[j][bEnd?0:i];
- aP2 = aVtc[j][(i==0?
iHorNum:i)-1];
- aP3 = aVtc[j-1][(i==0?
iHorNum:i)-1];
- aP4 = aVtc[j-1][bEnd?
0:i];
- // uv
- var fJ0:Number =
j / iVerNum;
- var fJ1:Number =
(j-1) / iVerNum;
+ aP1 = aVtc[j]
[lastIVertex ? 0 : i+1];
+ aP2 = aVtc[j][i];
+ aP3 = aVtc[j-1][i];
+ aP4 = aVtc[j-1]
[lastIVertex ? 0 : i+1];
+ // UV-mapping for X
var fI0:Number = (i
+1) / iHorNum;
var fI1:Number =
i / iHorNum;
aP4uv = new
NumberUV(fI0,fJ1);
@@ -158,7 +165,7 @@
aFace.push( new
Triangle3D(this, [aP1,aP3,aP4], matInstance, [aP1uv,aP3uv,aP4uv]) );
}
}
- if (j==0||j==(iVerNum-1)) {
+ if ((fBottomFace || fTopFace) &&
(j==0||j==(iVerNum-1))) { // draw top & bottom faces from top &
bottom set of vertexes
for (i=0;i<(iHorNum-2);i++) {
// uv
var iI:int =
Math.floor(i/2);
_______________________________________________
Papervision3D mailing list
[hidden email]
http://osflash.org/mailman/listinfo/papervision3d_osflash.org