Revision a40adec7
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/examples/meshfile/FactoryCubit.java | ||
---|---|---|
835 | 835 |
} |
836 | 836 |
} |
837 | 837 |
|
838 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
839 |
|
|
840 |
private void computeConvexityCenter(double[] out, float[] in, FaceTransform ft) |
|
841 |
{ |
|
842 |
if( in==null ) |
|
843 |
{ |
|
844 |
out[0] = out[1] = 0.0f; |
|
845 |
} |
|
846 |
else |
|
847 |
{ |
|
848 |
out[0] = in[0] - ft.vx; |
|
849 |
out[1] = in[1] - ft.vy; |
|
850 |
out[2] = in[2] - ft.vz; |
|
851 |
out[3] = 1.0f; |
|
852 |
|
|
853 |
mQuat1[0] =-ft.qx; |
|
854 |
mQuat1[1] =-ft.qy; |
|
855 |
mQuat1[2] =-ft.qz; |
|
856 |
mQuat1[3] = ft.qw; |
|
857 |
|
|
858 |
mQuat2[0] = -mQuat1[0]; |
|
859 |
mQuat2[1] = -mQuat1[1]; |
|
860 |
mQuat2[2] = -mQuat1[2]; |
|
861 |
mQuat2[3] = +mQuat1[3]; |
|
862 |
|
|
863 |
quatMultiply(mQuat1, out , mQuat3); |
|
864 |
quatMultiply(mQuat3, mQuat2, out ); |
|
865 |
|
|
866 |
out[0] /= ft.scale; |
|
867 |
out[1] /= ft.scale; |
|
868 |
out[2] /= ft.scale; |
|
869 |
} |
|
870 |
} |
|
871 |
|
|
838 | 872 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
839 | 873 |
|
840 | 874 |
public MeshBase createRoundedSolid(final double[][] vertices, final int[][] vertIndexes, |
841 | 875 |
final float[][] bands , final int[] bandIndexes, |
842 | 876 |
final float[][] corners , final int[] cornerIndexes, |
843 | 877 |
final float[][] centers , final int[] centerIndexes, |
844 |
final int numComponents ) |
|
878 |
final int numComponents , final float[] convexityCenter )
|
|
845 | 879 |
{ |
846 | 880 |
int numFaces = vertIndexes.length; |
847 | 881 |
float[] band, bandsComputed; |
848 | 882 |
MeshBase[] meshes = new MeshBase[numFaces]; |
849 | 883 |
FaceTransform fInfo; |
850 | 884 |
StickerCoords sInfo; |
885 |
double[] convexXY = new double[4]; |
|
851 | 886 |
|
852 | 887 |
for(int face=0; face<numFaces; face++) |
853 | 888 |
{ |
... | ... | |
859 | 894 |
float[] vertsFloat = new float[lenVerts]; |
860 | 895 |
for(int i=0; i<lenVerts; i++) vertsFloat[i] = (float)verts[i]; |
861 | 896 |
|
897 |
computeConvexityCenter(convexXY,convexityCenter,fInfo); |
|
898 |
|
|
862 | 899 |
band = bands[bandIndexes[face]]; |
863 | 900 |
bandsComputed = computeBands( band[0], (int)band[1], band[2], band[3], (int)band[4]); |
864 |
meshes[face] = new MeshPolygon(vertsFloat,bandsComputed,(int)band[5],(int)band[6]); |
|
901 |
meshes[face] = new MeshPolygon(vertsFloat,bandsComputed,(int)band[5],(int)band[6], (float)convexXY[0], (float)convexXY[1]);
|
|
865 | 902 |
meshes[face].setEffectAssociation(0,(1<<face),0); |
866 | 903 |
} |
867 | 904 |
|
src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java | ||
---|---|---|
254 | 254 |
|
255 | 255 |
private void createMesh() |
256 | 256 |
{ |
257 |
int mode = 14;
|
|
258 |
int numComponents = 0; |
|
257 |
int mode = 5;
|
|
258 |
int numComponents = 0;
|
|
259 | 259 |
double[][] vertices = null; |
260 | 260 |
int[][] vertIndexes = null; |
261 | 261 |
float[][] bands = null; |
... | ... | |
264 | 264 |
int[] cornerIndexes = null; |
265 | 265 |
float[][] centers = null; |
266 | 266 |
int[] centerIndexes = null; |
267 |
float[] convexCenter= null; |
|
267 | 268 |
|
268 | 269 |
///// CUBE //////////////////////////////////////////////////////////////////////////////// |
269 | 270 |
|
... | ... | |
519 | 520 |
|
520 | 521 |
else if( mode==5 ) |
521 | 522 |
{ |
522 |
int IVY_N = 3;
|
|
523 |
int IVY_N = 8;
|
|
523 | 524 |
final float IVY_D = 0.003f; |
524 | 525 |
final double angle = Math.PI/(2*IVY_N); |
525 | 526 |
final double CORR = 1.0 - 2*IVY_D; |
... | ... | |
625 | 626 |
centerIndexes[i] = -1; |
626 | 627 |
} |
627 | 628 |
|
629 |
float C = 0.5f - SQ2/4; |
|
630 |
convexCenter = new float[] {-C,-C,-C}; |
|
631 |
|
|
628 | 632 |
numComponents = 6; |
629 | 633 |
} |
630 | 634 |
|
... | ... | |
1246 | 1250 |
bands, bandIndexes, |
1247 | 1251 |
corners, cornerIndexes, |
1248 | 1252 |
centers, centerIndexes, |
1249 |
numComponents ); |
|
1253 |
numComponents, convexCenter );
|
|
1250 | 1254 |
|
1251 | 1255 |
int numEff = mMesh.getNumEffComponents(); |
1252 | 1256 |
|
Also available in: Unified diff
Convert the Ivy corner cubit to the new, 'universal' cubit creation method.
This forces deep changes to 'createRoundSolid' and the underlying 'MeshPolygon' class to make them support arbitrary Polygon 'centers of face convexity'.
Reason: the faces of this cubit are concave and such default 'center of face convexity' (which by default used to be (0,0)) turned to lie outside the face - which produces strange visual artifacts.