类javafx.scene.shape.CullFace源码实例Demo

下面列出了怎么用javafx.scene.shape.CullFace的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: paintera   文件: ArbitraryMeshConfigSerializer.java
@Override
public ArbitraryMeshConfig.MeshInfo deserialize(
		final JsonElement json,
		final Type typeOfT,
		final JsonDeserializationContext context) throws JsonParseException {
	final JsonObject map = json.getAsJsonObject();
	final String path = resolveIfRelative(map.get(PATH_KEY).getAsString(), projectDirectory.get());
	final String className = map.get(FORMAT_KEY).getAsString();
	try {
		final ArbitraryMeshConfig.MeshInfo meshInfo = new ArbitraryMeshConfig.MeshInfo(
				Paths.get(path),
				((Class<TriangleMeshFormat>)Class.forName(className)).getConstructor().newInstance());
		if (map.has(NAME_KEY)) meshInfo.nameProperty().set(map.get(NAME_KEY).getAsString());
		if (map.has(IS_VISIBLE_KEY)) meshInfo.isVisibleProperty().set(map.get(IS_VISIBLE_KEY).getAsBoolean());
		if (map.has(COLOR_KEY)) meshInfo.colorProperty().set(Color.web(map.get(COLOR_KEY).getAsString()));
		if (map.has(SCALE_KEY)) meshInfo.scaleProperty().set(map.get(SCALE_KEY).getAsDouble());
		if (map.has(TRANSLATE_X_KEY)) meshInfo.translateXProperty().set(map.get(TRANSLATE_X_KEY).getAsDouble());
		if (map.has(TRANSLATE_Y_KEY)) meshInfo.translateYProperty().set(map.get(TRANSLATE_Y_KEY).getAsDouble());
		if (map.has(TRANSLATE_Z_KEY)) meshInfo.translateZProperty().set(map.get(TRANSLATE_Z_KEY).getAsDouble());
		if (map.has(CULL_FACE_KEY)) meshInfo.cullFaceProperty().set(context.deserialize(map.get(CULL_FACE_KEY), CullFace.class));
		if (map.has(DRAW_MODE_KEY)) meshInfo.drawModeProperty().set(context.deserialize(map.get(DRAW_MODE_KEY), DrawMode.class));
		return meshInfo;
	} catch (Exception e) {
		throw new JsonParseException(e);
	}
}
 
