本文整理匯總了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;
}