/** * Fill the buffer with the transforms and return it */ protected FloatBuffer fillTransformBuffer() { _primCount = Math.min(_visibleMeshes.size(), _maxBatchSize); final int nrOfFloats = _primCount * 16; /* 16 floats per matrix */ // re-init buffer when it is too small of more than twice the required size if (_transformBuffer == null || nrOfFloats > _transformBuffer.capacity()) { _transformBuffer = BufferUtils.createFloatBuffer(nrOfFloats); } _transformBuffer.rewind(); _transformBuffer.limit(nrOfFloats); final Matrix4 mat = Matrix4.fetchTempInstance(); for (int i = 0; i < _maxBatchSize && _meshesToDraw > 0; i++) { final Mesh mesh = _visibleMeshes.get(--_meshesToDraw); final Matrix4 transform = mesh.getWorldTransform().getHomogeneousMatrix(mat); transform.toFloatBuffer(_transformBuffer, false); } Matrix4.releaseTempInstance(mat); _transformBuffer.rewind(); return _transformBuffer; }
/** * Fill the buffer with the transforms and return it */ protected FloatBuffer fillTransformBuffer() { _primCount = Math.min(_visibleMeshes.size(), _maxBatchSize); final int nrOfFloats = _primCount * 16; /* 16 floats per matrix */ // re-init buffer when it is too small of more than twice the required size if (_transformBuffer == null || nrOfFloats > _transformBuffer.capacity()) { _transformBuffer = BufferUtils.createFloatBuffer(nrOfFloats); } _transformBuffer.rewind(); _transformBuffer.limit(nrOfFloats); final Matrix4 mat = Matrix4.fetchTempInstance(); for (int i = 0; i < _maxBatchSize && _meshesToDraw > 0; i++) { final Mesh mesh = _visibleMeshes.get(--_meshesToDraw); final Matrix4 transform = mesh.getWorldTransform().getHomogeneousMatrix(mat); transform.toFloatBuffer(_transformBuffer, false); } Matrix4.releaseTempInstance(mat); _transformBuffer.rewind(); return _transformBuffer; }
_left._worldBounds = _left._bounds.transform(getMesh().getWorldTransform(), _left._worldBounds); _left.intersect(ray, result); _right._worldBounds = _right._bounds.transform(getMesh().getWorldTransform(), _right._worldBounds); _right.intersect(ray, result); } else if (_left == null) { final ReadOnlyTransform transform = getMesh().getWorldTransform();
_left._worldBounds = _left._bounds.transform(getMesh().getWorldTransform(), _left._worldBounds); _left.intersect(ray, result); _right._worldBounds = _right._bounds.transform(getMesh().getWorldTransform(), _right._worldBounds); _right.intersect(ray, result); } else if (_left == null) { final ReadOnlyTransform transform = getMesh().getWorldTransform();
ct.getBounds().transform(getWorldTransform(), ct.getWorldBounds()); ct.intersect(ray, primitives); for (int j = 0; j < max; j++) { if (vertices[j] != null) { getWorldTransform().applyForward(vertices[j]);
ct.getBounds().transform(getWorldTransform(), ct.getWorldBounds()); ct.intersect(ray, primitives); for (int j = 0; j < max; j++) { if (vertices[j] != null) { getWorldTransform().applyForward(vertices[j]);
collisionTree._worldBounds = collisionTree._bounds.transform(collisionTree.getMesh().getWorldTransform(), collisionTree._worldBounds); final ReadOnlyTransform transformA = getMesh().getWorldTransform(); final ReadOnlyTransform transformB = collisionTree.getMesh().getWorldTransform();
collisionTree._worldBounds = collisionTree._bounds.transform(collisionTree.getMesh().getWorldTransform(), collisionTree._worldBounds); final ReadOnlyTransform transformA = getMesh().getWorldTransform(); final ReadOnlyTransform transformB = collisionTree.getMesh().getWorldTransform();
collisionTree._worldBounds = collisionTree._bounds.transform(collisionTree.getMesh().getWorldTransform(), collisionTree._worldBounds); final ReadOnlyTransform transformA = getMesh().getWorldTransform(); final ReadOnlyTransform transformB = collisionTree.getMesh().getWorldTransform();
collisionTree._worldBounds = collisionTree._bounds.transform(collisionTree.getMesh().getWorldTransform(), collisionTree._worldBounds); final ReadOnlyTransform transformA = getMesh().getWorldTransform(); final ReadOnlyTransform transformB = collisionTree.getMesh().getWorldTransform();
/** * This function finds all intersections between this mesh and the checking one. The intersections are stored as * PrimitiveKeys. * * @param toCheck * The Mesh to check. * @param testIndex * The array of PrimitiveKeys intersecting in this mesh. * @param otherIndex * The array of PrimitiveKeys intersecting in the given mesh. */ public static void findPrimitiveCollision(final Mesh testMesh, final Mesh toCheck, final List<PrimitiveKey> testIndex, final List<PrimitiveKey> otherIndex) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return; } final CollisionTree myTree = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree otherTree = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (myTree == null || otherTree == null) { return; } myTree.getBounds().transform(testMesh.getWorldTransform(), myTree.getWorldBounds()); myTree.intersect(otherTree, testIndex, otherIndex); }
/** * This function checks for intersection between this mesh and the given one. On the first intersection, true is * returned. * * @param toCheck * The intersection testing mesh. * @return True if they intersect. */ public static boolean hasPrimitiveCollision(final Mesh testMesh, final Mesh toCheck) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return false; } final CollisionTree thisCT = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree checkCT = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (thisCT == null || checkCT == null) { return false; } final ReadOnlyTransform worldTransform = testMesh.getWorldTransform(); thisCT.getBounds().transform(worldTransform, thisCT.getWorldBounds()); return thisCT.intersect(checkCT); }
renderer.setMatrix(RenderMatrixType.Model, getWorldTransform()); renderer.computeNormalMatrix(getWorldTransform().isUniformScale());
/** * This function checks for intersection between this mesh and the given one. On the first intersection, true is * returned. * * @param toCheck * The intersection testing mesh. * @return True if they intersect. */ public static boolean hasPrimitiveCollision(final Mesh testMesh, final Mesh toCheck) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return false; } final CollisionTree thisCT = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree checkCT = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (thisCT == null || checkCT == null) { return false; } final ReadOnlyTransform worldTransform = testMesh.getWorldTransform(); thisCT.getBounds().transform(worldTransform, thisCT.getWorldBounds()); return thisCT.intersect(checkCT); }
/** * This function finds all intersections between this mesh and the checking one. The intersections are stored as * PrimitiveKeys. * * @param toCheck * The Mesh to check. * @param testIndex * The array of PrimitiveKeys intersecting in this mesh. * @param otherIndex * The array of PrimitiveKeys intersecting in the given mesh. */ public static void findPrimitiveCollision(final Mesh testMesh, final Mesh toCheck, final List<PrimitiveKey> testIndex, final List<PrimitiveKey> otherIndex) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return; } final CollisionTree myTree = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree otherTree = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (myTree == null || otherTree == null) { return; } myTree.getBounds().transform(testMesh.getWorldTransform(), myTree.getWorldBounds()); myTree.intersect(otherTree, testIndex, otherIndex); }
mesh.getWorldTransform().applyForward(_normalVect); lineVerts.put(_normalVect.getXf()); lineVerts.put(_normalVect.getYf()); mesh.getWorldTransform().applyForwardVector(_normalVect2).normalizeLocal().multiplyLocal(rSize); _normalVect.addLocal(_normalVect2); lineVerts.put(_normalVect.getXf());
mesh.getWorldTransform().applyForward(_normalVect); lineVerts.put(_normalVect.getXf()); lineVerts.put(_normalVect.getYf()); mesh.getWorldTransform().applyForwardVector(_normalVect2).normalizeLocal().multiplyLocal(rSize); _normalVect.addLocal(_normalVect2); lineVerts.put(_normalVect.getXf());