javafx.scene.shape.DrawMode Java Examples

The following examples show how to use javafx.scene.shape.DrawMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArbitraryMeshConfigSerializer.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@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);
	}
}
 
Example #2
Source File: SpringMesh.java    From FXyzLib with GNU General Public License v3.0 6 votes vote down vote up
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);
    
}
 
Example #3
Source File: CurvedSpringMesh.java    From FXyzLib with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: IcosahedronMesh.java    From FXyzLib with GNU General Public License v3.0 6 votes vote down vote up
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();
        }
    });
}
 
Example #5
Source File: KnotMesh.java    From FXyzLib with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: MeshSettingsSerializer.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: MeshGeneratorJobManager.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: SurfacePlotMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #9
Source File: BezierMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #10
Source File: CSGMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
public CSGMesh(CSG primitive){
    this.primitive=primitive;
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
Example #11
Source File: SegmentedSphereMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #12
Source File: SegmentedTorusMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #13
Source File: FrustumMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #14
Source File: TetrahedraMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
public TetrahedraMesh(double height, int level, Point3D center){
    setHeight(height);        
    setLevel(level);
    setCenter(center);
    
    updateMesh();
    setCullFace(CullFace.BACK);
    setDrawMode(DrawMode.FILL);
    setDepthTest(DepthTest.ENABLE);
}
 
Example #15
Source File: MeshGeneratorJobManager.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
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;
	}
 
Example #16
Source File: PrismMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #17
Source File: TriangulatedMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #18
Source File: CuboidMesh.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #19
Source File: TrapezoidTest.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private void generateShapes() {
        for (int i = 0; i < 50; i++) {
            Random r = new Random();
            //A lot of magic numbers in here that just artificially constrain the math
            double randomSmallSize = (double) ((r.nextDouble()*50) + 10);
            double randomBigSize = (double) ((r.nextDouble()*100)+ 50);
            double randomHeight = (double) ((r.nextDouble()*50)+ 25);
            double randomDepth = (double) ((r.nextDouble()*50) + 25);

            Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
            
            Trapezoid trapezoid = new Trapezoid(randomSmallSize, randomBigSize, 
                                    randomHeight, randomDepth, randomColor);
//            Trapezoid trapezoid = new Trapezoid(50, 100, 50, 50, randomColor);
            trapezoid.setEmissiveLightingColor(randomColor);
            trapezoid.setEmissiveLightingOn(r.nextBoolean());
            trapezoid.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
            
            double translationX = Math.random() * 1024;
            if (Math.random() >= 0.5) {
                translationX *= -1;
            }
            double translationY = Math.random() * 1024;
            if (Math.random() >= 0.5) {
                translationY *= -1;
            }
            double translationZ = Math.random() * 1024;
            if (Math.random() >= 0.5) {
                translationZ *= -1;
            }
            Translate translate = new Translate(translationX, translationY, translationZ);
            Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
            Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
            Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

            trapezoid.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
            
            shapeGroup.getChildren().add(trapezoid);
        }
    }
 
Example #20
Source File: SegmentMeshInfoNode.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #21
Source File: OctahedronTest.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private void generateShapes() {
    for (int i = 0; i < 100; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomHypotenuse = (float) ((r.nextFloat()*300) + 25);
        float randomHeight = (float) ((r.nextFloat()*200)+ 25);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        
        Octahedron octahedron = new Octahedron(randomHypotenuse, randomHeight, randomColor);
        octahedron.setEmissiveLightingColor(randomColor);
        octahedron.setEmissiveLightingOn(r.nextBoolean());
        octahedron.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
        
        double translationX = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        octahedron.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        
        shapeGroup.getChildren().add(octahedron);
    }
}
 
Example #22
Source File: Text3DMesh.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public void setDrawMode(DrawMode mode) {
    meshes.stream().forEach(m->m.setDrawMode(mode));
}
 
Example #23
Source File: Spheroid.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public final void setDrawMode(DrawMode value) {
    mesh.setDrawMode(value);
}
 
Example #24
Source File: Tetrahedron.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public final void setDrawMode(DrawMode value) {
    mesh.setDrawMode(value);
}
 
Example #25
Source File: Trapezoid.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public final void setDrawMode(DrawMode value) {
    mesh.setDrawMode(value);
}
 
Example #26
Source File: Torus.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public final void setDrawMode(DrawMode value) {
    mesh.setDrawMode(value);
}
 
Example #27
Source File: Octahedron.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public final void setDrawMode(DrawMode value) {
    mesh.setDrawMode(value);
}
 
Example #28
Source File: Pyramid.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public final void setDrawMode(DrawMode value) {
    mesh.setDrawMode(value);
}
 
Example #29
Source File: CapsuleTest.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    
    Group capsuleGroup = new Group();        
    for (int i = 0; i < 50; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat() * 100) + 25);
        float randomHeight = (float) ((r.nextFloat() * 300) + 75);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        
        Capsule cap = new Capsule(randomRadius, randomHeight, randomColor);               
        cap.setEmissiveLightingColor(randomColor);
        cap.setEmissiveLightingOn(r.nextBoolean());
        cap.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
        
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        cap.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        
        capsuleGroup.getChildren().add(cap);
    }
    
    root.getChildren().add(capsuleGroup);
            
    camera = new AdvancedCamera();
    controller = new FPSController();
    
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    
    controller.setScene(scene);
            
    stage.setTitle("Hello World!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(true);
    stage.setFullScreenExitHint("");
}
 
Example #30
Source File: ConeTest.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    
    Group coneGroup = new Group();        
    for (int i = 0; i < 100; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat()*100) + 25);
        float randomHeight = (float) ((r.nextFloat()*300)+ 75);
        int randomDivisions = (int) ((r.nextFloat()*50) + 5);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        
        Cone cone = new Cone(randomDivisions, randomRadius, randomHeight, randomColor);               
        cone.setEmissiveLightingColor(randomColor);
        cone.setEmissiveLightingOn(r.nextBoolean());
        cone.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
        
        double translationX = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        cone.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        
        coneGroup.getChildren().add(cone);
    }
    root.getChildren().add(coneGroup);
    
    camera = new AdvancedCamera();
    controller = new FPSController();
    
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    
    controller.setScene(scene);
            
    stage.setTitle("Random Cones!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(false);
    stage.setFullScreenExitHint("");
}