Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.scene; 027 028import com.sun.javafx.geom.PickRay; 029import com.sun.javafx.geom.Vec3d; 030import com.sun.javafx.geom.transform.Affine3D; 031import com.sun.javafx.geom.transform.GeneralTransform3D; 032import com.sun.javafx.sg.PGNode; 033import com.sun.javafx.sg.PGParallelCamera; 034import com.sun.javafx.tk.Toolkit; 035 036/** 037 * Specifies a parallel camera for rendering a scene without perspective correction. 038 * 039 * <p>If a scene contains only 2D transforms, then the following details are not 040 * relevant. 041 * This camera defines a viewing volume for a parallel (orthographic) projection; 042 * a rectangular box. This camera is always located at center of the window and 043 * looks along the positive z-axis. The coordinate system defined by this camera 044 * has its origin in the upper left corner of the panel with the Y-axis pointing 045 * down and the Z axis pointing away from the viewer (into the screen). The 046 * units are in pixel coordinates. 047 * 048 * @since JavaFX 1.3 049 */ 050public class ParallelCamera extends Camera { 051 052 @Override 053 Camera copy() { 054 ParallelCamera c = new ParallelCamera(); 055 c.setNearClip(getNearClip()); 056 c.setFarClip(getFarClip()); 057 return c; 058 } 059 060 /** 061 * @treatAsPrivate implementation detail 062 * @deprecated This is an internal API that is not intended for use and will be removed in the next version 063 */ 064 @Deprecated 065 @Override 066 protected PGNode impl_createPGNode() { 067 PGParallelCamera pgCamera = Toolkit.getToolkit().createPGParallelCamera(); 068 pgCamera.setNearClip((float) getNearClip()); 069 pgCamera.setFarClip((float) getFarClip()); 070 return pgCamera; 071 } 072 073 @Override 074 final PickRay computePickRay(double x, double y, PickRay pickRay) { 075 return PickRay.computeParallelPickRay(x, y, getCameraTransform(), 076 //TODO: use actual clips after rendering uses them 077 Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, pickRay); 078 } 079 080 @Override 081 void computeProjectionTransform(GeneralTransform3D proj) { 082 final double viewWidth = getViewWidth(); 083 final double viewHeight = getViewHeight(); 084 final double halfDepth = 085 (viewWidth > viewHeight) ? viewWidth / 2.0 : viewHeight / 2.0; 086 087 proj.ortho(0.0, viewWidth, viewHeight, 0.0, -halfDepth, halfDepth); 088 } 089 090 @Override 091 protected void computeViewTransform(Affine3D view) { 092 view.setToIdentity(); 093 } 094 095 @Override 096 Vec3d computePosition(Vec3d position) { 097 if (position == null) { 098 position = new Vec3d(); 099 } 100 101 position.set(0.0, 0.0, -1.0); 102 return position; 103 } 104}