/** * Creates a new AABB that encapsulates a set of AABBs. * * @param others The other AABBs that'll define the extents of the new one. */ public static AABB createEncompassing(Iterable<AABB> others) { Vector3f min; Vector3f max; Iterator<AABB> i = others.iterator(); if (i.hasNext()) { AABB next = i.next(); min = next.getMin(); max = next.getMax(); } else { return createEmpty(); } while (i.hasNext()) { AABB next = i.next(); Vector3f otherMin = next.getMin(); Vector3f otherMax = next.getMax(); Vector3fUtil.min(min, otherMin, min); Vector3fUtil.max(max, otherMax, max); } return new AABB(min, max); }
@Override protected void doReload(MeshData meshData) { this.data = meshData; this.aabb = AABB.createEncompasing(meshData.getVertices()); }
public SkeletalMeshData build() { int rootBones = 0; for (Bone bone : bones) { if (bone.getParent() == null) { rootBones++; } } if (rootBones == 0) { throw new IllegalStateException("Cannot create a skeleton with no root bones"); } else if (rootBones > 1) { throw new IllegalStateException("Cannot create a skeleton with multiple root bones"); } AABB staticAabb; if (minOfAABB != null && maxOfAABB != null) { staticAabb = AABB.createMinMax(minOfAABB, maxOfAABB); } else { staticAabb = AABB.createEmpty(); } // TODO: More validation return new SkeletalMeshData(bones, weights, uvs, vertexStartWeights, vertexWeightCounts, indices, staticAabb); } }
Physics physics = CoreRegistry.get(Physics.class); AABB blockBounds = block.getBounds(blockPos); Vector3f min = new Vector3f(blockBounds.getMin()); Vector3f max = new Vector3f(blockBounds.getMax()); max.sub(ADDITIONAL_ALLOWED_PENETRATION, ADDITIONAL_ALLOWED_PENETRATION, ADDITIONAL_ALLOWED_PENETRATION); AABB newBounds = AABB.createMinMax(min, max); return physics.scanArea(newBounds, StandardCollisionGroup.DEFAULT, StandardCollisionGroup.CHARACTER).isEmpty();
long id = entity.getId(); LocationComponent locationComponent = new LocationComponent(); Vector3f positionInChunk = new Vector3f(chunk.getAABB().getMin()); positionInChunk.x += 1; positionInChunk.y += 1;
/** * Creates an empty AABB that does not contain any points. * * @return The created AABB. */ public static AABB createEmpty() { return new AABB(new Vector3f(), new Vector3f()); }
private void readBounds(BufferedReader reader, MD5 md5) throws IOException { md5.bounds = new AABB[md5.numFrames]; for (int i = 0; i < md5.numFrames; ++i) { String line = MD5ParserCommon.readNextLine(reader); Matcher matcher = doubleVectorPattern.matcher(line); if (!matcher.find()) { throw new IOException("Invalid bounds line: \"" + line + "\""); } Vector3f a = MD5ParserCommon.readVector3fAndCorrect(matcher.group(1), matcher.group(2), matcher.group(3)); Vector3f b = MD5ParserCommon.readVector3fAndCorrect(matcher.group(4), matcher.group(5), matcher.group(6)); Vector3f min = new Vector3f(); min.x = Math.min(a.x, b.x); min.y = Math.min(a.y, b.y); min.z = Math.min(a.z, b.z); Vector3f max = new Vector3f(); max.x = Math.max(a.x, b.x); max.y = Math.max(a.y, b.y); max.z = Math.max(a.z, b.z); md5.bounds[i] = AABB.createMinMax(min, max); } }
@Override public void setAABB(AABB from) { if (from != null && !from.equals(this.aabb)) { this.aabb = from; dispose(); } }
AABB aabb = AABB.createEncompassing(Arrays.asList(md5.bounds)); return new MeshAnimationData(boneNames, boneParents, frames, timePerFrame, aabb);
Vector3f diff = new Vector3f(centerPointForNormal(n)); diff.sub(origin);
protected Collection<EntityRef> getEntitiesOfChunk(Chunk chunk) { List<EntityRef> entitiesToStore = Lists.newArrayList(); AABB aabb = chunk.getAABB(); for (EntityRef entity : getEntityManager().getEntitiesWith(LocationComponent.class)) { if (!entity.getOwner().exists() && !entity.isAlwaysRelevant() && !entity.hasComponent(ClientComponent.class)) { LocationComponent loc = entity.getComponent(LocationComponent.class); if (loc != null) { if (aabb.contains(loc.getWorldPosition())) { entitiesToStore.add(entity); } } } } return entitiesToStore; }
/** * Get a new AABB which have a new location base on the offset * @param offset The offset between the current AABB and the new AABB * @return the new AABB */ public AABB move(Vector3f offset) { Vector3f newMin = new Vector3f(min); newMin.add(offset); Vector3f newMax = new Vector3f(max); newMax.add(offset); return new AABB(newMin, newMax); }
@Override public AABB getAABB() { if (aabb == null) { Vector3f min = getChunkWorldOffset().toVector3f(); Vector3f max = ChunkConstants.CHUNK_SIZE.toVector3f(); max.add(min); aabb = AABB.createMinMax(min, max); } return aabb; }
/** * Creates a new AABB that contains the vertices as represented by a {@link TFloatList}. * * @param vertices The vertices to encompass. It is assumed that the X, Y, Z components of each * vertex are stored consecutively in the {@link TFloatList}. * * For the {@code i}th vertex in the list, the X, Y, and Z components * are stored at indices {@code 3 * i}, {@code 3 * i + 1}, and * {@code 3 * i + 2} respectively. * * @return The created AABB. */ public static AABB createEncompasing(TFloatList vertices) { int vertexCount = vertices.size() / 3; if (vertexCount == 0) { return AABB.createEmpty(); } Vector3f min = new Vector3f(vertices.get(0), vertices.get(1), vertices.get(2)); Vector3f max = new Vector3f(vertices.get(0), vertices.get(1), vertices.get(2)); for (int index = 1; index < vertexCount; ++index) { min.x = Math.min(min.x, vertices.get(3 * index)); max.x = Math.max(max.x, vertices.get(3 * index)); min.y = Math.min(min.y, vertices.get(3 * index + 1)); max.y = Math.max(max.y, vertices.get(3 * index + 1)); min.z = Math.min(min.z, vertices.get(3 * index + 2)); max.z = Math.max(max.z, vertices.get(3 * index + 2)); } return AABB.createMinMax(min, max); }
/** * Creates a new AABB from the given minimum and maximum points, both inclusive. * * @param min The minimum of the AABB. * @param max The maximum of the AABB. * @return The created AABB. */ public static AABB createMinMax(Vector3f min, Vector3f max) { return new AABB(new Vector3f(min), new Vector3f(max)); }
@Override public AABB getAABB(org.terasology.math.Transform transform) { Transform t = toBulletTransform(transform); javax.vecmath.Vector3f min = new javax.vecmath.Vector3f(); javax.vecmath.Vector3f max = new javax.vecmath.Vector3f(); underlyingShape.getAabb(t, min, max); return AABB.createMinMax(VecMath.from(min), VecMath.from(max)); }
createIndexBuffer(newData.getIndices()); aabb = AABB.createEncompasing(newData.getVertices());
/** * Creates a new AABB with the given center and extents. * * @param center The center of the AABB. * @param extent The extent of the AABB. * @return The created AABB. */ public static AABB createCenterExtent(Vector3f center, Vector3f extent) { Vector3f min = new Vector3f(center); min.sub(extent); Vector3f max = new Vector3f(center); max.add(extent); return new AABB(min, max); }
return AABB.createMinMax(worldMin, worldMax);