Search in sources :

Example 6 with Light

use of maspack.render.Light in project artisynth_core by artisynth.

the class GLViewer method setDefaultLights.

public void setDefaultLights() {
    // // For debugging lights, set to R-G-B
    // float light0_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    // float light0_diffuse[] = { 0.8f, 0.0f, 0.0f, 1.0f };
    // float light0_specular[] = { 0, 0, 0, 1 };
    // float light0_position[] = { 1, 0, 0, 0 };
    // 
    // float light1_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
    // float light1_diffuse[] = { 0.0f, 0.8f, 0.0f, 1.0f };
    // float light1_specular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
    // float light1_position[] = { 0, 1, 0, 0 };
    // 
    // float light2_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
    // float light2_diffuse[] = { 0.0f, 0.0f, 0.8f, 1.0f };
    // float light2_specular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
    // float light2_position[] = { 0, 0, 1, 0 };
    float[] light0_ambient = { 0.1f, 0.1f, 0.1f, 1f };
    float[] light0_diffuse = { 0.8f, 0.8f, 0.8f, 1.0f };
    float[] light0_specular = { 0.5f, 0.5f, 0.5f, 1.0f };
    float[] light0_position = { -0.8660254f, 0.5f, 1f, 0f };
    float[] light1_ambient = { 0.0f, 0.0f, 0.0f, 1.0f };
    float[] light1_diffuse = { 0.5f, 0.5f, 0.5f, 1.0f };
    float[] light1_specular = { 0.5f, 0.5f, 0.5f, 1.0f };
    float[] light1_position = { 0.8660254f, 0.5f, 1f, 0f };
    float[] light2_ambient = { 0.0f, 0.0f, 0.0f, 1.0f };
    float[] light2_diffuse = { 0.5f, 0.5f, 0.5f, 1.0f };
    float[] light2_specular = { 0.5f, 0.5f, 0.5f, 1.0f };
    float[] light2_position = { 0f, -10f, 1f, 0f };
    lightManager.clearLights();
    lightManager.addLight(new Light(light0_position, light0_ambient, light0_diffuse, light0_specular));
    lightManager.addLight(new Light(light1_position, light1_ambient, light1_diffuse, light1_specular));
    lightManager.addLight(new Light(light2_position, light2_ambient, light2_diffuse, light2_specular));
    lightManager.setMaxIntensity(1.0f);
    myProgramInfo.setNumLights(lightManager.numLights());
}
Also used : Light(maspack.render.Light)

Example 7 with Light

use of maspack.render.Light in project artisynth_core by artisynth.

the class GLViewer method addLight.

public Light addLight(float[] position, float[] ambient, float[] diffuse, float[] specular) {
    Light light = new Light(position, ambient, diffuse, specular);
    lightManager.addLight(light);
    myProgramInfo.setNumLights(lightManager.numLights());
    return light;
}
Also used : Light(maspack.render.Light)

Example 8 with Light

use of maspack.render.Light in project artisynth_core by artisynth.

the class SpecularTest method attach.

@Override
public void attach(DriverInterface driver) {
    super.attach(driver);
    GLViewer viewer = driver.getViewer();
    for (int i = viewer.numLights(); i-- > 0; ) {
        viewer.removeLight(i);
    }
    Light light = new Light();
    light.setAmbient(0, 0, 0, 0);
    light.setDiffuse(0, 0, 0, 0);
    light.setSpecular(1, 1, 1, 1);
    light.setPosition(0, 0, 1);
    light.setDirection(0, 0, -1);
    light.setType(LightType.POINT);
    viewer.addLight(light);
    LightComponent lc = new LightComponent(light);
    ComponentList<LightComponent> lights = new ComponentList<>(LightComponent.class, "lights");
    lights.add(lc);
    add(lights);
}
Also used : GLViewer(maspack.render.GL.GLViewer) Light(maspack.render.Light) LightComponent(artisynth.core.renderables.LightComponent) ComponentList(artisynth.core.modelbase.ComponentList)

Aggregations

Light (maspack.render.Light)8 ComponentList (artisynth.core.modelbase.ComponentList)1 LightComponent (artisynth.core.renderables.LightComponent)1 Point (java.awt.Point)1 ByteBuffer (java.nio.ByteBuffer)1 Point3d (maspack.matrix.Point3d)1 Vector3d (maspack.matrix.Vector3d)1 GLViewer (maspack.render.GL.GLViewer)1