📄 hirescoord.java
字号:
/* * $RCSfile: HiResCoord.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.4 $ * $Date: 2007/02/09 17:18:02 $ * $State: Exp $ */package javax.media.j3d;import java.lang.Integer;import javax.vecmath.*;/** * High resolution coordinate object. * *//** * The HiResCoord object specifies the location of scene * components within the Virtual Universe. * The coordinates of all scene graph objects are relative to * the HiResCoord of the Locale in which they are contained. * <P> * The HiResCoord defines a point using a set of three * high-resolution coordinates, each of which consists of three * two's-complement fixed-point numbers. * Each high-resolution number consists of 256 total bits with a * binary point at bit 128, or between the integers at index* 3 and 4. A high-resolution coordinate of 1.0 is defined to be exactly * 1 meter. This coordinate system is sufficient to describe a * universe in excess of several billion light years across, yet * still define objects smaller than a proton. * <P> * Java 3D uses integer arrays of length * eight to define or extract a single 256-bit coordinate value. * Java 3D interprets the integer at index 0 as the 32 * most-significant bits and the integer at index 7 as the 32 * least-significant bits. */public class HiResCoord { /** * The eight-element array containing the high resolution coordinate's * x value. */ int x[]; /** * The eight-element array containing the high resolution coordinate's * y value. */ int y[]; /** * The eight-element array containing the high resolution coordinate's * z value. */ int z[];private double scales[] = { 79228162514264337593543950336.0, // 2^96 18446744073709551616.0, // 2^64 4294967296.0, // 2^32 1.0, // 2^0 2.3283064365386962890625e-10, // 2^-32 5.421010862427522170037264004349708557128906250000000000000000e-20, // 2^-64 1.26217744835361888865876570445245796747713029617443680763244628906250e-29, // 2^-96 2.938735877055718769921841343055614194546663891930218803771879265696043148636817932128906250e-39 }; /** * Constructs and initializes a new HiResCoord using the values * provided in the argument. * The HiResCoord represents 768 bits of floating point 3-Space. * @param X an eight element array specifying the x position * @param Y an eight element array specifying the y position * @param Z an eight element array specifying the z position */ public HiResCoord(int[] X, int[] Y, int[] Z) { int i; this.x = new int[8]; this.y = new int[8]; this.z = new int[8]; for(i=0;i<8;i++) { this.x[i] = X[i]; this.y[i] = Y[i]; this.z[i] = Z[i]; } } /** * Constructs and initializes a new HiResCoord using the values * provided in the argument. * The HiResCoord represents 768 bits of floating point 3-Space. * @param hc the HiResCoord to copy */ public HiResCoord(HiResCoord hc) { this.x = new int[8]; this.y = new int[8]; this.z = new int[8]; this.x[0] = hc.x[0]; this.y[0] = hc.y[0]; this.z[0] = hc.z[0]; this.x[1] = hc.x[1]; this.y[1] = hc.y[1]; this.z[1] = hc.z[1]; this.x[2] = hc.x[2]; this.y[2] = hc.y[2]; this.z[2] = hc.z[2]; this.x[3] = hc.x[3]; this.y[3] = hc.y[3]; this.z[3] = hc.z[3]; this.x[4] = hc.x[4]; this.y[4] = hc.y[4]; this.z[4] = hc.z[4]; this.x[5] = hc.x[5]; this.y[5] = hc.y[5]; this.z[5] = hc.z[5]; this.x[6] = hc.x[6]; this.y[6] = hc.y[6]; this.z[6] = hc.z[6]; this.x[7] = hc.x[7]; this.y[7] = hc.y[7]; this.z[7] = hc.z[7]; } /** * Constructs and initializes a new HiResCoord located at (0, 0, 0). * The HiResCoord represents 768 bits of floating point 3-Space. */ public HiResCoord() { this.x = new int[8]; this.y = new int[8]; this.z = new int[8]; } /** * Sets this HiResCoord to the location specified by the * parameters provided. * @param X an eight-element array specifying the x position * @param Y an eight-element array specifying the y position * @param Z an eight-element array specifying the z position */ public void setHiResCoord(int[] X, int[] Y, int[] Z) { int i; for(i=0;i<8;i++) { this.x[i] = X[i]; this.y[i] = Y[i]; this.z[i] = Z[i]; } } /** * Sets this HiResCoord to the location specified by the * hires provided. * @param hires the hires coordinate to copy */ public void setHiResCoord(HiResCoord hires) { this.x[0] = hires.x[0]; this.y[0] = hires.y[0]; this.z[0] = hires.z[0]; this.x[1] = hires.x[1]; this.y[1] = hires.y[1]; this.z[1] = hires.z[1]; this.x[2] = hires.x[2]; this.y[2] = hires.y[2]; this.z[2] = hires.z[2]; this.x[3] = hires.x[3]; this.y[3] = hires.y[3]; this.z[3] = hires.z[3]; this.x[4] = hires.x[4]; this.y[4] = hires.y[4]; this.z[4] = hires.z[4]; this.x[5] = hires.x[5]; this.y[5] = hires.y[5]; this.z[5] = hires.z[5]; this.x[6] = hires.x[6]; this.y[6] = hires.y[6]; this.z[6] = hires.z[6]; this.x[7] = hires.x[7]; this.y[7] = hires.y[7]; this.z[7] = hires.z[7]; } /** * Sets this HiResCoord's X value to that specified by the argument. * @param X an eight-element array specifying the x position */ public void setHiResCoordX(int[] X) { this.x[0] = X[0]; this.x[1] = X[1]; this.x[2] = X[2]; this.x[3] = X[3]; this.x[4] = X[4]; this.x[5] = X[5]; this.x[6] = X[6]; this.x[7] = X[7]; } /** * Sets this HiResCoord's Y value to that specified by the argument. * @param Y an eight-element array specifying the y position */ public void setHiResCoordY(int[] Y) { this.y[0] = Y[0]; this.y[1] = Y[1]; this.y[2] = Y[2]; this.y[3] = Y[3]; this.y[4] = Y[4]; this.y[5] = Y[5]; this.y[6] = Y[6]; this.y[7] = Y[7]; } /** * Sets this HiResCoord's Z value to that specified by the argument. * @param Z an eight-element array specifying the z position */ public void setHiResCoordZ(int[] Z) { this.z[0] = Z[0]; this.z[1] = Z[1]; this.z[2] = Z[2]; this.z[3] = Z[3]; this.z[4] = Z[4]; this.z[5] = Z[5]; this.z[6] = Z[6]; this.z[7] = Z[7]; } /** * Retrieves this HiResCoord's location and saves the coordinates * in the specified arrays. The arrays must be large enough * to hold all of the ints. * @param X an eight element array that will receive the x position * @param Y an eight element array that will receive the y position * @param Z an eight element array that will receive the z position */ public void getHiResCoord(int[] X, int[] Y, int[] Z) { X[0] = this.x[0]; X[1] = this.x[1]; X[2] = this.x[2]; X[3] = this.x[3]; X[4] = this.x[4]; X[5] = this.x[5]; X[6] = this.x[6]; X[7] = this.x[7]; Y[0] = this.y[0]; Y[1] = this.y[1]; Y[2] = this.y[2]; Y[3] = this.y[3]; Y[4] = this.y[4]; Y[5] = this.y[5]; Y[6] = this.y[6]; Y[7] = this.y[7]; Z[0] = this.z[0]; Z[1] = this.z[1]; Z[2] = this.z[2]; Z[3] = this.z[3]; Z[4] = this.z[4]; Z[5] = this.z[5]; Z[6] = this.z[6]; Z[7] = this.z[7]; } /** * Retrieves this HiResCoord's location and places it into the hires * argument. * @param hc the hires coordinate that will receive this node's location */ public void getHiResCoord(HiResCoord hc) { hc.x[0] = this.x[0]; hc.x[1] = this.x[1]; hc.x[2] = this.x[2]; hc.x[3] = this.x[3]; hc.x[4] = this.x[4]; hc.x[5] = this.x[5]; hc.x[6] = this.x[6]; hc.x[7] = this.x[7]; hc.y[0] = this.y[0]; hc.y[1] = this.y[1]; hc.y[2] = this.y[2]; hc.y[3] = this.y[3]; hc.y[4] = this.y[4]; hc.y[5] = this.y[5]; hc.y[6] = this.y[6]; hc.y[7] = this.y[7]; hc.z[0] = this.z[0]; hc.z[1] = this.z[1]; hc.z[2] = this.z[2]; hc.z[3] = this.z[3]; hc.z[4] = this.z[4]; hc.z[5] = this.z[5]; hc.z[6] = this.z[6]; hc.z[7] = this.z[7]; } /** * Retrieves this HiResCoord's X value and stores it in the specified * array. The array must be large enough to hold all of the ints. * @param X an eight-element array that will receive the x position */ public void getHiResCoordX(int[] X) { X[0] = this.x[0]; X[1] = this.x[1]; X[2] = this.x[2]; X[3] = this.x[3]; X[4] = this.x[4]; X[5] = this.x[5]; X[6] = this.x[6]; X[7] = this.x[7]; } /** * Retrieves this HiResCoord's Y value and stores it in the specified * array. The array must be large enough to hold all of the ints. * @param Y an eight-element array that will receive the y position */ public void getHiResCoordY(int[] Y) { Y[0] = this.y[0]; Y[1] = this.y[1]; Y[2] = this.y[2]; Y[3] = this.y[3]; Y[4] = this.y[4]; Y[5] = this.y[5]; Y[6] = this.y[6]; Y[7] = this.y[7]; } /** * Retrieves this HiResCoord's Z value and stores it in the specified * array. The array must be large enough to hold all of the ints. * @param Z an eight-element array that will receive the z position
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -