📄 geometry.java
字号:
/* * J3DME Fast 3D software rendering for small devices * Copyright (C) 2001 Onno Hommes * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOS. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package net.jscience.j3dme;/** * This class is the root of all geometry types. It enforces that each * geometry is based on an array of int's known as the coordinate stream. * The coordinate stream is either empty or contains a a stream of int's * representing the x,y and z component of a vertex or normal vector. * The x,y and z components are all normal ints and should not contain * fixed point integers. * * @see Wireframe */abstract class Geometry{ protected int[] x; protected int[] y; protected int[] z; protected int bounding_radius; /** * Return the bounding radius of a geometry<p> * This method returns the bounding radius. The bounding radius defines * a sphere that encapsulates the 3D object defined by the geometry * object. This sphere is used to determine if a 3D-object is in the * view frustrum (in the field of view of a camera). This concept is * similar to the bounding box principle. However the bounding sphere * is a simpler version that does not require much machine cycles. * * @return The radius of the bounding sphere. */ public int getBoundingRadius(){ return bounding_radius; } /* * This method cheats it just takes the largest coordinate component. */ protected int setBoundingRadius(){ int radius = -1; for(int i=0;i<x.length;i++){ radius = Math.max(radius,Math.abs(x[i])); radius = Math.max(radius,Math.abs(y[i])); radius = Math.max(radius,Math.abs(z[i])); } return radius; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -