Examples of Vector3i


Examples of org.terasology.math.Vector3i

        for (EntityData.EntityStoreMetadata metadataData : globalStore.getStoreReferenceSetList()) {
            TIntSet refs = new TIntHashSet(metadataData.getReferenceList());
            StoreId id;
            switch (metadataData.getType()) {
                case ChunkStoreType:
                    id = new ChunkStoreId(new Vector3i(metadataData.getStoreIntegerId(0), metadataData.getStoreIntegerId(1), metadataData.getStoreIntegerId(2)));
                    break;
                default:
                    id = new PlayerStoreId(metadataData.getStoreStringId());
                    break;
View Full Code Here

Examples of org.terasology.math.Vector3i

    public void onFootstep(FootstepEvent event, EntityRef entity, LocationComponent locationComponent, CharacterSoundComponent characterSounds) {

        List<StaticSound> footstepSounds = characterSounds.footstepSounds;

        // Check if the block the character is standing on has footstep sounds
        Vector3i blockPos = new Vector3i(locationComponent.getLocalPosition());
        blockPos.y--; // The block *below* the character's feet is interesting to us
        Block block = worldProvider.getBlock(blockPos);
        if (block != null && !block.getSounds().getStepSounds().isEmpty()) {
            footstepSounds = block.getSounds().getStepSounds();
        }
View Full Code Here

Examples of org.terasology.math.Vector3i

        }

        // Gather adjacent blocks
        Map<Side, Block> adjacentBlocks = Maps.newEnumMap(Side.class);
        for (Side side : Side.values()) {
            Vector3i offset = side.getVector3i();
            Block blockToCheck = view.getBlock(x + offset.x, y + offset.y, z + offset.z);
            adjacentBlocks.put(side, blockToCheck);
        }

        BlockAppearance blockAppearance = block.getAppearance(adjacentBlocks);

        /*
         * Determine the render process.
         */
        ChunkMesh.RenderType renderType = ChunkMesh.RenderType.TRANSLUCENT;

        if (!block.isTranslucent()) {
            renderType = ChunkMesh.RenderType.OPAQUE;
        }
        // TODO: Review special case, or alternatively compare uris.
        if (block.isWater() || block.isIce()) {
            renderType = ChunkMesh.RenderType.WATER_AND_ICE;
        }
        if (block.isDoubleSided()) {
            renderType = ChunkMesh.RenderType.BILLBOARD;
        }

        if (blockAppearance.getPart(BlockPart.CENTER) != null) {
            Vector4f colorOffset = block.calcColorOffsetFor(BlockPart.CENTER, biome);
            blockAppearance.getPart(BlockPart.CENTER).appendTo(mesh, x, y, z, colorOffset, renderType, vertexFlag);
        }

        boolean[] drawDir = new boolean[6];

        for (Side side : Side.values()) {
            drawDir[side.ordinal()] = blockAppearance.getPart(BlockPart.fromSide(side)) != null && isSideVisibleForBlockTypes(adjacentBlocks.get(side), block, side);
        }

        // If the block is lowered, some more faces may have to be drawn
        if (block.isLiquid()) {
            Block bottomBlock = adjacentBlocks.get(Side.BOTTOM);
            // Draw horizontal sides if visible from below
            for (Side side : Side.horizontalSides()) {
                Vector3i offset = side.getVector3i();
                Block adjacentBelow = view.getBlock(x + offset.x, y - 1, z + offset.z);
                Block adjacent = adjacentBlocks.get(side);

                boolean visible = (blockAppearance.getPart(BlockPart.fromSide(side)) != null
                        && isSideVisibleForBlockTypes(adjacentBelow, block, side) && !isSideVisibleForBlockTypes(bottomBlock, adjacent, side.reverse()));
View Full Code Here

Examples of org.terasology.math.Vector3i

        for (Vector3i pos : border.expandTo3D(region.getRegion())) {
            chunkCoordinates.add(TeraMath.calcChunkPos(pos));
        }

        for (Vector3i chunkCoordinate : chunkCoordinates) {
            Vector3i minWorldPosForChunk = new Vector3i(ChunkConstants.SIZE_X * chunkCoordinate.x,
                    ChunkConstants.SIZE_Y * chunkCoordinate.y,
                    ChunkConstants.SIZE_Z * chunkCoordinate.z);
            Region3i chunkWorldRegion = Region3i.createFromMinAndSize(minWorldPosForChunk, ChunkConstants.CHUNK_SIZE);

            int hmX = (((chunkWorldRegion.minX() / chunkWorldRegion.sizeX()) % 512) + 512) % 512;
            int hmZ = (((chunkWorldRegion.minZ() / chunkWorldRegion.sizeZ()) % 512) + 512) % 512;

            double scaleFactor = 0.05 * MAX_HEIGHT;

            double p00 = heightmap[hmX][hmZ] * scaleFactor;
            double p10 = heightmap[(hmX - 1 + 512) % 512][(hmZ) % 512] * scaleFactor;
            double p11 = heightmap[(hmX - 1 + 512) % 512][(hmZ + 1 + 512) % 512] * scaleFactor;
            double p01 = heightmap[(hmX) % 512][(hmZ + 1 + 512) % 512] * scaleFactor;

            Rect2i worldRegion = Rect2i.createFromMinAndSize(chunkWorldRegion.minX(),
                    chunkWorldRegion.minZ(),
                    chunkWorldRegion.sizeX(),
                    chunkWorldRegion.sizeZ());

            for (Vector2i pos : worldRegion) {
                Vector3i localPos = TeraMath.calcBlockPos(new Vector3i(pos.x, 0, pos.y));
                int x = localPos.x;
                int z = localPos.z;
                //calculate avg height
                float interpolatedHeight = (float) lerp(x / (double) ChunkConstants.CHUNK_REGION.sizeX(), lerp(z / (double) ChunkConstants.CHUNK_REGION.sizeZ(), p10, p11),
                        lerp(z / (double) ChunkConstants.CHUNK_REGION.sizeZ(), p00, p01));
View Full Code Here

Examples of org.terasology.math.Vector3i

                        for (int i = 0; i < elements.length; ++i) {
                            String[] parts = elements[i].split("/", 4);
                            if (parts.length > 3) {
                                throw new IOException("Bad Statement");
                            }
                            result[i] = new Vector3i(Integer.parseInt(parts[0]), -1, -1);
                            if (parts.length > 1 && !parts[1].isEmpty()) {
                                result[i].y = Integer.parseInt(parts[1]);
                            }
                            if (parts.length > 2 && !parts[2].isEmpty()) {
                                result[i].z = Integer.parseInt(parts[2]);
View Full Code Here

Examples of org.terasology.math.Vector3i

        public final Vector3i pos;

        public EntryEvent(ChunkMonitorDisplay display, Vector3i pos, ChunkMonitorEntry entry) {
            super(display);
            this.entry = entry;
            this.pos = pos == null ? null : new Vector3i(pos);
        }
View Full Code Here

Examples of org.terasology.math.Vector3i

        EntityBuilder builder = entityManager.newBuilder("engine:smokeExplosion");
        builder.getComponent(LocationComponent.class).setWorldPosition(origin);
        builder.build();

        Vector3i blockPos = new Vector3i();
        for (int i = 0; i < 64; i++) {
            Vector3f direction = random.nextVector3f(1.0f);
            Vector3f impulse = new Vector3f(direction);
            impulse.scale(150);

            for (int j = 0; j < 4; j++) {
                Vector3f target = new Vector3f(origin);

                target.x += direction.x * j;
                target.y += direction.y * j;
                target.z += direction.z * j;
                blockPos.set((int) target.x, (int) target.y, (int) target.z);
                Block currentBlock = worldProvider.getBlock(blockPos);

                /* PHYSICS */
                if (currentBlock.isDestructible()) {
                    blockEntityRegistry.getEntityAt(blockPos).send(new DoDamageEvent(1000, EngineDamageTypes.EXPLOSIVE.get()));
View Full Code Here

Examples of org.terasology.math.Vector3i

        this.y = y;
        this.z = z;
    }

    public ImmutableBlockLocation move(Side side) {
        final Vector3i directionVector = side.getVector3i();
        return new ImmutableBlockLocation(x+directionVector.x, y+directionVector.y, z+directionVector.z);
    }
View Full Code Here

Examples of org.terasology.math.Vector3i

        final Vector3i directionVector = side.getVector3i();
        return new ImmutableBlockLocation(x+directionVector.x, y+directionVector.y, z+directionVector.z);
    }

    public Vector3i toVector3i() {
        return new Vector3i(x, y, z);
    }
View Full Code Here

Examples of org.terasology.math.Vector3i

        Vector3f dir = new Vector3f(event.getDirection());
        dir.scale(4.0f);
        Vector3f origin = new Vector3f(event.getOrigin());
        origin.add(dir);
        Vector3i blockPos = new Vector3i();

        int particleEffects = 0;
        int blockCounter = MAX_DESTROYED_BLOCKS;
        for (int s = 0; s <= 512; s++) {
            origin.add(dir);
            if (!worldProvider.isBlockRelevant(origin)) {
                break;
            }

            for (int i = 0; i < 64; i++) {
                Vector3f direction = random.nextVector3f(1.0f);
                Vector3f impulse = new Vector3f(direction);
                impulse.scale(200);

                for (int j = 0; j < 3; j++) {
                    Vector3f target = new Vector3f(origin);

                    target.x += direction.x * j;
                    target.y += direction.y * j;
                    target.z += direction.z * j;

                    blockPos.set((int) target.x, (int) target.y, (int) target.z);

                    Block currentBlock = worldProvider.getBlock(blockPos);

                    if (currentBlock.isDestructible()) {
                        if (particleEffects < MAX_PARTICLE_EFFECTS) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.