当前位置: 首页>>代码示例>>Java>>正文


Java Intersector.intersectRayTriangles方法代码示例

本文整理汇总了Java中com.badlogic.gdx.math.Intersector.intersectRayTriangles方法的典型用法代码示例。如果您正苦于以下问题:Java Intersector.intersectRayTriangles方法的具体用法?Java Intersector.intersectRayTriangles怎么用?Java Intersector.intersectRayTriangles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.math.Intersector的用法示例。


在下文中一共展示了Intersector.intersectRayTriangles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rayIntesects

import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
public LandscapeCell rayIntesects(Ray ray, Vector3 intersection) {
    List<Vector3> triangleList = new ArrayList<>();
    packedCells().forEach(c -> triangleList.addAll(c.trianglePoints()));
    if(Intersector.intersectRayTriangles(ray, triangleList, intersection)) {
        for (LandscapeCell cell : packedCells) {
            if(cell.rayIntersects(ray)) return cell;
        }
    }
    return null;
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:11,代码来源:LandscapeWorldActor.java

示例2: testHit

import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
public void testHit(Mesh mesh, Ray ray) {
    int numVertices = mesh.getNumVertices();
    float[] vertices = new float[numVertices];
    mesh.getVertices(vertices);

    int numIndices = mesh.getNumIndices();
    short[] indices = new short[numIndices];
    mesh.getIndices(indices);

    Vector3 intersection = new Vector3();
    if (Intersector.intersectRayTriangles(ray, vertices, indices, mesh.getVertexSize(), intersection))
        hit(ray, intersection);
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:14,代码来源:PointLight.java

示例3: rayIntersects

import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
public boolean rayIntersects(Ray ray) {
    return Intersector.intersectRayTriangles(ray, trianglePoints(), null);
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:4,代码来源:LandscapeCell.java

示例4: getPieceFromList

import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
/**
 * Finds the closest clicked chess piece from the list of pieces that had an
 * intersecting bounding box.
 * 
 * @param ray
 *            a ray from the camera position to the destination of the mouse
 *            click
 * @param playerWhite
 *            is the user playing as white
 * @return grid location instance of clicked chess piece
 */
private GridLocation getPieceFromList(Ray ray, boolean playerWhite) {

	GridLocation clickedPiece = null;

	for (GridLocation location : mIntersectedBoxList) {

		ModelInstance modelInstance = location.chessPiece.getCollisionModelInstance();
		Mesh mesh = modelInstance.model.meshes.get(0);

		modelInstance.transform.rotate(1, 0, 0, -90);
		modelInstance.transform.rotate(0, 0, 1, 180);
		Matrix4 inverse = new Matrix4(modelInstance.transform).inv();

		mesh.transform(modelInstance.transform);

		float[] vertices = new float[mesh.getNumVertices() * mesh.getVertexSize() / 4];
		short[] indices = new short[mesh.getNumIndices()];

		mesh.getVertices(vertices);
		mesh.getIndices(indices);

		if (Intersector.intersectRayTriangles(ray, vertices, indices, mesh.getVertexSize() / 4, null)) {
			clickedPiece = location;
		}

		mesh.transform(inverse);
		modelInstance.transform.rotate(0, 0, 1, -180);
		modelInstance.transform.rotate(1, 0, 0, 90);

		if (clickedPiece != null) {
			mIntersectedBoxList.clear();
			if (clickedPiece.chessPiece.getDescription() < 0 && playerWhite || clickedPiece.chessPiece.getDescription() > 0
					&& !playerWhite) {

				return clickedPiece;
			}
		}
	}

	return null;
}
 
开发者ID:nkarasch,项目名称:ChessGDX,代码行数:53,代码来源:ObjectPicker.java


注:本文中的com.badlogic.gdx.math.Intersector.intersectRayTriangles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。