final void startGeometry(Geometry geom) { if (lineShader != null) lineShader.startGeometry(geom); if (faceShader != null) faceShader.startGeometry(geom); if (pointShader != null) pointShader.startGeometry(geom); if (geom instanceof PointSet) { vertexColor = ((PointSet) geom).getVertexAttributes(Attribute.COLORS); vertexColors = vertexColor != null; if (vertexColors) vertexColorLength = vertexColor.getStorageModel().getDimensions()[1]; // System.out.println("PolygonPipeline.startGeometry("+geom.getName() // +"): colors: "+vertexColors); } else { vertexColor = null; vertexColors = false; } }
public final void processPseudoTube(DoubleArray from, DoubleArray to) { if (lineShader == null) return; shader = lineShader.getPolygonShader(); double w = 1; if (from.size() == 4) w = from.getValueAt(3); VecMat.transform( matrix, from.getValueAt(0), from.getValueAt(1), from.getValueAt(2), w, point0, 0); VecMat.transformUnNormalized(matrix, 0, 0, lineWidth, normal0, 0); w = 1; if (to.size() == 4) w = to.getValueAt(3); VecMat.transform(matrix, to.getValueAt(0), to.getValueAt(1), to.getValueAt(2), w, point1, 0); double[] mat = matrix; double[] tmat = inverseTransposeMatrix; matrix = identity; inverseTransposeMatrix = identity; direction[0] = point1[0] - point0[0]; direction[1] = point1[1] - point0[1]; direction[2] = point1[2] - point0[2]; // TODO: decide: better but slower: zzNormal[0] = point1[0] + point0[0]; zzNormal[1] = point1[1] + point0[1]; zzNormal[2] = point1[2] + point0[2]; VecMat.normalize(zzNormal); // TODO make only one call to norm... if (VecMat.norm(direction) == 0) { matrix = mat; inverseTransposeMatrix = tmat; return; } VecMat.normalize(direction); double length = VecMat.norm(normal0); VecMat.cross(direction, zzNormal, normal0); VecMat.normalize(normal0); VecMat.cross(normal0, direction, normal1); normal0[0] *= length; normal0[1] *= length; // allways zero: normal0[2] *= length; VecMat.normalize(normal1); if (VecMat.dot(normal1, zzNormal) < 0) { normal1[0] *= -1; normal1[1] *= -1; normal1[2] *= -1; System.out.println("flip"); } line[0] = point0[0] - normal0[0]; line[1] = point0[1] - normal0[1]; line[2] = point0[2]; line[3] = point0[0]; line[4] = point0[1]; line[5] = point0[2] + length; line[6] = point1[0]; line[7] = point1[1]; line[8] = point1[2] + length; line[9] = point1[0] - normal0[0]; line[10] = point1[1] - normal0[1]; line[11] = point1[2]; normal2[0] = +cs / length * normal0[0] + ss * normal1[0]; normal2[1] = +cs / length * normal0[1] + ss * normal1[1]; normal2[2] = ss * normal1[2]; normal2[3] = normal1[0]; normal2[4] = normal1[1]; normal2[5] = normal1[2]; computeArrayNoTransform(line, lineIndices, normal2, nIndices); ///// line[0] = point0[0]; line[1] = point0[1]; line[2] = point0[2] + length; line[3] = point0[0] + normal0[0]; line[4] = point0[1] + normal0[1]; line[5] = point0[2]; line[6] = point1[0] + normal0[0]; line[7] = point1[1] + normal0[1]; line[8] = point1[2]; line[9] = point1[0]; line[10] = point1[1]; line[11] = point1[2] + length; normal2[0] = normal1[0]; normal2[1] = normal1[1]; normal2[2] = normal1[2]; normal2[3] = -cs / length * normal0[0] + ss * normal1[0]; normal2[4] = -cs / length * normal0[1] + ss * normal1[1]; normal2[5] = ss * normal1[2]; computeArrayNoTransform(line, lineIndices, normal2, nIndices); /* test1[0] = point1[0]; test1[1] = point1[1]; test1[2] = point1[2]; test2[0] = point1[0]+normal1[0]; test2[1] = point1[1]+normal1[1]; test2[2] = point1[2]+normal1[2]; test3[0] = point0[0]; test3[1] = point0[1]; test3[2] = point0[2]; test4[0] = point0[0]+normal1[0]; test4[1] = point0[1]+normal1[1]; test4[2] = point0[2]+normal1[2]; processLine(tda1,tda2); processLine(tda3,tda4); */ matrix = mat; inverseTransposeMatrix = tmat; }
/* (non-Javadoc) * @see de.jreality.soft.LineProcessor#processLine(double[], int, int) */ public final void processLine(DoubleArray from, DoubleArray to) { if (lineShader == null) return; shader = lineShader.getPolygonShader(); double w = 1; if (from.size() == 4) w = from.getValueAt(3); VecMat.transform( matrix, from.getValueAt(0), from.getValueAt(1), from.getValueAt(2), 1, point0, 0); VecMat.transformUnNormalized(matrix, 0, 0, lineWidth, normal0, 0); w = 1; if (to.size() == 4) w = from.getValueAt(3); VecMat.transform(matrix, to.getValueAt(0), to.getValueAt(1), to.getValueAt(2), 1, point1, 0); // VecMat.transformUnNormalized(matrix,0,0,.2,normal0,0); double[] mat = matrix; double[] tmat = inverseTransposeMatrix; matrix = identity; inverseTransposeMatrix = identity; // VecMat.assignIdentity(matrix); direction[0] = point1[0] - point0[0]; direction[1] = point1[1] - point0[1]; direction[2] = point1[2] - point0[2]; // TODO make only one call to norm... if (VecMat.norm(direction) == 0) { matrix = mat; inverseTransposeMatrix = tmat; return; } VecMat.normalize(direction); double length = VecMat.norm(normal0); VecMat.cross(direction, zNormal, normal0); VecMat.normalize(normal0); normal0[0] *= length; normal0[1] *= length; normal0[2] *= length; VecMat.cross(normal0, direction, normal1); VecMat.normalize(normal1); line[0] = point0[0] - normal0[0]; line[1] = point0[1] - normal0[1]; line[2] = point0[2] + length; // - normal0[2]; line[3] = point0[0] + normal0[0]; line[4] = point0[1] + normal0[1]; line[5] = point0[2] + length; // + normal0[2]; line[6] = point1[0] + normal0[0]; line[7] = point1[1] + normal0[1]; line[8] = point1[2] + length; // + normal0[2]; line[9] = point1[0] - normal0[0]; line[10] = point1[1] - normal0[1]; line[11] = point1[2] + length; // + normal0[2]; computeArray(line, lineIndices, normal1, pointNormals); matrix = mat; inverseTransposeMatrix = tmat; }
/** * Sets the lineShader. * * @param lineShader The lineShader to set */ public void setLineShader(LineShader lineShader) { this.lineShader = lineShader; if (lineShader != null) lineWidth = lineShader.getLineWidth(); }