



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/* * 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)专家共识-
- GB/T 31586.1-2015防护涂料体系对钢结构的防腐蚀保护涂层附着力/内聚力(破坏强度)的评定和验收准则第1部分:拉开法试验
- 水泵试运行调试记录
- 半导体中载流子的统计分布和计算
- 组织部处级干部培训审计财经纪律课件
- 史上最全最权威妇产科icd编码培训【版】课件
- 心血管诊治与抢救标准操作规程(SOP)
- 星级酒店MOD值班管理制度管理办法
- 中南大学自主招生综合素质测试面试试题答题技巧
- 科尔沁蒙古族草原上的婚礼
评论
0/150
提交评论