源代码2 项目: paintera   文件: MeshSettingsSerializer.java
public static MeshSettings deserializeInto(
		final JsonObject map,
		final MeshSettings settings,
		final JsonDeserializationContext context) {
	Optional.ofNullable(map.get(COARSEST_SCALE_LEVEL_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setCoarsetsScaleLevel);
	Optional.ofNullable(map.get(FINEST_SCALE_LEVEL_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setFinestScaleLevel);
	Optional.ofNullable(map.get(SIMPLIFICATION_ITERATIONS_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setSimplificationIterations);
	Optional.ofNullable(map.get(SMOOTHING_ITERATIONS_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setSmoothingIterations);
	Optional.ofNullable(map.get(SMOOTHING_LAMBDA_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setSmoothingLambda);
	Optional.ofNullable(map.get(OPACITY_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setOpacity);
	Optional.ofNullable(map.get(INFLATE_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setInflate);
	Optional.ofNullable(map.get(DRAW_MODE_KEY)).map(el -> (DrawMode) context.deserialize(el, DrawMode.class)).ifPresent(settings::setDrawMode);
	Optional.ofNullable(map.get(CULL_FACE_KEY)).map(el -> (CullFace) context.deserialize(el, CullFace.class)).ifPresent(settings::setCullFace);
	Optional.ofNullable(map.get(IS_VISIBLE_KEY)).map(JsonElement::getAsBoolean).ifPresent(settings::setVisible);
	Optional.ofNullable(map.get(MIN_LABEL_RATIO_KEY)).map(JsonElement::getAsDouble).ifPresent(settings::setMinLabelRatio);
	Optional.ofNullable(map.get(LEVEL_OF_DETAIL_KEY)).map(JsonElement::getAsInt).ifPresent(settings::setLevelOfDetail);
	return settings;
}
 
源代码3 项目: paintera   文件: MeshGeneratorJobManager.java
private static MeshView makeMeshView(final PainteraTriangleMesh verticesAndNormals)
{
	final float[]      vertices = verticesAndNormals.getVertices();
	final float[]      normals  = verticesAndNormals.getNormals();
	final TriangleMesh mesh     = new TriangleMesh();
	mesh.getPoints().addAll(vertices);
	mesh.getNormals().addAll(normals);
	mesh.getTexCoords().addAll(0, 0);
	mesh.setVertexFormat(VertexFormat.POINT_NORMAL_TEXCOORD);
	final int[] faceIndices = new int[vertices.length];
	for (int i = 0, k = 0; i < faceIndices.length; i += 3, ++k)
	{
		faceIndices[i + 0] = k;
		faceIndices[i + 1] = k;
		faceIndices[i + 2] = 0;
	}
	mesh.getFaces().addAll(faceIndices);
	final PhongMaterial material = Meshes.painteraPhongMaterial();
	final MeshView mv = new MeshView(mesh);
	mv.setOpacity(1.0);
	mv.setCullFace(CullFace.FRONT);
	mv.setMaterial(material);
	mv.setDrawMode(DrawMode.FILL);
	return mv;
}
 
源代码4 项目: FXyzLib   文件: KnotMesh.java
public KnotMesh(double majorRadius, double minorRadius, double wireRadius, double p, double q, 
                  int rDivs, int tDivs, int lengthCrop, int wireCrop) {
    
    setMajorRadius(majorRadius);
    setMinorRadius(minorRadius);
    setWireRadius(wireRadius);
    setP(p);
    setQ(q);
    setLengthDivisions(rDivs);
    setWireDivisions(tDivs);
    setLengthCrop(lengthCrop);
    setWireCrop(wireCrop);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码5 项目: FXyzLib   文件: IcosahedronMesh.java
public IcosahedronMesh(int level, float diameter){
    setLevel(level);
    setDiameter(diameter);

    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
    
    diameterProperty().addListener((obs,f0,f1)->{
        if(mesh!=null && f0!=null && f1!=null && f0.floatValue()>0 && f1.floatValue()>0){
            updateVertices(f1.floatValue()/f0.floatValue());
        }
    });
    
    levelProperty().addListener((obs,i0,i1)->{
        if(mesh!=null && i1!=null && i1.intValue()>=0){
            updateMesh();
        }
    });
}
 
源代码6 项目: FXyzLib   文件: CurvedSpringMesh.java
public CurvedSpringMesh(double majorRadius, double minorRadius, double wireRadius, double pitch, double length, 
                  int rDivs, int tDivs, int lengthCrop, int wireCrop) {
    
    setMajorRadius(majorRadius);
    setMinorRadius(minorRadius);
    setWireRadius(wireRadius);
    setPitch(pitch);
    setLength(length);
    setLengthDivisions(rDivs);
    setWireDivisions(tDivs);
    setLengthCrop(lengthCrop);
    setWireCrop(wireCrop);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码7 项目: FXyzLib   文件: SpringMesh.java
public SpringMesh(double meanRadius, double wireRadius, double pitch, double length, 
                  int rDivs, int tDivs, int lengthCrop, int wireCrop) {
    
    setMeanRadius(meanRadius);
    setWireRadius(wireRadius);
    setPitch(pitch);
    setLength(length);
    factor=length/pitch;
    setLengthDivisions(rDivs);
    setWireDivisions(tDivs);
    setLengthCrop(lengthCrop);
    setWireCrop(wireCrop);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
    
}
 
源代码8 项目: paintera   文件: MeshGeneratorJobManager.java
private Node createBlockShape(final ShapeKey<T> key)
	{
		final Interval keyInterval = key.interval();
		final double[] worldMin = new double[3], worldMax = new double[3];
		Arrays.setAll(worldMin, d -> keyInterval.min(d));
		Arrays.setAll(worldMax, d -> keyInterval.min(d) + keyInterval.dimension(d));
		unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMin, worldMin);
		unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMax, worldMax);

		final RealInterval blockWorldInterval = new FinalRealInterval(worldMin, worldMax);
		final double[] blockWorldSize = new double[blockWorldInterval.numDimensions()];
		Arrays.setAll(blockWorldSize, d -> blockWorldInterval.realMax(d) - blockWorldInterval.realMin(d));

		// the standard Box primitive is made up of triangles, so the unwanted diagonals are visible when using DrawMode.Line
//		final Box box = new Box(
//				blockWorldSize[0],
//				blockWorldSize[1],
//				blockWorldSize[2]
//			);
		final PolygonMeshView box = new PolygonMeshView(Meshes.createQuadrilateralMesh(
				(float) blockWorldSize[0],
				(float) blockWorldSize[1],
				(float) blockWorldSize[2]
		));

		final double[] blockWorldTranslation = new double[blockWorldInterval.numDimensions()];
		Arrays.setAll(blockWorldTranslation, d -> blockWorldInterval.realMin(d) + blockWorldSize[d] * 0.5);

		box.setTranslateX(blockWorldTranslation[0]);
		box.setTranslateY(blockWorldTranslation[1]);
		box.setTranslateZ(blockWorldTranslation[2]);

		final PhongMaterial material = Meshes.painteraPhongMaterial();
		box.setCullFace(CullFace.NONE);
		box.setMaterial(material);
		box.setDrawMode(DrawMode.LINE);

		return box;
	}
 
源代码9 项目: paintera   文件: SegmentMeshInfoNode.java
public SegmentMeshInfoNode(final DataSource<?, ?> source, final SegmentMeshInfo meshInfo)
{
	this.source = source;
	this.meshInfo = meshInfo;
	this.settings = meshInfo.getMeshSettings();

	LOG.debug("Initializing MeshinfoNode with draw mode {}", settings.drawModeProperty());
	visibleCheckBox = new CheckBox();
	levelOfDetailSlider = new NumericSliderWithField(MeshSettings.Defaults.Values.getMinLevelOfDetail(), MeshSettings.Defaults.Values.getMaxLevelOfDetail(), settings.getLevelOfDetail());
	coarsestScaleLevelSlider = new NumericSliderWithField(0, settings.getNumScaleLevels() - 1, settings.getCoarsetsScaleLevel());
	finestScaleLevelSlider = new NumericSliderWithField(0, settings.getNumScaleLevels() - 1, settings.getFinestScaleLevel());
	smoothingLambdaSlider = new NumericSliderWithField(0.0, 1.0, settings.getSmoothingLambda());
	smoothingIterationsSlider = new NumericSliderWithField(0, 10, settings.getSmoothingIterations());
	minLabelRatioSlider = new NumericSliderWithField(0.0, 1.0, settings.getMinLabelRatio());
	this.opacitySlider = new NumericSliderWithField(0, 1.0, settings.getOpacity());
	this.inflateSlider = new NumericSliderWithField(0.5, 2.0, settings.getInflate());

	this.drawModeChoice = new ComboBox<>(FXCollections.observableArrayList(DrawMode.values()));
	this.drawModeChoice.setValue(settings.getDrawMode());

	this.cullFaceChoice = new ComboBox<>(FXCollections.observableArrayList(CullFace.values()));
	this.cullFaceChoice.setValue(settings.getCullFace());

	bindSlidersToSettings();

	this.contents = createContents();
}
 
源代码10 项目: gluon-samples   文件: ObjImporter.java
public MeshView buildMeshView(String key) {
    MeshView meshView = new MeshView();
    meshView.setId(key);
    meshView.setMaterial(materials.get(key));
    meshView.setMesh(meshes.get(key));
    meshView.setCullFace(CullFace.NONE);
    return meshView;
}
 
源代码11 项目: TweetwallFX   文件: DevoxxBillboardLogo.java
public DevoxxBillboardLogo() {
    this.mat.setDiffuseMap(image);

    this.mesh = createMesh();
    this.setMesh(mesh);
    this.setMaterial(mat);
    this.setCullFace(CullFace.NONE);
    this.updateThread.setRunnable(() -> {
        if (isAnimated() && updateThread.getCurrentTime() >= (updateThread.getUpdateDelay())) {
            updateMesh();
            updateThread.setUpdateDelay((updateThread.getCurrentTime() + 80000000));
        }
    });

    updateThread.start();

    this.sceneProperty().addListener(new ChangeListener<Scene>() {
        @Override
        public void changed(ObservableValue<? extends Scene> observable, Scene oldValue, Scene newValue) {
            if (newValue != null) {
                otherNode = getScene().getCamera();
                startBillboardBehavior();
                sceneProperty().removeListener(this);
            }
        }
    });
}
 
源代码12 项目: FXyzLib   文件: CuboidMesh.java
public CuboidMesh(double width, double height, double depth, int level, Point3D center){
    setWidth(width);        
    setHeight(height);        
    setDepth(depth);        
    setLevel(level);
    setCenter(center);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码13 项目: FXyzLib   文件: SurfacePlotMesh.java
public SurfacePlotMesh(Function<Point2D,Number> function, double rangeX, double rangeY, int divisionsX, int divisionsY, double functionScale) {
    setFunction2D(function);
    setRangeX(rangeX);
    setRangeY(rangeY);
    setDivisionsX(divisionsX);
    setDivisionsY(divisionsY);
    setFunctionScale(functionScale);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码14 项目: FXyzLib   文件: TriangulatedMesh.java
public TriangulatedMesh(List<Point3D> points, List<List<Point3D>> pointsHole, int level, double height, double holeRadius, Bounds bounds) {
    this.pointsExterior=points;
    this.pointsHoles=pointsHole;
    setLevel(level);
    setHeight(height);
    setHoleRadius(holeRadius);
    setBounds(bounds);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码15 项目: FXyzLib   文件: PrismMesh.java
public PrismMesh(double radius, double height, int level, Point3D pIni, Point3D pEnd){
    setAxisOrigin(pIni==null?new Point3D(0,(float)height/2f,0):pIni);
    setAxisEnd(pEnd==null?new Point3D(0,-(float)height/2f,0):pEnd);
    setRadius(radius);
    setHeight(getAxisEnd().substract(getAxisOrigin()).magnitude());
    setLevel(level);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码16 项目: FXyzLib   文件: SegmentedTorusMesh.java
public SegmentedTorusMesh(int rDivs, int tDivs, int crop, double majorRadius, double minorRadius) {
    setMajorRadiusDivisions(rDivs);
    setMinorRadiusDivisions(tDivs);
    setMajorRadiusCrop(crop);
    setMajorRadius(majorRadius);
    setMinorRadius(minorRadius);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码17 项目: FXyzLib   文件: CSGMesh.java
public CSGMesh(CSG primitive){
    this.primitive=primitive;
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码18 项目: FXyzLib   文件: BezierMesh.java
public BezierMesh(BezierHelper spline, double wireRadius, 
                  int rDivs, int tDivs, int lengthCrop, int wireCrop) {
    
    setSpline(spline);
    setWireRadius(wireRadius);
    setLengthDivisions(rDivs);
    setWireDivisions(tDivs);
    setLengthCrop(lengthCrop);
    setWireCrop(wireCrop);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码19 项目: FXyzLib   文件: SegmentedSphereMesh.java
public SegmentedSphereMesh(int tDivs, int cropX, int cropY, double radius, Point3D center) {
    setRadiusDivisions(tDivs);
    setRadiusCropX(cropX);
    setRadiusCropY(cropY);
    setRadius(radius);
    setzOffset(1);
    setCenter(center);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码20 项目: FXyzLib   文件: FrustumMesh.java
public FrustumMesh(double majorRadius, double minorRadius, double height, int level, Point3D pIni, Point3D pEnd){
    setAxisOrigin(pIni==null?new Point3D(0,(float)height/2f,0):pIni);
    setAxisEnd(pEnd==null?new Point3D(0,-(float)height/2f,0):pEnd);
    setMajorRadius(majorRadius);
    setMinorRadius(minorRadius);
    setLevel(level);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码21 项目: FXyzLib   文件: TetrahedraMesh.java
public TetrahedraMesh(double height, int level, Point3D center){
    setHeight(height);        
    setLevel(level);
    setCenter(center);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码22 项目: mzmine3   文件: Fx3DRawDataFileDataset.java
public Fx3DRawDataFileDataset(RawDataFile dataFile, float[][] intensityValues, int rtResolution,
    int mzResolution, double maxBinnedIntensity, String fileName, Color peakColor) {
  super(dataFile, fileName, peakColor);
  this.intensityValues = intensityValues;
  this.rtResolution = rtResolution;
  this.mzResolution = mzResolution;
  this.maxBinnedIntensity = maxBinnedIntensity;
  mesh = new TriangleMesh();

  peakListIndices = new int[rtResolution][mzResolution];
  float factorX = (float) SIZE / rtResolution;
  float factorZ = (float) SIZE / mzResolution;

  for (int i = 0; i < rtResolution; i++) {
    for (int j = 0; j < mzResolution; j++) {
      if (maxIntensityValue < intensityValues[i][j]) {
        maxIntensityValue = intensityValues[i][j];
      }
    }
  }

  for (int x = 0; x < rtResolution; x++) {
    for (int z = 0; z < mzResolution; z++) {
      mesh.getPoints().addAll((float) x * factorX, -intensityValues[x][z] * AMPLIFI,
          (float) z * factorZ);
      if (intensityValues[x][z] > 0.022 * maxIntensityValue) {
        peakListIndices[x][z] = 1;
      }
    }
  }

  int rtLength = rtResolution;
  int mzLength = mzResolution;
  float rtTotal = rtLength;
  float mzTotal = mzLength;

  for (float x = 0; x < rtLength - 1; x++) {
    for (float y = 0; y < mzLength - 1; y++) {

      float x0 = x / rtTotal;
      float y0 = y / mzTotal;
      float x1 = (x + 1) / rtTotal;
      float y1 = (y + 1) / mzTotal;

      mesh.getTexCoords().addAll( //
          x0, y0, // 0, top-left
          x0, y1, // 1, bottom-left
          x1, y0, // 2, top-right
          x1, y1 // 3, bottom-right
      );
    }
  }

  // faces
  for (int x = 0; x < rtLength - 1; x++) {
    for (int z = 0; z < mzLength - 1; z++) {

      int tl = x * mzLength + z; // top-left
      int bl = x * mzLength + z + 1; // bottom-left
      int tr = (x + 1) * mzLength + z; // top-right
      int br = (x + 1) * mzLength + z + 1; // bottom-right

      int offset = (x * (mzLength - 1) + z) * 8 / 2; // div 2 because
                                                     // we have u AND
                                                     // v in the list

      // working
      mesh.getFaces().addAll(bl, offset + 1, tl, offset + 0, tr, offset + 2);
      mesh.getFaces().addAll(tr, offset + 2, br, offset + 3, bl, offset + 1);

    }
  }
  setNodeColor(peakColor);
  meshView.setMesh(mesh);
  meshView.setCullFace(CullFace.NONE);
  meshView.setDrawMode(DrawMode.FILL);
  meshView.setDepthTest(DepthTest.ENABLE);
  logger.finest("Plot mesh is ready.");
}
 
源代码23 项目: paintera   文件: CatmaidJsonLoader.java
public static void main(String[] args) throws IOException {
		PlatformImpl.startup(() -> {});
		final Path path = Paths.get(System.getProperty("user.home"), "Downloads", "catmaid-meshes", "Block3.json");
		final TriangleMesh mesh = new CatmaidJsonLoader().loadMesh(path);
		final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY};
		final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY};
		for (int i = 0; i < mesh.getPoints().size(); i += 3) {
			for (int d = 0; d < 3; ++d) {
				min[d] = Math.min(min[d], mesh.getPoints().get(i + d));
				max[d] = Math.max(max[d], mesh.getPoints().get(i + d));
			}
		}
		System.out.print(Arrays.toString(min) +" " + Arrays.toString(max));
		final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max));
		final MeshView mv = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE));
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		final Viewer3DFX viewer = new Viewer3DFX(800, 600);
		viewer.meshesEnabledProperty().set(true);
		mv.setOpacity(1.0);
		viewer.setInitialTransformToInterval(interval);
		final MeshView mv2 = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial());
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		mv2.setTranslateX(100);
		viewer.meshesGroup().getChildren().addAll(mv, mv2);
		Platform.setImplicitExit(true);
		Platform.runLater(() -> {
			final Scene scene = new Scene(viewer);
			final Stage stage = new Stage();
			stage.setScene(scene);
			stage.setWidth(800);
			stage.setHeight(600);
			stage.show();
		});
//		final String mesh = "<IndexedTriangleSet  index='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35'><Coordinate point='440474 99212 136120 440474 119212 136120 460474 99212 136120 460474 99212 136120 440474 119212 136120 460474 119212 136120 440474 99212 136120 460474 99212 136120 460474 99212 156120 440474 99212 136120 460474 99212 156120 440474 99212 156120 440474 119212 136120 440474 119212 156120 460474 119212 156120 440474 119212 136120 460474 119212 156120 460474 119212 136120 440474 99212 156120 460474 119212 156120 440474 119212 156120 440474 99212 156120 460474 99212 156120 460474 119212 156120 440474 99212 136120 440474 119212 156120 440474 119212 136120 440474 99212 136120 440474 99212 156120 440474 119212 156120 460474 99212 136120 460474 119212 136120 460474 99212 156120 460474 119212 136120 460474 119212 156120 460474 99212 156120'/></IndexedTriangleSet>";
//		final Document doc = Jsoup.parse(mesh);
//		System.out.println(doc);
//		System.out.println(doc.select("IndexedTriangleSet").attr("index"));
	}
 
源代码24 项目: paintera   文件: ObjLoader.java
public static void main(String[] args) throws IOException {
		PlatformImpl.startup(() -> {});
		// https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html
//		final String objFile = "al.obj";
//		final String objFile = "diamond.obj";
		final String objFile = "alfa147.obj";
		final Path path = Paths.get(System.getProperty("user.home"), "Downloads", objFile);
		final TriangleMesh mesh = new ObjLoader().loadMesh(path);
		final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY};
		final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY};
		for (int i = 0; i < mesh.getPoints().size(); i += 3) {
			for (int d = 0; d < 3; ++d) {
				min[d] = Math.min(min[d], mesh.getPoints().get(i + d));
				max[d] = Math.max(max[d], mesh.getPoints().get(i + d));
			}
		}
		final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max));
		final MeshView mv = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE));
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		final Viewer3DFX viewer = new Viewer3DFX(800, 600);
		viewer.meshesEnabledProperty().set(true);
		mv.setOpacity(1.0);
		viewer.setInitialTransformToInterval(interval);
		final MeshView mv2 = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial());
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		mv2.setTranslateX(100);
		viewer.meshesGroup().getChildren().addAll(mv, mv2);
//		final double factor = 1;
//		final double w = 1*factor, h = 2*factor, d = 3*factor;
//		final Box box = new Box(w, h, d);
//		box.setCullFace(CullFace.NONE);
//		box.setOpacity(1.0);
//		box.setMaterial(Meshes.painteraPhongMaterial(Color.RED));
//		viewer.meshesGroup().getChildren().add(box);
		Platform.setImplicitExit(true);
		Platform.runLater(() -> {
			final Scene scene = new Scene(viewer);
			final Stage stage = new Stage();
			stage.setScene(scene);
			stage.setWidth(800);
			stage.setHeight(600);
			stage.show();
		});
	}
 
源代码25 项目: mzmine2   文件: Fx3DRawDataFileDataset.java
public Fx3DRawDataFileDataset(RawDataFile dataFile,
        float[][] intensityValues, int rtResolution, int mzResolution,
        double maxBinnedIntensity, String fileName, Color peakColor) {
    super(dataFile, fileName, peakColor);
    this.intensityValues = intensityValues;
    this.rtResolution = rtResolution;
    this.mzResolution = mzResolution;
    this.maxBinnedIntensity = maxBinnedIntensity;
    mesh = new TriangleMesh();

    peakListIndices = new int[rtResolution][mzResolution];
    float factorX = (float) SIZE / rtResolution;
    float factorZ = (float) SIZE / mzResolution;

    for (int i = 0; i < rtResolution; i++) {
        for (int j = 0; j < mzResolution; j++) {
            if (maxIntensityValue < intensityValues[i][j]) {
                maxIntensityValue = intensityValues[i][j];
            }
        }
    }

    for (int x = 0; x < rtResolution; x++) {
        for (int z = 0; z < mzResolution; z++) {
            mesh.getPoints().addAll((float) x * factorX,
                    -intensityValues[x][z] * AMPLIFI, (float) z * factorZ);
            if (intensityValues[x][z] > 0.022 * maxIntensityValue) {
                peakListIndices[x][z] = 1;
            }
        }
    }

    int rtLength = rtResolution;
    int mzLength = mzResolution;
    float rtTotal = rtLength;
    float mzTotal = mzLength;

    for (float x = 0; x < rtLength - 1; x++) {
        for (float y = 0; y < mzLength - 1; y++) {

            float x0 = x / rtTotal;
            float y0 = y / mzTotal;
            float x1 = (x + 1) / rtTotal;
            float y1 = (y + 1) / mzTotal;

            mesh.getTexCoords().addAll( //
                    x0, y0, // 0, top-left
                    x0, y1, // 1, bottom-left
                    x1, y0, // 2, top-right
                    x1, y1 // 3, bottom-right
            );
        }
    }

    // faces
    for (int x = 0; x < rtLength - 1; x++) {
        for (int z = 0; z < mzLength - 1; z++) {

            int tl = x * mzLength + z; // top-left
            int bl = x * mzLength + z + 1; // bottom-left
            int tr = (x + 1) * mzLength + z; // top-right
            int br = (x + 1) * mzLength + z + 1; // bottom-right

            int offset = (x * (mzLength - 1) + z) * 8 / 2; // div 2 because
                                                           // we have u AND
                                                           // v in the list

            // working
            mesh.getFaces().addAll(bl, offset + 1, tl, offset + 0, tr,
                    offset + 2);
            mesh.getFaces().addAll(tr, offset + 2, br, offset + 3, bl,
                    offset + 1);

        }
    }
    setNodeColor(peakColor);
    meshView.setMesh(mesh);
    meshView.setCullFace(CullFace.NONE);
    meshView.setDrawMode(DrawMode.FILL);
    meshView.setDepthTest(DepthTest.ENABLE);
    LOG.finest("Plot mesh is ready.");
}
 
源代码26 项目: TweetwallFX   文件: SegmentedTorus.java
public final void setCullFace(CullFace value) {
    mesh.setCullFace(value);
}
 
源代码27 项目: FXyzLib   文件: Cone.java
public final void setCullFace(CullFace value) {
    mesh.setCullFace(value);
}
 
源代码28 项目: FXyzLib   文件: SurfacePlot.java
public void setHeightData(float[][] arrayY, int spacing, Color color, boolean ambient, boolean fill) {
    material = new PhongMaterial();
    material.setSpecularColor(color);
    material.setDiffuseColor(color);

    mesh = new TriangleMesh();

    // Fill Points
    for (int x = 0; x < arrayY.length; x++) {
        for (int z = 0; z < arrayY[0].length; z++) {
            mesh.getPoints().addAll(x * spacing, arrayY[x][z], z * spacing);
        }
    }

    //for now we'll just make an empty texCoordinate group
    mesh.getTexCoords().addAll(0, 0);
    int total = arrayY.length * arrayY.length;
    int nextRow = arrayY.length;
    //Add the faces "winding" the points generally counter clock wise
    for (int i = 0; i < total - nextRow -1; i++) {
        //Top upper left triangle
        mesh.getFaces().addAll(i,0,i+nextRow,0,i+1,0);
        //Top lower right triangle
        mesh.getFaces().addAll(i+nextRow,0,i+nextRow + 1,0,i+1,0);
        
        //Bottom            
    }
    //Create a viewable MeshView to be added to the scene
    //To add a TriangleMesh to a 3D scene you need a MeshView container object
    meshView = new MeshView(mesh);
    //The MeshView allows you to control how the TriangleMesh is rendered
    if(fill) { 
        meshView.setDrawMode(DrawMode.FILL);
    } else {
        meshView.setDrawMode(DrawMode.LINE); //show lines only by default
    }
    meshView.setCullFace(CullFace.BACK); //Removing culling to show back lines

    getChildren().add(meshView);
    meshView.setMaterial(material);
    if (ambient) {
        selfLight.getScope().add(meshView);
        if(!getChildren().contains(selfLight))
            getChildren().add(selfLight);
    }
    else if(getChildren().contains(selfLight))
        getChildren().remove(selfLight);
    setDepthTest(DepthTest.ENABLE);
}
 
源代码29 项目: FXyzLib   文件: PolyLine3D.java
public PolyLine3D(List<Point3D> points, int width, Color color) {
    this.points = points;
    this.width = width;
    this.color = color;
    setDepthTest(DepthTest.ENABLE);        
    mesh  = new TriangleMesh();
    //add each point. For each point add another point shifted on Z axis by width
    //This extra point allows us to build triangles later
    for(Point3D point: points) {
        mesh.getPoints().addAll(point.x,point.y,point.z);
        mesh.getPoints().addAll(point.x,point.y,point.z+width);
    }
    //add dummy Texture Coordinate
    mesh.getTexCoords().addAll(0,0); 
    //Now generate trianglestrips for each line segment
    for(int i=2;i<points.size()*2;i+=2) {  //add each segment
        //Vertices wound counter-clockwise which is the default front face of any Triange
        //These triangles live on the frontside of the line facing the camera
        mesh.getFaces().addAll(i,0,i-2,0,i+1,0); //add primary face
        mesh.getFaces().addAll(i+1,0,i-2,0,i-1,0); //add secondary Width face
        //Add the same faces but wind them clockwise so that the color looks correct when camera is rotated
        //These triangles live on the backside of the line facing away from initial the camera
        mesh.getFaces().addAll(i+1,0,i-2,0,i,0); //add primary face
        mesh.getFaces().addAll(i-1,0,i-2,0,i+1,0); //add secondary Width face
    }
    //Need to add the mesh to a MeshView before adding to our 3D scene 
    meshView = new MeshView(mesh);
    meshView.setDrawMode(DrawMode.FILL);  //Fill so that the line shows width
    material = new PhongMaterial(color);
    material.setDiffuseColor(color);
    material.setSpecularColor(color);
    meshView.setMaterial(material); 
    //Make sure you Cull the Back so that no black shows through
    meshView.setCullFace(CullFace.BACK);

    //Add some ambient light so folks can see it
    AmbientLight light = new AmbientLight(Color.WHITE);
    light.getScope().add(meshView);
    getChildren().add(light);
    getChildren().add(meshView);           
}
 
源代码30 项目: FXyzLib   文件: ScatterPlotMesh.java
public void setXYZData(ArrayList<Double> xData, ArrayList<Double> yData, ArrayList<Double> zData) {
        xAxisData = xData;
        yAxisData = yData;
        zAxisData = zData;
        getChildren().clear();
        //for now we will always default to x axis
        //later we could maybe dynamically determine the smallest axis and then
        //uses 0's for the other axes that are larger.
        ArrayList<Point3D> point3DList = new ArrayList<>();

        for(int i=0;i<xAxisData.size();i++) {
            //some safety checks for array sizes
            double translateY = 0.0;
            double translateZ = 0.0;            
            if(!yAxisData.isEmpty() && yAxisData.size() > i)
                translateY = yAxisData.get(i);
            if(!zAxisData.isEmpty() && zAxisData.size() > i)
                translateZ = zAxisData.get(i);
            setTranslateX(xAxisData.get(i));
            //Convert to Floats and build list of adjusted points
            point3DList.add(new Point3D(new Float(xAxisData.get(i)), new Float(translateY), new Float(translateZ)));

            float width = 1;
            final TriangleMesh mesh = new TriangleMesh();
            //add each point. For each point add another point shifted on Z axis by width
            //This extra point allows us to build triangles later
            for(Point3D point: point3DList) {
                //Rear points
                //top right rear point
                mesh.getPoints().addAll(point.x+width,point.y+width,point.z+width);
                //top left rear point
                mesh.getPoints().addAll(point.x-width,point.y+width,point.z+width);
                //bottom right rear point
                mesh.getPoints().addAll(point.x+width,point.y-width,point.z+width);
                //bottom left rear point
                mesh.getPoints().addAll(point.x-width,point.y-width,point.z+width);
                //Front points
                //top right front point
                mesh.getPoints().addAll(point.x+width,point.y+width,point.z-width);
                //top left front point
                mesh.getPoints().addAll(point.x-width,point.y+width,point.z-width);
                //bottom right front point
                mesh.getPoints().addAll(point.x+width,point.y-width,point.z-width);
                //bottom left front point
                mesh.getPoints().addAll(point.x-width,point.y-width,point.z-width);
            }
            //add dummy Texture Coordinate
            mesh.getTexCoords().addAll(0,0);
            //Now generate nodes for each point
            for(int p=8;p<point3DList.size()*7;p+=8) {  //add each segment
                //Wind the next 8 vertices as a cube.  The cube itself will represent the data
                //Vertices wound counter-clockwise which is the default front face of any Triangle
                //Rear triangle faces should be wound clockwise to face away from center
                mesh.getFaces().addAll(p,0,p+3,0,p+2,0); //TRR,BLR,BRR
                mesh.getFaces().addAll(p+3,0,p,0,p+1,0); //BLR,TRR,TLR
                //left side faces
                mesh.getFaces().addAll(p+1,0,p+5,0,p+3,0); //TLR,TLF,BLR
                mesh.getFaces().addAll(p+5,0,p+7,0,p+3,0); //TLF,BLR,BLF
                //front side faces
                mesh.getFaces().addAll(p+5,0,p+7,0,p+4,0); //TLF,BLF,TLR
                mesh.getFaces().addAll(p+4,0,p+7,0,p+6,0); //TRF,BLF,BRF
                //front side faces
                mesh.getFaces().addAll(p+4,0,p+6,0,p+2,0); //TRF,BRF,BRR
                mesh.getFaces().addAll(p+4,0,p+2,0,p,0); //TRF,BRR,TRR
               
                //Top faces
                mesh.getFaces().addAll(p,0,p+1,0,p+3,0); //TRR,TLR,TRF
                mesh.getFaces().addAll(p+1,0,p+5,0,p+3,0); //TLR,TLF,TRF
               
                //bottom faces
                mesh.getFaces().addAll(p+3,0,p+7,0,p+6,0); //BLR,BLF,BRF
                mesh.getFaces().addAll(p+3,0,p+6,0,p+2,0); //BLR,BRF,BRR
            }
           
            //Need to add the mesh to a MeshView before adding to our 3D scene
            MeshView meshView = new MeshView(mesh);
            meshView.setDrawMode(DrawMode.FILL);  //Fill so that the line shows width
                              
            Color hsb = Color.hsb((new Double(i)  / 12) * 360, 1.0, 1.0, 0.5);
            PhongMaterial material = new PhongMaterial(hsb);
            material.setDiffuseColor(hsb);
            material.setSpecularColor(hsb);
            meshView.setMaterial(material);
            //Make sure you Cull the Back so that no black shows through
            meshView.setCullFace(CullFace.BACK);    
//            //Add some ambient light so folks can see it
//            Group line = new Group();
//            AmbientLight light = new AmbientLight(Color.WHITE);
//            light.getScope().add(meshView);
//            line.getChildren().add(light);
//            line.getChildren().add(meshView);           
            getChildren().addAll(meshView);           
        }
    }
 
 类所在包
 同包方法