use of org.rajawali3d.lights.PointLight in project Rajawali by Rajawali.
the class LoaderFBX method buildLight.
private ALight buildLight(Model l) {
int m = l.properties.lightType != null ? l.properties.lightType : ALight.POINT_LIGHT;
switch(m) {
case //Point
ALight.POINT_LIGHT:
PointLight light = new PointLight();
light.setPosition(l.properties.lclTranslation);
light.setX(light.getX() * -1f);
light.setRotation(l.properties.lclRotation);
light.setPower(l.properties.intensity / 100f);
light.setColor(l.properties.color);
//mRootObject.addLight(light);
return light;
case //Area
ALight.DIRECTIONAL_LIGHT:
//TODO calculate direction based on position and rotation
DirectionalLight lD = new DirectionalLight();
lD.setPosition(l.properties.lclTranslation);
lD.setX(lD.getX() * -1f);
lD.setRotation(l.properties.lclRotation);
lD.setPower(l.properties.intensity / 100f);
lD.setColor(l.properties.color);
//mRootObject.addLight(lD);
return lD;
default:
case //Spot
ALight.SPOT_LIGHT:
//TODO calculate direction based on position and rotation
SpotLight lS = new SpotLight();
lS.setPosition(l.properties.lclTranslation);
lS.setX(lS.getX() * -1f);
lS.setRotation(l.properties.lclRotation);
lS.setPower(l.properties.intensity / 100f);
lS.setCutoffAngle(l.properties.coneangle);
lS.setColor(l.properties.color);
lS.setLookAt(0, 0, 0);
//mRootObject.addLight(lS);
return lS;
}
}
use of org.rajawali3d.lights.PointLight in project Rajawali by Rajawali.
the class LightsVertexShaderFragment method applyParams.
@Override
public void applyParams() {
super.applyParams();
int lightCount = mLights.size();
int dirCount = 0, spotCount = 0, attCount = 0;
for (int i = 0; i < lightCount; i++) {
ALight light = mLights.get(i);
int t = light.getLightType();
GLES20.glUniform3fv(muLightColorHandles[i], 1, light.getColor(), 0);
GLES20.glUniform1f(muLightPowerHandles[i], light.getPower());
GLES20.glUniform3fv(muLightPositionHandles[i], 1, ArrayUtils.convertDoublesToFloats(light.getPositionArray(), mTemp3Floats), 0);
if (t == ALight.SPOT_LIGHT) {
SpotLight l = (SpotLight) light;
GLES20.glUniform3fv(muLightDirectionHandles[spotCount], 1, ArrayUtils.convertDoublesToFloats(l.getDirection(), mTemp3Floats), 0);
GLES20.glUniform4fv(muLightAttenuationHandles[attCount], 1, l.getAttenuation(), 0);
//GLES20.glUniform1f(muSpotExponentHandles[spotCount], l.get)
GLES20.glUniform1f(muSpotCutoffAngleHandles[spotCount], l.getCutoffAngle());
GLES20.glUniform1f(muSpotFalloffHandles[spotCount], l.getFalloff());
spotCount++;
dirCount++;
attCount++;
} else if (t == ALight.POINT_LIGHT) {
PointLight l = (PointLight) light;
GLES20.glUniform4fv(muLightAttenuationHandles[attCount], 1, l.getAttenuation(), 0);
attCount++;
} else if (t == ALight.DIRECTIONAL_LIGHT) {
DirectionalLight l = (DirectionalLight) light;
GLES20.glUniform3fv(muLightDirectionHandles[dirCount], 1, ArrayUtils.convertDoublesToFloats(l.getDirection(), mTemp3Floats), 0);
dirCount++;
}
}
GLES20.glUniform3fv(muAmbientColorHandle, 1, mAmbientColor, 0);
GLES20.glUniform3fv(muAmbientIntensityHandle, 1, mAmbientIntensity, 0);
}
Aggregations