< Zurück | Inhalt | Weiter >

From AwtRenderingEngine.java


private int computeIntensity( GeometryArray geometryArray, int index, int numPoints )

{


int intensity = 0;


if ( computeIntensity != false )


{

// if we have a normal vector, compute the intensity


// under the lighting


if ( (geometryArray.getVertexFormat( ) GeometryArray.NORMALS) == GeometryArray.NORMALS )

{


double cos_theta; double cos_alpha; double cos_beta;


for( int n = 0; n <numPoints; n++ ) geometryArray.getNormal( index+n, normalsArray[n] );


// take the average normal vector


averageVector( surf_norm, normalsArray, numPoints ); temp.set( view );

temp.scale( 1.0f, surf_norm );


cos_beta = temp.x + temp.y + temp.z;


if ( cos_beta > 0.0 )


{


cos_theta = surf_norm.dot( light );


if ( cos_theta <= 0.0 )


{


intensity = (int) (lightMax * lightAmbient);


}


else


{


temp.set( surf_norm ); temp.scale( (float) cos_theta );

temp.normalize( ); temp.sub( light ); temp.normalize( );


cos_alpha = view.dot( temp );


intensity = (int) (lightMax * ( lightAmbient + lightDiffuse * cos_theta + lightSpecular * Math.pow( cos_alpha, lightGlossiness )));

}


}


}


}


return intensity;


}


image