package electrosphere.renderer.light;

import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityCreationUtils;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityTags;

import org.joml.Vector3d;
import org.joml.Vector3f;

/**
 * Utility functions for dealing with entities that create light
 */
public class LightEntityUtils {

    public static Entity createDirectionalLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular){
        Entity rVal = EntityCreationUtils.createClientSpatialEntity();
        Globals.clientScene.registerEntityToTag(rVal, EntityTags.LIGHT);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_DIRECTIONAL);
        rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_DIFFUSE, diffuse);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_SPECULAR, specular);
        return rVal;
    }

    public static Entity createPointLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular, float constant, float linear, float quadratic){
        Entity rVal = EntityCreationUtils.createClientSpatialEntity();
        Globals.clientScene.registerEntityToTag(rVal, EntityTags.LIGHT);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_POINT);
        rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_DIFFUSE, diffuse);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_SPECULAR, specular);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_CONSTANT, constant);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_LINEAR, linear);
        rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_QUADRATIC, quadratic);
        return rVal;
    }

}