本文整理汇总了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;
}
示例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);
}
示例3: rayIntersects
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
public boolean rayIntersects(Ray ray) {
return Intersector.intersectRayTriangles(ray, trianglePoints(), null);
}
示例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;
}