fixed some normal calc issues in LODGeomap
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9252 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
f06b1dfa4d
commit
ee69225ad0
@ -798,76 +798,71 @@ public class LODGeomap extends GeoMap {
|
|||||||
for (int r = 0; r < getHeight(); r++) {
|
for (int r = 0; r < getHeight(); r++) {
|
||||||
for (int c = 0; c < getWidth(); c++) {
|
for (int c = 0; c < getWidth(); c++) {
|
||||||
|
|
||||||
rootPoint.set(c, getValue(c, r), r);
|
rootPoint.set(0, getValue(c, r), 0);
|
||||||
Vector3f normal = vars.vect8;
|
Vector3f normal = vars.vect8;
|
||||||
|
|
||||||
if (r == 0) { // first row
|
if (r == 0) { // first row
|
||||||
if (c == 0) { // first column
|
if (c == 0) { // first column
|
||||||
rightPoint.set(c + 1, getValue(c + 1, r), r);
|
rightPoint.set(1, getValue(c + 1, r), 0);
|
||||||
bottomPoint.set(c, getValue(c, r + 1), r + 1);
|
bottomPoint.set(0, getValue(c, r + 1), 1);
|
||||||
getNormal(bottomPoint, rootPoint, rightPoint, scale, normal);
|
getNormal(bottomPoint, rootPoint, rightPoint, scale, normal);
|
||||||
} else if (c == getWidth() - 1) { // last column
|
} else if (c == getWidth() - 1) { // last column
|
||||||
leftPoint.set(c - 1, getValue(c - 1, r), r);
|
leftPoint.set(-1, getValue(c - 1, r), 0);
|
||||||
bottomPoint.set(c, getValue(c, r + 1), r + 1);
|
bottomPoint.set(0, getValue(c, r + 1), 1);
|
||||||
getNormal(leftPoint, rootPoint, bottomPoint, scale, normal);
|
getNormal(leftPoint, rootPoint, bottomPoint, scale, normal);
|
||||||
} else { // all middle columns
|
} else { // all middle columns
|
||||||
leftPoint.set(c - 1, getValue(c - 1, r), r);
|
leftPoint.set(-1, getValue(c - 1, r), 0);
|
||||||
rightPoint.set(c + 1, getValue(c + 1, r), r);
|
rightPoint.set(1, getValue(c + 1, r), 0);
|
||||||
bottomPoint.set(c, getValue(c, r + 1), r + 1);
|
bottomPoint.set(0, getValue(c, r + 1), 1);
|
||||||
|
|
||||||
normal.set( getNormal(leftPoint, rootPoint, bottomPoint, scale, tmp1) );
|
normal.set( getNormal(leftPoint, rootPoint, bottomPoint, scale, tmp1) );
|
||||||
normal.add( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) );
|
normal.addLocal( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) );
|
||||||
normal.normalizeLocal();
|
|
||||||
}
|
}
|
||||||
} else if (r == getHeight() - 1) { // last row
|
} else if (r == getHeight() - 1) { // last row
|
||||||
if (c == 0) { // first column
|
if (c == 0) { // first column
|
||||||
topPoint.set(c, getValue(c, r - 1), r - 1);
|
topPoint.set(0, getValue(c, r - 1), -1);
|
||||||
rightPoint.set(c + 1, getValue(c + 1, r), r);
|
rightPoint.set(1, getValue(c + 1, r), 0);
|
||||||
getNormal(rightPoint, rootPoint, topPoint, scale, normal);
|
getNormal(rightPoint, rootPoint, topPoint, scale, normal);
|
||||||
} else if (c == getWidth() - 1) { // last column
|
} else if (c == getWidth() - 1) { // last column
|
||||||
topPoint.set(c, getValue(c, r - 1), r - 1);
|
topPoint.set(0, getValue(c, r - 1), -1);
|
||||||
leftPoint.set(c - 1, getValue(c - 1, r), r);
|
leftPoint.set(-1, getValue(c - 1, r), 0);
|
||||||
getNormal(topPoint, rootPoint, leftPoint, scale, normal);
|
getNormal(topPoint, rootPoint, leftPoint, scale, normal);
|
||||||
} else { // all middle columns
|
} else { // all middle columns
|
||||||
topPoint.set(c, getValue(c, r - 1), r - 1);
|
topPoint.set(0, getValue(c, r - 1), -1);
|
||||||
leftPoint.set(c - 1, getValue(c - 1, r), r);
|
leftPoint.set(-1, getValue(c - 1, r), 0);
|
||||||
rightPoint.set(c + 1, getValue(c + 1, r), r);
|
rightPoint.set(1, getValue(c + 1, r), 0);
|
||||||
|
|
||||||
normal.set( getNormal(topPoint, rootPoint, leftPoint, scale, tmp1) );
|
normal.set( getNormal(topPoint, rootPoint, leftPoint, scale, tmp1) );
|
||||||
normal.add( getNormal(rightPoint, rootPoint, topPoint, scale, tmp1) );
|
normal.addLocal( getNormal(rightPoint, rootPoint, topPoint, scale, tmp1) );
|
||||||
normal.normalizeLocal();
|
|
||||||
}
|
}
|
||||||
} else { // all middle rows
|
} else { // all middle rows
|
||||||
if (c == 0) { // first column
|
if (c == 0) { // first column
|
||||||
topPoint.set(c, getValue(c, r - 1), r - 1);
|
topPoint.set(0, getValue(c, r - 1), -1);
|
||||||
rightPoint.set(c + 1, getValue(c + 1, r), r);
|
rightPoint.set(1, getValue(c + 1, r), 0);
|
||||||
bottomPoint.set(c, getValue(c, r + 1), r + 1);
|
bottomPoint.set(0, getValue(c, r + 1), 1);
|
||||||
|
|
||||||
normal.set( getNormal(rightPoint, rootPoint, topPoint, scale, tmp1) );
|
normal.set( getNormal(rightPoint, rootPoint, topPoint, scale, tmp1) );
|
||||||
normal.add( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) );
|
normal.addLocal( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) );
|
||||||
normal.normalizeLocal();
|
|
||||||
} else if (c == getWidth() - 1) { // last column
|
} else if (c == getWidth() - 1) { // last column
|
||||||
topPoint.set(c, getValue(c, r - 1), r - 1);
|
topPoint.set(0, getValue(c, r - 1), -1);
|
||||||
leftPoint.set(c - 1, getValue(c - 1, r), r);
|
leftPoint.set(-1, getValue(c - 1, r), 0);
|
||||||
bottomPoint.set(c, getValue(c, r + 1), r + 1); //XXX wrong
|
bottomPoint.set(0, getValue(c, r + 1), 1);
|
||||||
|
|
||||||
normal.set( getNormal(topPoint, rootPoint, leftPoint, scale, tmp1) );
|
normal.set( getNormal(topPoint, rootPoint, leftPoint, scale, tmp1) );
|
||||||
normal.add( getNormal(leftPoint, rootPoint, bottomPoint, scale, tmp1) );
|
normal.addLocal( getNormal(leftPoint, rootPoint, bottomPoint, scale, tmp1) );
|
||||||
normal.normalizeLocal();
|
|
||||||
} else { // all middle columns
|
} else { // all middle columns
|
||||||
topPoint.set(c, getValue(c, r - 1), r - 1);
|
topPoint.set(0, getValue(c, r - 1), -1);
|
||||||
leftPoint.set(c - 1, getValue(c - 1, r), r);
|
leftPoint.set(-1, getValue(c - 1, r), 0);
|
||||||
rightPoint.set(c + 1, getValue(c + 1, r), r);
|
rightPoint.set(1, getValue(c + 1, r), 0);
|
||||||
bottomPoint.set(c, getValue(c, r + 1), r + 1);
|
bottomPoint.set(0, getValue(c, r + 1), 1);
|
||||||
|
|
||||||
normal.set( getNormal(topPoint, rootPoint, leftPoint, scale, tmp1 ) );
|
normal.set( getNormal(topPoint, rootPoint, leftPoint, scale, tmp1 ) );
|
||||||
normal.add( getNormal(leftPoint, rootPoint, bottomPoint, scale, tmp1) );
|
normal.addLocal( getNormal(leftPoint, rootPoint, bottomPoint, scale, tmp1) );
|
||||||
normal.add( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) );
|
normal.addLocal( getNormal(bottomPoint, rootPoint, rightPoint, scale, tmp1) );
|
||||||
normal.add( getNormal(rightPoint, rootPoint, topPoint, scale, tmp1) );
|
normal.addLocal( getNormal(rightPoint, rootPoint, topPoint, scale, tmp1) );
|
||||||
normal.normalizeLocal();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
normal.normalizeLocal();
|
||||||
BufferUtils.setInBuffer(normal, store, (r * getWidth() + c)); // save the normal
|
BufferUtils.setInBuffer(normal, store, (r * getWidth() + c)); // save the normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -897,11 +892,15 @@ public class LODGeomap extends GeoMap {
|
|||||||
store.x = x3 * inv;
|
store.x = x3 * inv;
|
||||||
store.y = y3 * inv;
|
store.y = y3 * inv;
|
||||||
store.z = z3 * inv;
|
store.z = z3 * inv;
|
||||||
|
|
||||||
|
|
||||||
|
/*firstPoint.multLocal(scale);
|
||||||
|
rootPoint.multLocal(scale);
|
||||||
|
secondPoint.multLocal(scale);
|
||||||
|
firstPoint.subtractLocal(rootPoint);
|
||||||
|
secondPoint.subtractLocal(rootPoint);
|
||||||
|
firstPoint.cross(secondPoint, store);*/
|
||||||
return store;
|
return store;
|
||||||
|
|
||||||
/*store.set( firstPoint.subtractLocal(rootPoint).multLocal(scale).crossLocal(secondPoint.subtractLocal(rootPoint).multLocal(scale)).normalizeLocal() );
|
|
||||||
return store;*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user