use of org.joml.Vector3f in project Terasology by MovingBlocks.
the class PlayerTargetSystem method update.
@Override
public void update(float delta) {
EntityRef charEntity = player.getCharacterEntity();
if (charEntity.exists()) {
Vector3f cameraPos = player.getViewPosition(new Vector3f());
CharacterComponent charComp = charEntity.getComponent(CharacterComponent.class);
if (charComp != null) {
Vector3f dir = player.getViewDirection(new Vector3f());
float maxDist = charComp.interactionRange;
FirstPersonHeldItemMountPointComponent heldItemMountPoint = player.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
if (heldItemMountPoint != null && heldItemMountPoint.isTracked()) {
maxDist = heldItemMountPoint.translate.length() + 0.25f;
dir = new Vector3f(heldItemMountPoint.translate).normalize();
}
if (targetSystem.updateTarget(cameraPos, dir, maxDist)) {
EntityRef oldTarget = targetSystem.getPreviousTarget();
EntityRef newTarget = targetSystem.getTarget();
charEntity.send(new PlayerTargetChangedEvent(oldTarget, newTarget));
}
}
}
}
use of org.joml.Vector3f in project Terasology by MovingBlocks.
the class SpriteParticleRenderer method renderAlphaBlend.
@Override
public void renderAlphaBlend() {
if (!opengl33) {
return;
}
PerspectiveCamera camera = (PerspectiveCamera) worldRenderer.getActiveCamera();
Vector3f cameraPosition = camera.getPosition();
Matrix4f viewProjection = new Matrix4f(camera.getViewProjectionMatrix()).translate(-cameraPosition.x, -cameraPosition.y, -cameraPosition.z);
Material material = Assets.getMaterial(PARTICLE_MATERIAL_URI).get();
material.enable();
material.setFloat3("camera_position", cameraPosition.x, cameraPosition.y, cameraPosition.z);
material.setMatrix4("view_projection", viewProjection.get(matrixBuffer));
particleSystemManager.getParticleEmittersByDataComponent(ParticleDataSpriteComponent.class).forEach(particleSystem -> drawParticles(material, particleSystem));
}
use of org.joml.Vector3f in project Terasology by MovingBlocks.
the class AbstractStorageManager method getEntitiesOfChunk.
protected Collection<EntityRef> getEntitiesOfChunk(Chunk chunk) {
List<EntityRef> entitiesToStore = Lists.newArrayList();
AABBfc 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) {
continue;
}
Vector3f pos = loc.getWorldPosition(new Vector3f());
if (pos.isFinite()) {
if (aabb.containsPoint(loc.getWorldPosition(new Vector3f()))) {
entitiesToStore.add(entity);
}
}
}
}
return entitiesToStore;
}
use of org.joml.Vector3f in project Terasology by MovingBlocks.
the class ScaleRangeGeneratorComponent method copyFrom.
@Override
public void copyFrom(ScaleRangeGeneratorComponent other) {
this.minScale = new Vector3f(other.minScale);
this.maxScale = new Vector3f(other.maxScale);
}
use of org.joml.Vector3f in project Terasology by MovingBlocks.
the class PositionRangeGeneratorComponent method copyFrom.
@Override
public void copyFrom(PositionRangeGeneratorComponent other) {
this.minPosition = new Vector3f(other.minPosition);
this.maxPosition = new Vector3f(other.maxPosition);
}
Aggregations