Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
fix uv and stacks 0 problem
Browse files Browse the repository at this point in the history
  • Loading branch information
akjava committed Jul 7, 2016
1 parent 415b0ca commit ff13c63
Showing 1 changed file with 33 additions and 9 deletions.
Expand Up @@ -385,7 +385,8 @@ public Geometry createGeometry(List<Vector3> points,int slices,double thick,bool
primaryFirstTop=a;
primaryLastTop=d;
}
else if(i==stacks-1){
if(i==stacks-1){

primaryFirstBottom=b;
primaryLastBottom=c;
}
Expand All @@ -400,15 +401,18 @@ else if(i==stacks-1){
primaryFirstTop=a;
primaryLastTop=d;
}
else if(i==stacks-1){
if(i==stacks-1){

primaryFirstBottom=b;
primaryLastBottom=c;
}
}


}

for ( double i = 0; i < stacks; i ++ ) {

int j=0;
int j2=slices;
int a = (int)(i * sliceCount + j)+frontGeometrySize;
Expand All @@ -433,8 +437,9 @@ else if(i==stacks-1){
secondaryFirstTop=a;
secondaryLastTop=d;
}
else

if(i==stacks-1){

secondaryFirstBottom=b;
secondaryLastBottom=c;
}
Expand All @@ -449,21 +454,22 @@ else if(i==stacks-1){
secondaryFirstTop=a;
secondaryLastTop=d;
}
else

if(i==stacks-1){

secondaryFirstBottom=b;
secondaryLastBottom=c;
}
}


}
if(thick!=0){
//add bottom
Vector2 uva = getUv(slices+1,0);
if(thick!=0 ){

Vector2 uva = getUv(slices,0);
Vector2 uvb = getUv(slices+1,0);
Vector2 uvc = getUv(slices+1,0);
Vector2 uvd = getUv(slices+1,0);
Vector2 uvd = getUv(slices,0);
//LogUtils.log("top:"+primaryFirstTop+","+primaryLastTop+","+secondaryFirstTop+","+secondaryLastTop);

//set first
Expand All @@ -479,19 +485,35 @@ else if(i==stacks-1){
int d=secondaryLastTop;

if(flipNormal){
LogUtils.log("flip-top "+a+","+b+","+c+","+d);
geometry.getFaces().push( THREE.Face3( d, b, a ) );
pushUv(uvs, uvd, uvb, uva );
geometry.getFaces().push(THREE.Face3( d, c, b ) );
pushUv(uvs, uvd.clone(), uvc, uvb.clone());

ThreeLog.log("a",geometry.getVertices().get(a));
ThreeLog.log("b",geometry.getVertices().get(b));
ThreeLog.log("c",geometry.getVertices().get(c));
ThreeLog.log("d",geometry.getVertices().get(d));

ThreeLog.log("a",uva);
ThreeLog.log("b",uvb);
ThreeLog.log("c",uvc);
ThreeLog.log("d",uvd);

}else{
LogUtils.log("top "+a+","+b+","+c+","+d);
geometry.getFaces().push( THREE.Face3(a, b,d ) );
pushUv(uvs, uva, uvb, uvd );

geometry.getFaces().push( THREE.Face3( b ,c,d) );
pushUv(uvs, uvb.clone(), uvc, uvd.clone());

}

uva = getUv(slices,0);
uvb = getUv(slices+1,0);
uvc = getUv(slices+1,0);
uvd = getUv(slices,0);
//LogUtils.log("bottom:"+primaryFirstBottom+","+primaryLastBottom+","+secondaryFirstBottom+","+secondaryLastBottom);

//set bottom
Expand All @@ -506,12 +528,14 @@ else if(i==stacks-1){
d=secondaryLastBottom;

if(flipNormal){
LogUtils.log("flip-bottom "+a+","+b+","+c+","+d);
geometry.getFaces().push( THREE.Face3(a, b,d ) );
pushUv(uvs, uva, uvb, uvd );

geometry.getFaces().push( THREE.Face3( b ,c,d) );
pushUv(uvs, uvb.clone(), uvc, uvd.clone());
}else{
LogUtils.log("bottom "+a+","+b+","+c+","+d);
geometry.getFaces().push( THREE.Face3( d, b, a ) );
pushUv(uvs, uvd, uvb, uva );
geometry.getFaces().push(THREE.Face3( d, c, b ) );
Expand Down

0 comments on commit ff13c63

Please sign in to comment.