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


Java CollisionResult.setTriangleIndex方法代码示例

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


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

示例1: intersectBrute

import com.jme3.collision.CollisionResult; //导入方法依赖的package包/类
public final int intersectBrute(Ray r,
        Matrix4f worldMatrix,
        BIHTree tree,
        float sceneMin,
        float sceneMax,
        CollisionResults results) {
    float tHit = Float.POSITIVE_INFINITY;

    Vector3f v1 = new Vector3f(),
            v2 = new Vector3f(),
            v3 = new Vector3f();

    int cols = 0;

    TempVars vars = TempVars.get();
    ArrayList<BIHStackData> stack = vars.bihStack;
    stack.clear();
    stack.add(new BIHStackData(this, 0, 0));
    stackloop:
    while (stack.size() > 0) {

        BIHStackData data = stack.remove(stack.size() - 1);
        BIHNode node = data.node;

        leafloop:
        while (node.axis != 3) { // while node is not a leaf
            BIHNode nearNode, farNode;
            nearNode = node.left;
            farNode = node.right;

            stack.add(new BIHStackData(farNode, 0, 0));
            node = nearNode;
        }

        // a leaf
        for (int i = node.leftIndex; i <= node.rightIndex; i++) {
            tree.getTriangle(i, v1, v2, v3);

            if (worldMatrix != null) {
                worldMatrix.mult(v1, v1);
                worldMatrix.mult(v2, v2);
                worldMatrix.mult(v3, v3);
            }

            float t = r.intersects(v1, v2, v3);
            if (t < tHit) {
                tHit = t;
                Vector3f contactPoint = new Vector3f(r.direction).multLocal(tHit).addLocal(r.origin);
                CollisionResult cr = new CollisionResult(contactPoint, tHit);
                cr.setTriangleIndex(tree.getTriangleIndex(i));
                results.addCollision(cr);
                cols++;
            }
        }
    }
    vars.release();
    return cols;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:59,代码来源:BIHNode.java

示例2: intersectBrute

import com.jme3.collision.CollisionResult; //导入方法依赖的package包/类
public final int intersectBrute(Ray r,
        Matrix4f worldMatrix,
        BIHTree tree,
        float sceneMin,
        float sceneMax,
        CollisionResults results) {
    float tHit = Float.POSITIVE_INFINITY;
    
    TempVars vars = TempVars.get();

    Vector3f v1 = vars.vect1,
            v2 = vars.vect2,
            v3 = vars.vect3;

    int cols = 0;

    ArrayList<BIHStackData> stack = vars.bihStack;
    stack.clear();
    stack.add(new BIHStackData(this, 0, 0));
    stackloop:
    while (stack.size() > 0) {

        BIHStackData data = stack.remove(stack.size() - 1);
        BIHNode node = data.node;

        leafloop:
        while (node.axis != 3) { // while node is not a leaf
            BIHNode nearNode, farNode;
            nearNode = node.left;
            farNode = node.right;

            stack.add(new BIHStackData(farNode, 0, 0));
            node = nearNode;
        }

        // a leaf
        for (int i = node.leftIndex; i <= node.rightIndex; i++) {
            tree.getTriangle(i, v1, v2, v3);

            if (worldMatrix != null) {
                worldMatrix.mult(v1, v1);
                worldMatrix.mult(v2, v2);
                worldMatrix.mult(v3, v3);
            }

            float t = r.intersects(v1, v2, v3);
            if (t < tHit) {
                tHit = t;
                Vector3f contactPoint = new Vector3f(r.direction).multLocal(tHit).addLocal(r.origin);
                CollisionResult cr = new CollisionResult(contactPoint, tHit);
                cr.setTriangleIndex(tree.getTriangleIndex(i));
                results.addCollision(cr);
                cols++;
            }
        }
    }
    vars.release();
    return cols;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:60,代码来源:BIHNode.java


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