



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/* * Copyright (c) 2008, 2012 Oracle and/or its affiliates. * All rights reserved. Use is subject to license terms. */import javafx.scene.transform.Rotate;import javafx.scene.PerspectiveCamera;import javafx.scene.transform.Translate;import javafx.application.Application;import javafx.scene.Group;import javafx.scene.Scene;import javafx.stage.Stage;import javafx.animation.Animation;import javafx.animation.KeyFrame;import javafx.animation.KeyValue;import javafx.animation.Timeline;import javafx.scene.Node;import javafx.scene.paint.Color;import javafx.scene.shape.RectangleBuilder;import javafx.util.Duration;/* * A sample that demonstrates an animated rotation of 3D cubes. When the * application runs in standAlone mode, the scene must be constructed with * the depthBuffer argument set to true, and the root node must have depthTest * set to true. * * see javafx.scene.transform.Rotate * see javafx.scene.paint.Color * see javafx.scene.shape.RectangleBuilder */public class CubeSample extends Application private Timeline animation; private void init(Stage primaryStage) Group root = new Group(); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 400,150,true); primaryStage.getScene().setCamera(new PerspectiveCamera(); root.getTransforms().addAll( new Translate(400 / 2, 150 / 2), new Rotate(180, Rotate.X_AXIS) ); root.getChildren().add(create3dContent(); public Node create3dContent() Cube c1 = new Cube(50,Color.RED,1); c1.rx.setAngle(45); c1.ry.setAngle(45); Cube c2 = new Cube(50,Color.GREEN,1); c2.setTranslateX(100); c2.rx.setAngle(45); c2.ry.setAngle(45); Cube c3 = new Cube(50,Color.ORANGE,1); c3.setTranslateX(-100); c3.rx.setAngle(45); c3.ry.setAngle(45); animation = new Timeline(); animation.getKeyFrames().addAll( new KeyFrame(Duration.ZERO, new KeyValue(c1.ry.angleProperty(), 0d), new KeyValue(c2.rx.angleProperty(), 0d), new KeyValue(c3.rz.angleProperty(), 0d) ), new KeyFrame(Duration.seconds(1), new KeyValue(c1.ry.angleProperty(), 360d), new KeyValue(c2.rx.angleProperty(), 360d), new KeyValue(c3.rz.angleProperty(), 360d) ); animation.setCycleCount(Animation.INDEFINITE); return new Group(c1,c2,c3); public void play() animation.play(); Override public void stop() animation.pause(); public class Cube extends Group final Rotate rx = new Rotate(0,Rotate.X_AXIS); final Rotate ry = new Rotate(0,Rotate.Y_AXIS); final Rotate rz = new Rotate(0,Rotate.Z_AXIS); public Cube(double size, Color color, double shade) getTransforms().addAll(rz, ry, rx); getChildren().addAll( RectangleBuilder.create() / back face .width(size).height(size) .fill(color.deriveColor(0.0, 1.0, (1 - 0.5*shade), 1.0) .translateX(-0.5*size) .translateY(-0.5*size) .translateZ(0.5*size) .build(), RectangleBuilder.create() / bottom face .width(size).height(size) .fill(color.deriveColor(0.0, 1.0, (1 - 0.4*shade), 1.0) .translateX(-0.5*size) .translateY(0) .rotationAxis(Rotate.X_AXIS) .rotate(90) .build(), RectangleBuilder.create() / right face .width(size).height(size) .fill(color.deriveColor(0.0, 1.0, (1 - 0.3*shade), 1.0) .translateX(-1*size) .translateY(-0.5*size) .rotationAxis(Rotate.Y_AXIS) .rotate(90) .build(), RectangleBuilder.create() / left face .width(size).height(size) .fill(color.deriveColor(0.0, 1.0, (1 - 0.2*shade), 1.0) .translateX(0) .translateY(-0.5*size) .rotationAxis(Rotate.Y_AXIS) .rotate(90) .build(), RectangleBuilder.create() / top face .width(size).height(size) .fill(color.deriveColor(0.0, 1.0, (1 - 0.1*shade), 1.0) .translateX(-0.5*size) .translateY(-1*size) .rotationAxis(Rotate.X_AXIS) .rotate(90) .build(), RectangleBuilder.create() / top face .width(size).height(size) .fill(color) .translateX(-0.5*size) .translateY(-0.5*size) .translateZ(-0.5*size) .build() ); public double getSampleWidth() return 400; public dou
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 个人车辆挂靠合同范本
- 培训计划内容方案
- 小学信息技术第三册 第15课初学绘图命令教学设计 北京版
- 健身中心场地租赁合同2025年
- 食品购销合同样本
- 合作合同合作协议
- 合作伙伴协议书模板2025
- 中外合资公司合同大全
- 培训师竞聘述职
- 2024年04月青海果洛州事业单位招聘66人(含医疗岗)笔试历年专业考点(难、易错点)附带答案详解
- YS-T 5226-2016水质分析规程
- 国开2024年秋《生产与运作管理》形成性考核1-4答案
- 国家病案质控死亡病例自查表
- 2024年江苏省无锡市天一实验学校中考英语押题试卷含答案
- DB3305-T 57-2018幸福邻里中心建设与服务管理规范
- AIGC基础与应用全套教学课件
- 9.1.3二项分布(解析版)
- 神经生长因子在神经退行性疾病中的作用
- 国有企业采购管理规范 T/CFLP 0027-2020
- 《灾害风险管理》 课件 第6、7章 灾害风险分析与评估、灾害发生前的风险管理
- 2024年内蒙古中考地理生物试卷
评论
0/150
提交评论