⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plane.java

📁 使用stl技术,(还没看,是听说的)
💻 JAVA
字号:
/*  Ogre4J
    Copyright (C) 2002 macross

    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 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 PURPOSE.  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 org.ogre4j;

import org.ogre4j.math.Vector3;

/**
 * Plane
 * 
 * @author Ivica Aracic <ivica.aracic@bytelords.de>
 */
public class Plane extends NativeObject {
	
	public final static int NO_SIDE = 0;
	public final static int POSITIVE_SIDE = 1;
	public final static int NEGATIVE_SIDE = 2;
	
	public Vector3 normal;
	public float d;
	
	public Plane() {
		normal = new Vector3();
		set(Vector3.UNIT_Y,0);
	}
	
	public Plane(Plane rhs) {
		normal = new Vector3();
		set(rhs.normal,rhs.d);
	}
	 
	public Plane(Vector3 rkNormal, float fConstant) {
		normal = new Vector3();
		set(rkNormal,fConstant);
	}

	public Plane(Vector3 rkNormal, Vector3 rkPoint) {
		normal = new Vector3();
		set(rkNormal,-rkNormal.dotProduct(rkPoint));
	}

	public Plane(Vector3 rkPoint0, Vector3 rkPoint1, Vector3 rkPoint2) {
		normal = new Vector3();
		
		Vector3 kEdge1 = rkPoint1.sub(rkPoint0);
		Vector3 kEdge2 = rkPoint2.sub(rkPoint0);
		Vector3 vRes  = kEdge1.cross(kEdge2);
		vRes.normalize();
		set(vRes,-normal.dotProduct(rkPoint0));
	}
	
	public native float getDistance(Vector3 rkPoint);
	
	public native int getSide(Vector3 rkPoint);
	
	public void set(Vector3 rkNormal, float fConstant) {
		this.normal.set(rkNormal);
		this.d = fConstant;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -