當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。