Package org.terasology.math

Examples of org.terasology.math.Vector3i


    }


    @Override
    public Chunk getChunk(int x, int y, int z) {
        return getChunk(new Vector3i(x, y, z));
    }
View Full Code Here


    }

    @Override
    public ChunkViewCore getSubviewAroundBlock(Vector3i blockPos, int extent) {
        Region3i region = TeraMath.getChunkRegionAroundWorldPos(blockPos, extent);
        return createWorldView(region, new Vector3i(-region.min().x, -region.min().y, -region.min().z));
    }
View Full Code Here

    @Override
    public ChunkViewCore getSubviewAroundChunk(Vector3i chunkPos) {
        Region3i region = Region3i.createFromCenterExtents(chunkPos, ChunkConstants.LOCAL_REGION_EXTENTS);
        if (getChunk(chunkPos) != null) {
            return createWorldView(region, new Vector3i(-region.min().x, -region.min().y, -region.min().z));
        }
        return null;
    }
View Full Code Here

        public int compare(ChunkTask o1, ChunkTask o2) {
            return score(o1.getPosition()) - score(o2.getPosition());
        }

        private int score(Vector3i chunk) {
            Vector3i playerChunk = TeraMath.calcChunkPos(new Vector3i(localPlayer.getPosition(), 0.5f));
            return playerChunk.distanceSquared(chunk);
        }
View Full Code Here

        if (blockSelectionComponent.currentSelection == null) {
            if (blockSelectionComponent.startPosition != null) {
                selectionRenderer.renderMark(blockSelectionComponent.startPosition);
            }
        } else {
            Vector3i size = blockSelectionComponent.currentSelection.size();
            Vector3i block = new Vector3i();
            for (int z = 0; z < size.z; z++) {
                for (int y = 0; y < size.y; y++) {
                    for (int x = 0; x < size.x; x++) {
                        block.set(x, y, z);
                        block.add(blockSelectionComponent.currentSelection.min());
                        selectionRenderer.renderMark(block);
                    }
                }
            }
        }
View Full Code Here

        this.hit = true;
        this.entity = entity;
        this.hitPoint = hitPoint;
        this.hitNormal = hitNormal;
        //This is the block were the hitPoint is inside:
        this.blockPosition = new Vector3i(hitPoint, 0.5f);
        this.worldHit = false;
    }
View Full Code Here

    }

    private float[] getSubset(float[] fullData, Region3i fullRegion, Region3i subRegion) {
        if (subRegion.size().x != fullRegion.size().x || subRegion.size().y != fullRegion.size().y || subRegion.size().z != fullRegion.size().z) {
            float[] result = new float[subRegion.size().x * subRegion.size().y * subRegion.size().z];
            Vector3i offset = new Vector3i(subRegion.minX() - fullRegion.minX(), subRegion.minY() - fullRegion.minY(), subRegion.minZ() - fullRegion.minZ());
            for (int z = 0; z < subRegion.size().z; ++z) {
                for (int y = 0; y < subRegion.size().y; ++y) {
                    System.arraycopy(fullData, offset.x + fullRegion.sizeX() * (y + offset.y + fullRegion.sizeY() * (z + offset.z)),
                            result, subRegion.sizeX() * (y + subRegion.sizeY() * z), subRegion.size().x);
                }
View Full Code Here

        int newMinY = region.minY() - IntMath.mod(region.minY(), sampleRate);
        int newMinZ = region.minZ() - IntMath.mod(region.minZ(), sampleRate);
        int newMaxX = region.maxX() + 4 - IntMath.mod(region.maxX(), sampleRate) - 1;
        int newMaxY = region.maxY() + 4 - IntMath.mod(region.maxY(), sampleRate) - 1;
        int newMaxZ = region.maxZ() + 4 - IntMath.mod(region.maxZ(), sampleRate) - 1;
        return Region3i.createFromMinMax(new Vector3i(newMinX, newMinY, newMinZ), new Vector3i(newMaxX, newMaxY, newMaxZ));
    }
View Full Code Here

        EVENT_BUS.post(event);
    }

    private static synchronized ChunkMonitorEntry registerChunk(Chunk chunk) {
        Preconditions.checkNotNull(chunk, "The parameter 'chunk' must not be null");
        final Vector3i pos = chunk.getPosition();
        ChunkMonitorEntry entry = CHUNKS.get(pos);
        if (entry == null) {
            entry = new ChunkMonitorEntry(pos);
            CHUNKS.put(pos, entry);
        }
View Full Code Here

        for (NetData.BlockChangeMessage blockChange : message.getBlockChangeList()) {
            Block newBlock = blockManager.getBlock((short) blockChange.getNewBlock());
            logger.debug("Received block change to {}", newBlock);
            // TODO: Store changes to blocks that aren't ready to be modified (the surrounding chunks aren't available)
            WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
            Vector3i pos = NetMessageUtil.convert(blockChange.getPos());
            if (worldProvider.isBlockRelevant(pos)) {
                worldProvider.setBlock(pos, newBlock);
            } else {
                awaitingChunkReadyBlockUpdates.put(TeraMath.calcChunkPos(pos), blockChange);
            }
View Full Code Here

TOP

Related Classes of org.terasology.math.Vector3i

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.