當前位置: 首頁>>代碼示例>>Java>>正文


Java GL2.glLightfv方法代碼示例

本文整理匯總了Java中javax.media.opengl.GL2.glLightfv方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glLightfv方法的具體用法?Java GL2.glLightfv怎麽用?Java GL2.glLightfv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glLightfv方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: useCamera

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param openGl
 */
public void useCamera(final GL2 openGl) {
    if (resetProjection) {
        resetProjection = false;
        setProjection(openGl);
    }

    openGl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, new float[]{1000.f,1000.f,1000.f}, 0);
    openGl.glEnable(GL2.GL_LIGHT0);

    openGl.glMatrixMode(GL2.GL_MODELVIEW);
    openGl.glLoadIdentity();
    position.translateBy(openGl);
    product.rotateAround(openGl);
    upVector.rotateAround(openGl);
    
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:21,代碼來源:Camera.java

示例2: setLights

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setLights(GL2 gl) {

		// prepare light parameters
		float SHINE_ALL_DIRECTIONS = 1;
		float[] lightPos = { -40, 0, 20, SHINE_ALL_DIRECTIONS };

		// 'weak' light which is everywhere
		float[] lightColorAmbient = { 0.2f, 0.2f, 0.2f, 1f };

		// 'strong' light from a particular spot which creates a 3d-effect
		float[] lightColorSpecular = { 0.8f, 0.8f, 0.8f, 1f };

		// set light parameters
		gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_POSITION, lightPos, 0);
		gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_AMBIENT, lightColorAmbient, 0);
		gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_SPECULAR, lightColorSpecular, 0);

		// enable lights
		gl.glEnable(GL2.GL_LIGHT1);
		gl.glEnable(GL2.GL_LIGHTING);
	}
 
開發者ID:johb,項目名稱:GAIA,代碼行數:22,代碼來源:Mode3D.java

示例3: initialize

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Called during openGL initialisation. This enables the necessary settings
 * and sets up the light source.
 *
 * @param gl The GL2 instance responsible for drawing the scene.
 * @param gs The GlobalState.
 */
public void initialize(GL2 gl, GlobalState gs) {
    gl.glEnable(GL_LIGHTING);
    gl.glEnable(GL_LIGHT0);
    calculatePosition(gs);
    gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPos, 0);
    gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight, 0);
    gl.glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight, 0);
    gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight, 0);
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:17,代碼來源:Lighting.java

示例4: setupLighting

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void setupLighting(GLAutoDrawable drawable, GL2 gl) {
	int paramsOffset = 0;
	float pos[] = { 2.0f, -2.0f, 10.0f, 0.0f };
	float ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
	float diffuse[] = {0.9f, 0.9f, 0.9f, 1.0f};
	float specular[] = {0.05f, 0.05f, 0.99f, 1.0f};

	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
	gl.glEnable(GL2.GL_LIGHTING);
	gl.glEnable(GL2.GL_LIGHT0);
	gl.glEnable(GL2.GL_DEPTH_TEST);
	gl.glEnable(GL2.GL_AUTO_NORMAL);
	gl.glEnable(GL2.GL_NORMALIZE);

	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, paramsOffset);
	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, paramsOffset);
	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specular, paramsOffset);
	gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, paramsOffset);
	gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL2.GL_TRUE);

	gl.glClearColor(1f, 1f, 1f, 1f);
	gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
	gl.glMatrixMode(GL2.GL_MODELVIEW);
	gl.glLoadIdentity();
	gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
	gl.glMatrixMode(GL2.GL_PROJECTION);
	gl.glLoadIdentity();
	if (gl instanceof GLLightingFunc) {
		((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT_AND_DIFFUSE, blue, 0);
		((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, white, 0);
		float[] medHiShiny = new float[] {80.0f};
		((GLLightingFunc) gl).glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, medHiShiny, 0);
		((GLLightingFunc) gl).glShadeModel(GLLightingFunc.GL_FLAT);
	}
}
 
開發者ID:akmaier,項目名稱:CONRAD,代碼行數:36,代碼來源:SurfaceTest.java

示例5: display

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 *
 * @see javax.media.opengl.GLEventListener#display(javax.media.opengl.GLAutoDrawable)
 */
@Override
public void display( final GLAutoDrawable drawable )
{
	this.updateVis();

	final GL2 gl = drawable.getGL().getGL2();
	gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
	gl.glLoadIdentity();

	if( this.cameraPosition != null )
	{
		final float[] pos = this.cameraPosition.getCameraPosition();
		this.glu.gluLookAt( pos[0], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6], pos[7], pos[8] );
	}

       // Prepare light parameters.
	if( this.enableLights )
	{
        final float SHINE_ALL_DIRECTIONS = 1;
        final float[] lightPos = {-30, 0, 0, SHINE_ALL_DIRECTIONS};
        final float[] lightColorAmbient = {0.2f, 0.2f, 0.2f, 1f};
        final float[] lightColorSpecular = {0.5f, 0.5f, 0.5f, 1f};

        // Set light parameters.
        gl.glLightfv( GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_POSITION, lightPos, 0 );
        gl.glLightfv( GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_AMBIENT, lightColorAmbient, 0 );
        gl.glLightfv( GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_SPECULAR, lightColorSpecular, 0 );

        // Enable lighting in GL.
        gl.glEnable( GLLightingFunc.GL_LIGHT1 );
        gl.glEnable( GLLightingFunc.GL_LIGHTING );
	}

	gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );

	this.renderVis( drawable );
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:43,代碼來源:Visualisation3D.java

示例6: setView

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Called during the setView part of the loop. Reset the position of the
 * light source here, otherwise it will move with the camera.
 *
 * @param gl The GL2 instance responsible for drawing the scene.
 */
public void setView(GL2 gl) {
    gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPos, 0);
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:10,代碼來源:Lighting.java


注:本文中的javax.media.opengl.GL2.glLightfv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。