全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/* * 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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 实时视频无线传输协议书
- 绿色复合材料在木材改良中的有效性研究-洞察及研究
- 绿色养殖技术应用-洞察及研究
- 锦纶纤维防水性能的纳米技术应用-洞察及研究
- 车间整改方案十篇
- 班级消防演练总结报告范文大全
- 2025年智能翻译软件市场分析报告
- 基于大数据的稳态系统建模-洞察及研究
- 广播节目版权保护与数字分发的挑战与对策-洞察及研究
- 大数据在经济决策中的角色-洞察及研究
- 激光熔覆应用介绍
- 电除颤临床操作规范指南样本
- 教学《近似数》数学课件教案
- 2025年西昌市邛海泸山风景名胜区管理局招聘5名执法协勤人员备考题库完整参考答案详解
- 2025年中共湛江市委巡察服务保障中心、湛江市清风苑管理中心公开招聘事业编制工作人员8人备考题库完整参考答案详解
- 2025年产业融合发展与区域经济一体化进程研究可行性研究报告
- 医保科工作流程管理标准化方案
- 2025呼伦贝尔莫旗消防救援大队招聘消防文员(公共基础知识)综合能力测试题附答案解析
- 《国家赔偿法》期末终结性考试(占总成绩50%)-国开(ZJ)-参考资料
- 社会能力训练教程
- 2024年有机硅有机硅橡胶项目管理培训课件
评论
0/150
提交评论