Package org.terasology.logic.location

Examples of org.terasology.logic.location.LocationComponent


    }

    @ReceiveEvent(components = {LocationComponent.class})
    public void onEndSelectionAtEntity(SetBlockSelectionEndingPointEvent event, EntityRef entity) {

        LocationComponent locationComponent = entity.getComponent(LocationComponent.class);
        if (null == locationComponent) {
            // entity isn't LocationComponent, which shouldn't ever be the case
            return;
        }

        BlockSelectionComponent blockSelectionComponent = event.getBlockSelectionComponent();
        if (null == blockSelectionComponent) {
            // event did not provide a BlockSelection component to modify
            return;
        }

        Vector3f worldPosition = locationComponent.getWorldPosition();

        Vector3i endPosition = new Vector3i(worldPosition.x, worldPosition.y, worldPosition.z);
        Vector3i startPosition = blockSelectionComponent.startPosition;
        if (null == startPosition) {
            startPosition = endPosition;
View Full Code Here


        Material program = Assets.getMaterial("engine:prog.simple");
        program.enable();
        program.setCamera(camera);
        EntityManager entityManager = CoreRegistry.get(EntityManager.class);
        for (EntityRef entity : entityManager.getEntitiesWith(LightComponent.class, LocationComponent.class)) {
            LocationComponent locationComponent = entity.getComponent(LocationComponent.class);
            LightComponent lightComponent = entity.getComponent(LightComponent.class);

            final Vector3f worldPosition = locationComponent.getWorldPosition();
            renderLightComponent(lightComponent, worldPosition, program, camera, true);
        }
        DefaultRenderingProcess.getInstance().endRenderLightGeometryStencilPass();

        /*
         * LIGHT GEOMETRY PASS
         */
        DefaultRenderingProcess.getInstance().beginRenderLightGeometry();
        program = Assets.getMaterial("engine:prog.lightGeometryPass");
        for (EntityRef entity : entityManager.getEntitiesWith(LightComponent.class, LocationComponent.class)) {
            LocationComponent locationComponent = entity.getComponent(LocationComponent.class);
            LightComponent lightComponent = entity.getComponent(LightComponent.class);

            final Vector3f worldPosition = locationComponent.getWorldPosition();
            renderLightComponent(lightComponent, worldPosition, program, camera, false);
        }
        DefaultRenderingProcess.getInstance().endRenderLightGeometry();
        DefaultRenderingProcess.getInstance().beginRenderDirectionalLights();

View Full Code Here

        Vector3f cameraPosition = worldRenderer.getActiveCamera().getPosition();

        for (EntityRef entity : entityRefs) {
            MeshComponent meshComp = entity.getComponent(MeshComponent.class);
            meshComp.material.enable();
            LocationComponent location = entity.getComponent(LocationComponent.class);
            if (location == null) {
                continue;
            }

            Quat4f worldRot = location.getWorldRotation();
            Vector3f worldPos = location.getWorldPosition();
            float worldScale = location.getWorldScale();
            AABB aabb = meshComp.mesh.getAABB().transform(worldRot, worldPos, worldScale);
            if (worldRenderer.isAABBVisible(aabb)) {
                glPushMatrix();

                glTranslated(worldPos.x - cameraPosition.x, worldPos.y - cameraPosition.y, worldPos.z - cameraPosition.z);
View Full Code Here

            Set<EntityRef> entities = meshByMaterial.get(material);
            lastRendered = entities.size();
            for (EntityRef entity : entities) {
                MeshComponent meshComp = entity.getComponent(MeshComponent.class);
                LocationComponent location = entity.getComponent(LocationComponent.class);

                if (location == null || meshComp.mesh == null || !worldProvider.isBlockRelevant(location.getWorldPosition())) {
                    continue;
                }
                if (meshComp.mesh.isDisposed()) {
                    logger.error("Attempted to render disposed mesh");
                    continue;
                }

                location.getWorldRotation(worldRot);
                location.getWorldPosition(worldPos);
                float worldScale = location.getWorldScale();

                matrixWorldSpace.set(worldRot, worldPos, worldScale);
                transWorldSpace.set(matrixWorldSpace);

                Vector3f worldPositionCameraSpace = new Vector3f();
View Full Code Here

    public ChunkRelevanceRegion(EntityRef entity, Vector3i relevanceDistance) {
        this.entity = entity;
        this.relevanceDistance.set(relevanceDistance);

        LocationComponent loc = entity.getComponent(LocationComponent.class);
        if (loc == null) {
            dirty = false;
        } else {
            center.set(TeraMath.calcChunkPos(loc.getWorldPosition()));
            currentRegion = calculateRegion();
            dirty = true;
        }
    }
View Full Code Here

            }
        }
    }

    private Region3i calculateRegion() {
        LocationComponent loc = entity.getComponent(LocationComponent.class);
        if (loc != null) {
            Vector3i extents = new Vector3i(relevanceDistance.x / 2, relevanceDistance.y / 2, relevanceDistance.z / 2);
            return Region3i.createFromCenterExtents(TeraMath.calcChunkPos(loc.getWorldPosition()), extents);
        }
        return Region3i.EMPTY;
    }
View Full Code Here

        }
        return Region3i.EMPTY;
    }

    private Vector3i calculateCenter() {
        LocationComponent loc = entity.getComponent(LocationComponent.class);
        if (loc != null) {
            return TeraMath.calcChunkPos(loc.getWorldPosition());
        }
        return new Vector3i();
    }
View Full Code Here

TOP

Related Classes of org.terasology.logic.location.LocationComponent

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.