void ElevatorSimRenderWindow::glInit() {
      /* if GlInit is called while valid() returns true, drop a breakpoint */
      assert(!valid());

      glEnable(GL_TEXTURE_2D);

      glShadeModel(GL_SMOOTH);
      glEnable(GL_DEPTH_TEST);
      glDepthFunc(GL_LEQUAL);
      glDepthMask(GL_TRUE);

      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180);

      glLightfv(GL_LIGHT0, GL_AMBIENT, light1_ambient);
      glLightfv(GL_LIGHT0, GL_DIFFUSE, light1_diffuse);
      glLightfv(GL_LIGHT0, GL_SPECULAR, light1_specular);
      glLightfv(GL_LIGHT0, GL_POSITION, light1_position);
      glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light1_direction);
   }
Esempio n. 2
0
void lights(){

    GLfloat light_position1[] = {50, 50, 0, 1};
    GLfloat light1[] = {0.5, 0.5, 0.5, 1};
    GLfloat light2[] = {0.5, 0.5, .5, 1.0};
    GLfloat zero[] = {0, 0, 0 , 0};

    // setup
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);

    glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 25);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light2);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light1);
    glLightfv(GL_LIGHT0, GL_AMBIENT, light2);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position1);


}
Esempio n. 3
0
//light
void setOnTheLight() {
    GLfloat light_ambient[] = {1.0, 1.0, 1.0, 1.0};
    GLfloat light_diffuse[] = {0.8, 0.8, 0.8, 1.0};

    //Position of the light
    light0_position[0] = 0.0;
    light0_position[1] = 1.0;
    light0_position[2] = 1.0;
    light0_position[3] = 1.0;

    light1_position[0] = 0.0;
    light1_position[1] = -2.0;
    light1_position[2] = -12.0;

    light2_position[0] = 0.0;
    light2_position[1] = -2.0;
    light2_position[2] = -10.0;

    //Direction of the light
    light0_direction[0] = 0.0;
    light0_direction[1] = -0.2;
    light0_direction[2] = -6.0;

    glLoadIdentity();
    glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
    glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
    glLightfv(GL_LIGHT2, GL_POSITION, light2_position);

    glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light0_direction);
    glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 45.0);
    glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
    glLightfv(GL_LIGHT2, GL_AMBIENT, light_ambient);
    glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diffuse);

    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    glEnable(GL_LIGHT2);
    glShadeModel(GL_SMOOTH);
}
Esempio n. 4
0
// This function does any needed initialization on the rendering
// context. 
void SetupRC()
    {
    glEnable(GL_DEPTH_TEST);	// Hidden surface removal
    glFrontFace(GL_CCW);		// Counter clock-wise polygons face out
    glEnable(GL_CULL_FACE);		// Do not try to display the back sides

    // Enable lighting
    glEnable(GL_LIGHTING);

    // Setup and enable light 0
    // Supply a slight ambient light so the objects can be seen
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);
	
    // The light is composed of just a diffuse and specular components
    glLightfv(GL_LIGHT0,GL_DIFFUSE,ambientLight);
    glLightfv(GL_LIGHT0,GL_SPECULAR,specular);
    glLightfv(GL_LIGHT0,GL_POSITION,lightPos);

    // Specific spot effects
    // Cut off angle is 60 degrees
    glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,50.0f);

    // Enable this light in particular
    glEnable(GL_LIGHT0);

    // Enable color tracking
    glEnable(GL_COLOR_MATERIAL);
	
    // Set Material properties to follow glColor values
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    // All materials hereafter have full specular reflectivity
    // with a high shine
    glMaterialfv(GL_FRONT, GL_SPECULAR,specref);
    glMateriali(GL_FRONT, GL_SHININESS,128);


    // Black background
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
    }
Esempio n. 5
0
void LightEngine::drawLights()
{
	//test light source
	int count = 0;
	for each(lightParams light in lightArray)
	{
		if(light.clear == false && light.active == true)
		{
			//lighting effects? .. test
			lightArray[count].specular[0] += 0.005;
			if(lightArray[count].specular[0] > 1)
				lightArray[count].specular[0] = 0;

			lightArray[count].specular[1] += 0.005;
			if(lightArray[count].specular[1] > 1)
				lightArray[count].specular[1] = 0;

			lightArray[count].specular[2] += 0.005;
			if(lightArray[count].specular[2] > 1)
				lightArray[count].specular[2] = 0;
			//end lighting effects

			glLightfv(light.lightNumber, GL_SPECULAR, light.specular);
			glLightfv(light.lightNumber, GL_AMBIENT, light.specular);
			glLightfv(light.lightNumber, GL_DIFFUSE, light.specular);
			glLightfv(light.lightNumber, GL_POSITION, light.position);
			glLightf(light.lightNumber, GL_SPOT_CUTOFF, light.cutoff);
			glLightfv(light.lightNumber, GL_SPOT_DIRECTION, light.direction);

			glEnable(light.lightNumber);

			//For testing purposes.
			glPushMatrix();
			glTranslatef(light.position[0], light.position[1], light.position[2]);
			glutSolidSphere(1, 10, 10);
			glPopMatrix();
		}
		count++;
	}
}
void R3DirectionalLight::
Draw(int i) const
{
    // Draw light
    GLenum index = (GLenum) (GL_LIGHT0 + i);
    if (index > GL_LIGHT7) return;
    GLfloat buffer[4];
    buffer[0] = Intensity() * Color().R();
    buffer[1] = Intensity() * Color().G();
    buffer[2] = Intensity() * Color().B();
    buffer[3] = 1.0;
    glLightfv(index, GL_DIFFUSE, buffer);
    glLightfv(index, GL_SPECULAR, buffer);
    buffer[0] = -(Direction().X());
    buffer[1] = -(Direction().Y());
    buffer[2] = -(Direction().Z());
    buffer[3] = 0.0;
    glLightfv(index, GL_POSITION, buffer);
    buffer[0] = 180.0;
    glLightf(index, GL_SPOT_CUTOFF, buffer[0]);
    glEnable(index);
}
Esempio n. 7
0
// INITIALIZE OPEN GL
// **************************
void initGL(void)
{
	// Background color
	glClearColor(0.4, 0.47, 0.55, 0.0);

	glEnable(GL_DEPTH_TEST);
	glMatrixMode(GL_MODELVIEW);

	// Configure Lighting
	GLfloat LightAmbient[] = {0.9f, 0.9f, 0.9f, 1.0f};
	GLfloat LightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
	GLfloat LightSpecular[] = {0.5f, 0.5f, 0.5f, 1.0f};

	glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
	glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90.0);

	//glEnable(GL_LIGHT0);
	//glEnable(GL_LIGHTING);

	// Enable various rending attributes
	glEnable(GL_NORMALIZE);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_COLOR_MATERIAL);

	// Add specularity to all objects
	float specReflection[] = { 0.8f, 0.8f, 0.8f, 1.0f };
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specReflection);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 30.0);
	
	// Configure Appearance of POINTS
	glPointSize(2.0);

    /*glEnable(GL_POINT_SMOOTH);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
}
Esempio n. 8
0
void draw_streamlines() 
{
	#if	0	// DEL-BY-LEETEN 02/03/2012-BEGIN
		glPushAttrib(
			GL_LIGHTING_BIT |
			0
		);

		int iLighting;
		cLineRenderer._GetInteger(CLineRenderer::ENABLE_LIGHTING, &iLighting);
		if( iLighting )
		{
			static GLfloat pfLightAmbient[4] =	{0.1f, 0.1f, 0.1f, 1.0f};
			static GLfloat pfLightDiffuse[4] =	{0.6f, 0.6f, 0.6f, 1.0f};
			static GLfloat pfLightSpecular[4] =	{0.3f, 0.3f, 0.3f, 1.0f};;
			static GLfloat fSpotExponent = 4.0f;
			glLightfv(GL_LIGHT0, GL_AMBIENT,	pfLightAmbient);
			glLightfv(GL_LIGHT0, GL_DIFFUSE,	pfLightDiffuse);
			glLightfv(GL_LIGHT0, GL_SPECULAR,	pfLightSpecular);
			glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, fSpotExponent);

			glEnable(GL_LIGHTING);
			glEnable(GL_LIGHT0);

			glPushMatrix();
			glLoadIdentity();
			static GLfloat pfLightPos[4] =	{0.0f, 0.0f, 1.0f, 0.0f};
			glLightfv(GL_LIGHT0, GL_POSITION, pfLightPos);
			glPopMatrix();
		}
	#endif	// DEL-BY-LEETEN 02/03/2012-END

	cLineRenderer._Draw();

	// DEL-BY-LEETEN 02/03/2012-BEGIN
		// glPopAttrib();
	// DEL-BY-LEETEN 02/03/2012-END
}
Esempio n. 9
0
void fwglLightf (int light, int pname, GLfloat param) {
	ppRenderFuncs p = (ppRenderFuncs)gglobal()->RenderFuncs.prv;
	/*
	printf ("glLightf light: %d ",light);
	switch (pname) {
		case GL_CONSTANT_ATTENUATION: printf ("GL_CONSTANT_ATTENUATION"); break;
		case GL_LINEAR_ATTENUATION: printf ("GL_LINEAR_ATTENUATION"); break;
		case GL_QUADRATIC_ATTENUATION: printf ("GL_QUADRATIC_ATTENUATION"); break;
		case GL_SPOT_CUTOFF: printf ("GL_SPOT_CUTOFF"); break;
		case GL_SPOT_EXPONENT: printf ("GL_SPOT_EXPONENT"); break;
	}
	printf (" %f\n",param);
	*/

	#ifndef GL_ES_VERSION_2_0
		glLightf(GL_LIGHT0+light,pname,param);
	#endif

	switch (pname) {
		case GL_CONSTANT_ATTENUATION:
			p->light_constAtten[light] = param;
			break;
		case GL_LINEAR_ATTENUATION:
			p->light_linAtten[light] = param;
			break;
		case GL_QUADRATIC_ATTENUATION:
			p->light_quadAtten[light] = param;
			break;
		case GL_SPOT_CUTOFF:
			p->light_spotCut[light] = param;
			break;
		case GL_SPOT_EXPONENT:
			p->light_spotExp[light] = param;
			break;
		default: {printf ("help, unknown fwgllightfv param %d\n",pname);}
	}
	p->lightParamsDirty = TRUE;
}
Esempio n. 10
0
void CLightManager::SetColor (short nLight, float red, float green, float blue, float fBrightness)
{
	CDynLight*	pl = m_data.lights + nLight;
	int			i;

if ((pl->info.nType == 1) ? gameOpts->render.color.bGunLight : gameStates.render.bAmbientColor) {
	pl->info.color.red = red;
	pl->info.color.green = green;
	pl->info.color.blue = blue;
	}
else
	pl->info.color.red =
	pl->info.color.green =
	pl->info.color.blue = 1.0f;
pl->info.color.alpha = 1.0;
pl->info.fBrightness = fBrightness;
pl->info.fRange = (float) sqrt (fBrightness / 2.0f);
pl->fSpecular[0] = red;
pl->fSpecular[1] = green;
pl->fSpecular[2] = blue;
for (i = 0; i < 3; i++) {
#if USE_OGL_LIGHTS
	pl->info.fAmbient.v [i] = pl->info.fDiffuse [i] * 0.01f;
	pl->info.fDiffuse.v [i] =
#endif
	pl->fEmissive [i] = pl->fSpecular[i] * fBrightness;
	}
// light alphas
#if USE_OGL_LIGHTS
pl->info.fAmbient.v [3] = 1.0f;
pl->info.fDiffuse.v [3] = 1.0f;
pl->fSpecular.v [3] = 1.0f;
glLightfv (pl->info.handle, GL_AMBIENT, pl->info.fAmbient);
glLightfv (pl->info.handle, GL_DIFFUSE, pl->info.fDiffuse);
glLightfv (pl->info.handle, GL_SPECULAR, pl->fSpecular);
glLightf (pl->info.handle, GL_SPOT_EXPONENT, 0.0f);
#endif
}
Esempio n. 11
0
void
init()
{
	LOG(printf("Initialize here."));
	glEnable(GL_DEPTH_TEST);

	// ADD-BY-LEETEN 02/03/2012-BEGIN
	static GLfloat pfLightAmbient[4] =	{0.1f, 0.1f, 0.1f, 1.0f};
	static GLfloat pfLightDiffuse[4] =	{0.6f, 0.6f, 0.6f, 1.0f};
	static GLfloat pfLightSpecular[4] =	{0.3f, 0.3f, 0.3f, 1.0f};;
	static GLfloat fSpotExponent = 4.0f;
	glLightfv(GL_LIGHT0, GL_AMBIENT,	pfLightAmbient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE,	pfLightDiffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR,	pfLightSpecular);
	glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, fSpotExponent);

	cLineRenderer._UpdateLighting();
	// ADD-BY-LEETEN 02/03/2012-END

	// ADD-BY-LEETEN 08/14/2010-BEGIN
	LOG(printf("The vector field is ready. Press key 's' to generate the primtives."));
	// ADD-BY-LEETEN 08/14/2010-END
}
Esempio n. 12
0
Action::ResultE PointLight::drawEnter(Action *action)
{   
    if(getOn() == false)
        return Action::Continue;

    DrawAction *da    = dynamic_cast<DrawAction *>(action);
    GLenum      light = GL_LIGHT0 + da->getLightCount();
    
    Light::drawEnter(action);

    Vec4f pos(_sfPosition.getValue());

    pos[3] = 1;

    glLightfv(light, GL_POSITION   , pos.getValues());
    glLightf (light, GL_SPOT_CUTOFF, 180.f          );

    glPopMatrix();

    da->getStatistics()->getElem(PointLight::statNPointLights)->inc();

    return Action::Continue;
}
Esempio n. 13
0
void setLight0() {

	float ambient[4] = { 0.2f, 0.2f, 0.2f, 1.0f };
	//float diffuse[4] = { 1.0f,1.0f,1.0f,1.0f };
	//float specular[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
	float diffuse[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
	float specular[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
	

	float position[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
	float direction[4] = { -1.0f, -1.0f, -1.0f, 1.0f };
	float cut_off = 90.0f;

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, specular);

	glLightfv(GL_LIGHT0, GL_POSITION, position);
	glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, direction);
	glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, cut_off);

	glEnable(GL_LIGHT0);
}
Esempio n. 14
0
//-----------------------------------------------------------------------------
void mglCanvasGL::AddLight(int n,mglPoint r,mglPoint d,char cc, mreal br,mreal ap)
{
	mglColor c(cc);
	float amb[4],dif[4],spc[4], pos[4],dir[4];
	bool inf = mgl_isnan(r.x);
	if(n<0 || n>7)	{	SetWarn(mglWarnLId,"AddLight");	return;	}
	if(c.Valid())
	{
		spc[0] = br*c.r;	spc[1] = br*c.g;	spc[2] = br*c.b;
		amb[0] = AmbBr*c.r;	amb[1] = AmbBr*c.g;	amb[2] = AmbBr*c.b;
	}
	else
	{
		spc[0] = spc[1] = spc[2] = br;
		amb[0] = amb[1] = amb[2] = AmbBr;
	}
	ap = 90-180*atan(fabs(ap))/M_PI;
	dif[0] = dif[1] = dif[2] = DifBr;
	dif[3] = amb[3] = spc[3] = 1.;
	if(inf)
	{	pos[0] = d.x;	pos[1] = d.y;	pos[2] = d.z;	pos[3] = 0;	}
	else
	{	pos[0] = r.x;	pos[1] = r.y;	pos[2] = r.z;	pos[3] = 1;	}
	dir[0] = d.x;	dir[1] = d.y;	dir[2] = d.z;	dir[3] = 0;

	glShadeModel(GL_SMOOTH);
	glLightfv(GL_LIGHT0+n, GL_AMBIENT, amb);
	glLightfv(GL_LIGHT0+n, GL_DIFFUSE, dif);
	glLightfv(GL_LIGHT0+n, GL_SPECULAR, spc);
	glLightfv(GL_LIGHT0+n, GL_POSITION, pos);
	if(!inf)
	{
		glLightfv(GL_LIGHT0+n, GL_SPOT_DIRECTION, dir);
		glLightf(GL_LIGHT0+n, GL_SPOT_CUTOFF, ap);
	}
	glEnable(GL_LIGHT0+n);
}
Esempio n. 15
0
bool lcLight::Setup(int LightIndex)
{
	GLenum LightName = (GLenum)(GL_LIGHT0 + LightIndex);

	if (mState & LC_LIGHT_DISABLED)
		return false;

	glEnable(LightName);

	glLightfv(LightName, GL_AMBIENT, mAmbientColor);
	glLightfv(LightName, GL_DIFFUSE, mDiffuseColor);
	glLightfv(LightName, GL_SPECULAR, mSpecularColor);

	if (!IsDirectionalLight())
	{
		glLightf(LightName, GL_CONSTANT_ATTENUATION, mAttenuation[0]);
		glLightf(LightName, GL_LINEAR_ATTENUATION, mAttenuation[1]);
		glLightf(LightName, GL_QUADRATIC_ATTENUATION, mAttenuation[2]);

		lcVector4 Position(mPosition, 1.0f);
		glLightfv(LightName, GL_POSITION, Position);
	}
	else
	{
		lcVector4 Position(mPosition, 0.0f);
		glLightfv(LightName, GL_POSITION, Position);
	}

	if (IsPointLight())
	{
		glLightf(LightName, GL_SPOT_CUTOFF, 180.0f);
	}
	else if (IsSpotLight())
	{
		lcVector3 Dir(mTargetPosition - mPosition);
		Dir.Normalize();

		glLightf(LightName, GL_SPOT_CUTOFF, mSpotCutoff);
		glLightf(LightName, GL_SPOT_EXPONENT, mSpotExponent);
		glLightfv(LightName, GL_SPOT_DIRECTION, Dir);
	}

	return true;
}
void initLights(void)
{
	//Define a luz ambiente global
	GLfloat global_ambient[] = { 0.05f, 0.05f, 0.05f, 1.0f };
	//Define a luz light0
	GLfloat light0_ambient[] = { 0.05f, 0.05f, 0.05f, 1.0f };
	GLfloat light0_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
	GLfloat light0_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };

	// Fonte de luz ambiente
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);

	// Fonte de luz posicional - na posicao do sol
	glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular);
	//glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.0025 /2);
	glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.00001);
	//glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0025/2);
	glEnable(GL_LIGHT0);


}
Esempio n. 17
0
void
init()
{
	cLineRenderer._SetInteger(CTimeLineRendererInOpenGL::TIME_VARYING_ON, 1);
	cLineRenderer._SetFloat(CTimeLineRendererInOpenGL::MIN_TIME_STEP, 0.0f);
	cLineRenderer._SetFloat(CTimeLineRendererInOpenGL::MAX_TIME_STEP, float(num_timesteps));


	LOG(printf("Initialize here."));
	glEnable(GL_DEPTH_TEST);

	// setup light 0
	static GLfloat pfLightAmbient[4] =	{0.0f, 0.0f, 0.0f, 1.0f};
	static GLfloat pfLightColor[4] =	{0.5f, 0.5f, 0.5f, 1.0f};
	glLightfv(GL_LIGHT0, GL_AMBIENT,		pfLightAmbient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE,		pfLightColor);
	glLightfv(GL_LIGHT0, GL_SPECULAR,		pfLightColor);
	glLightf(GL_LIGHT0, GL_SPOT_EXPONENT,	4.0f);
	cLineRenderer._UpdateLighting();

	// ADD-BY-LEETEN 08/14/2010-BEGIN
	LOG(printf("The vector field is ready. Press key 's' to generate the primtives."));
	// ADD-BY-LEETEN 08/14/2010-END
}
Esempio n. 18
0
void GLLogic::InitLighting()
{
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_COLOR_MATERIAL);
	glShadeModel(GL_SMOOTH);

	GLfloat lightPos[] = { 12.f, 12.f, -35.f, 1.f };
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

	GLfloat ambient[] = { 0.3f, 0.3f, 0.3f, 1.0f };
	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	GLfloat diffuse[] = { 0.7f, 0.7f, 0.7f, 1.f };
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
	GLfloat specular[] = { 1.f, 1.f, 1.f, 1.f };
	glLightfv(GL_LIGHT0, GL_SPECULAR, specular);

	GLfloat specularRef[] = { 1.f, 1.f, 1.f, 1.f };
	glMaterialfv(GL_FRONT, GL_SPECULAR, specularRef);
	glMateriali(GL_FRONT, GL_SHININESS, 128);
	glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 50.f);

	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
}
Esempio n. 19
0
void PositionalLight::drawLight()
{
    Light::drawLight();

    GLfloat pos[4];
    pos[0]=(GLfloat)(d_position.getValue()[0]);
    pos[1]=(GLfloat)(d_position.getValue()[1]);
    pos[2]=(GLfloat)(d_position.getValue()[2]);
    pos[3]=1.0; // positional
    if (d_fixed.getValue())
    {
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        glLightfv(GL_LIGHT0+m_lightID, GL_POSITION, pos);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
    }
    else
        glLightfv(GL_LIGHT0+m_lightID, GL_POSITION, pos);

    glLightf(GL_LIGHT0+m_lightID, GL_LINEAR_ATTENUATION, d_attenuation.getValue());

}
Esempio n. 20
0
void GUI::sunLight() {
#define SUN_LIGHT_STRENGHT 0.3f
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    GLfloat ambientLight[] = {
        SUN_LIGHT_STRENGHT,
        SUN_LIGHT_STRENGHT,
        SUN_LIGHT_STRENGHT*0.8f
    };
    GLfloat position[] = {
        ZOOM_1,
        10.0f,
        20.0f,
        1.0f
    };

    //glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 0.4f);
    //glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.01);
    glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.8f);

    glLightfv(GL_LIGHT0, GL_DIFFUSE, ambientLight);
    glLightfv(GL_LIGHT0, GL_POSITION, position);
}
Esempio n. 21
0
void Light::Enable(GLenum lightN)
{
    glEnable(lightN);
    float ambient0[4], diffuse0[4], specular0[4];

    for (int i = 0; i < 4; i++)
    {
        ambient0[i] = ambient[i] * intensity;
        diffuse0[i] = diffuse[i] * intensity;
        specular0[i] = specular[i] * intensity;
    }

    position[3] = lightType == 0 ? 0.0f : 1.0f;
    glLightfv(lightN, GL_POSITION, position);
    glLightfv(lightN, GL_AMBIENT, ambient0);
    glLightfv(lightN, GL_DIFFUSE, diffuse0);
    glLightfv(lightN, GL_SPECULAR, specular0);
    glLightf(lightN, GL_CONSTANT_ATTENUATION, const_att);
    glLightf(lightN, GL_LINEAR_ATTENUATION, linear_att);
    glLightf(lightN, GL_QUADRATIC_ATTENUATION, quad_att);
    glLightfv(lightN, GL_SPOT_DIRECTION, direction);

    if (lightType == 2)
    {
        if (cutoff == 180.0f) { cutoff = 90.0f; }

        glLightf(lightN, GL_SPOT_CUTOFF, cutoff);
        glLightf(lightN, GL_SPOT_EXPONENT, spot_exp);
    }
    else
    {
        cutoff = 180;
        glLightf(lightN, GL_SPOT_CUTOFF, cutoff);
        glLightf(lightN, GL_SPOT_EXPONENT, 0);
    }
}
Esempio n. 22
0
void setLight()
{
	//LIGHT0
  glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse[0]);
  glLightfv(GL_LIGHT0, GL_AMBIENT, lightDiffuse[0]);
  glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpecular[0]);
  glLightfv(GL_LIGHT0, GL_POSITION, lightPos[0]);
	//LIGHT1
  glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse[1]);
  glLightfv(GL_LIGHT1, GL_AMBIENT, lightDiffuse[1]);
  glLightfv(GL_LIGHT1, GL_SPECULAR, lightSpecular[1]);
  glLightfv(GL_LIGHT1, GL_POSITION, lightPos[1]);

	//減衰モード変更はLIGHT0だけ
	if(AttMode == 0)
	{
		constAtt = 1.0; linearAtt = 0.0; quadraAtt = 0.0;
	}
	else if(AttMode == 1) 
	{
		constAtt = 0.0; linearAtt = 1.0 / lightPos0[0][1]; quadraAtt = 0.0;
	}
	else
	{
		constAtt = 0.0; linearAtt = 0.0; quadraAtt = 1.0 / (lightPos0[0][1]*lightPos0[0][1]);
	}

	//LIGHT1はスポットライト(スポットライトは常にワールド空間の原点を向く)
	for(int i = 0; i < 3; i++) spotDir[i] = -lightPos[1][i];

	//LIGHT0
  glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, constAtt);
  glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, linearAtt);
  glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, quadraAtt);
  glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180.0);
  glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spotDir);
  glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, spotExp);
  glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, spotCutoff);
}
Esempio n. 23
0
/*
 *  OpenGL (GLUT) calls this routine to display the scene
 */
void display()
{
   int i,j;
   const double len=2.0;  //  Length of axes
   double mul = 2.0/num;
   float Position[] = {X+Cos(Th),Y+Sin(Th),Z,1-inf};
   //  Erase the window and the depth buffer
   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
   //  Enable Z-buffering in OpenGL
   glEnable(GL_DEPTH_TEST);
   //  Undo previous transformations
   glLoadIdentity();
   //  Perspective - set eye position
   if (mode)
   {
      double Ex = -2*dim*Sin(th)*Cos(ph);
      double Ey = +2*dim        *Sin(ph);
      double Ez = +2*dim*Cos(th)*Cos(ph);
      gluLookAt(Ex,Ey,Ez , 0,0,0 , 0,Cos(ph),0);
   }
   //  Orthogonal - set world orientation
   else
   {
      glRotatef(ph,1,0,0);
      glRotatef(th,0,1,0);
   }
   glShadeModel(smooth?GL_SMOOTH:GL_FLAT);
   //  Light switch
   if (light)
   {
      //  Translate intensity to color vectors
      float Ambient[]   = {0.01*ambient ,0.01*ambient ,0.01*ambient ,1.0};
      float Diffuse[]   = {0.01*diffuse ,0.01*diffuse ,0.01*diffuse ,1.0};
      float Specular[]  = {0.01*specular,0.01*specular,0.01*specular,1.0};
      //  Spotlight color and direction
      float yellow[] = {1.0,1.0,0.0,1.0};
      float Direction[] = {Cos(Th)*Sin(Ph),Sin(Th)*Sin(Ph),-Cos(Ph),0};
      //  Draw light position as ball (still no lighting here)
      ball(Position[0],Position[1],Position[2] , 0.1);
      //  OpenGL should normalize normal vectors
      glEnable(GL_NORMALIZE);
      //  Enable lighting
      glEnable(GL_LIGHTING);
      //  Location of viewer for specular calculations
      glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,local);
      //  Two sided mode
      glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,side);
      //  glColor sets ambient and diffuse color materials
      glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
      glEnable(GL_COLOR_MATERIAL);
      //  Set specular colors
      glMaterialfv(GL_FRONT,GL_SPECULAR,yellow);
      glMaterialfv(GL_FRONT,GL_SHININESS,shinyvec);
      //  Enable light 0
      glEnable(GL_LIGHT0);
      //  Set ambient, diffuse, specular components and position of light 0
      glLightfv(GL_LIGHT0,GL_AMBIENT ,Ambient);
      glLightfv(GL_LIGHT0,GL_DIFFUSE ,Diffuse);
      glLightfv(GL_LIGHT0,GL_SPECULAR,Specular);
      glLightfv(GL_LIGHT0,GL_POSITION,Position);
      //  Set spotlight parameters
      glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,Direction);
      glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,sco);
      glLightf(GL_LIGHT0,GL_SPOT_EXPONENT,Exp);
      //  Set attenuation
      glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION ,at0/100.0);
      glLightf(GL_LIGHT0,GL_LINEAR_ATTENUATION   ,at1/100.0);
      glLightf(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,at2/100.0);
   }
   else
      glDisable(GL_LIGHTING);
   //  Enable textures
   if (ntex)
      glEnable(GL_TEXTURE_2D);
   else
      glDisable(GL_TEXTURE_2D);
   glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
   //  Draw the wall
   glColor3f(1.0,1.0,1.0);
   glNormal3f(0,0,1); 
   glBegin(GL_QUADS);
   for (i=0;i<num;i++)
      for (j=0;j<num;j++)
      {
         glTexCoord2d(mul*(i+0),mul*(j+0)); glVertex2d(5*mul*(i+0)-5,5*mul*(j+0)-5);
         glTexCoord2d(mul*(i+1),mul*(j+0)); glVertex2d(5*mul*(i+1)-5,5*mul*(j+0)-5);
         glTexCoord2d(mul*(i+1),mul*(j+1)); glVertex2d(5*mul*(i+1)-5,5*mul*(j+1)-5);
         glTexCoord2d(mul*(i+0),mul*(j+1)); glVertex2d(5*mul*(i+0)-5,5*mul*(j+1)-5);
      }
   glEnd();
   glDisable(GL_TEXTURE_2D);
   //  Draw axes - no lighting from here on
   glDisable(GL_LIGHTING);
   glColor3f(1,1,1);
   if (axes)
   {
      glBegin(GL_LINES);
      glVertex3d(0.0,0.0,0.0);
      glVertex3d(len,0.0,0.0);
      glVertex3d(0.0,0.0,0.0);
      glVertex3d(0.0,len,0.0);
      glVertex3d(0.0,0.0,0.0);
      glVertex3d(0.0,0.0,len);
      glEnd();
      //  Label axes
      glRasterPos3d(len,0.0,0.0);
      Print("X");
      glRasterPos3d(0.0,len,0.0);
      Print("Y");
      glRasterPos3d(0.0,0.0,len);
      Print("Z");
      //  Show quads
      glBegin(GL_LINES);
      for (i=0;i<=num;i++)
      {
         glVertex3d(5*mul*i-5,-5,0.01);
         glVertex3d(5*mul*i-5,+5,0.01);
      }
      for (j=0;j<=num;j++)
      {
         glVertex3d(-5,5*mul*j-5,0.01);
         glVertex3d(+5,5*mul*j-5,0.01);
      }
      glEnd();
   }
   //  Display parameters
   glWindowPos2i(5,5);
   Print("Angle=%d,%d  Dim=%.1f Projection=%s Light=%s",
     th,ph,dim,mode?"Perpective":"Orthogonal",light?"On":"Off");
   if (light)
   {
      glWindowPos2i(5,65);
      Print("Cutoff=%.0f Exponent=%.1f Direction=%d,%d Attenuation=%.2f,%.2f,%.2f",sco,Exp,Th,Ph,at0/100.0,at1/100.0,at2/100.0);
      glWindowPos2i(5,45);
      Print("Model=%s LocalViewer=%s TwoSided=%s Position=%.1f,%.1f,%.1f,%.1f Num=%d",smooth?"Smooth":"Flat",local?"On":"Off",side?"On":"Off",Position[0],Position[1],Position[2],Position[3],num);
      glWindowPos2i(5,25);
      Print("Ambient=%d  Diffuse=%d Specular=%d Emission=%d Shininess=%.0f",ambient,diffuse,specular,emission,shinyvec[0]);
   }
   //  Render the scene and make it visible
   ErrCheck("display");
   glFlush();
   glutSwapBuffers();
}
Esempio n. 24
0
void display(void)
{



	glFogf (GL_FOG_DENSITY, density);

	printf("%f \n",density);

		// Position the light and show where it is
	glPushMatrix();

	glRotatef(90,0,1,0);
		glTranslatef(move_x, move_y, move_z);
		
	//	glLightf(GL_LIGHT4, GL_CONSTANT_ATTENUATION, const_att);
		glLightfv(GL_LIGHT4, GL_POSITION, light_pos);
		//glDisable(GL_LIGHTING);
		//glDisable(GL_LIGHT4);
		glColor3d(0.9, 0.9, 0.5);
		glutSolidSphere(0.1, 10, 10);
		//glEnable(GL_LIGHTING);
		//glEnable(GL_LIGHT4);
	glPopMatrix();

	


	for(int i =0;i<16;i++)
	{
		HeadMatrix[i] = dragonmodel.TransformMatrixArray[0][i];
	}

	light_position[0] = HeadMatrix[12];
	light_position[1] = HeadMatrix[13];
	light_position[2] = HeadMatrix[14];
	
	light_direction[0] = HeadMatrix[8];
	light_direction[1] = HeadMatrix[9];
	light_direction[2] = HeadMatrix[10];

	normalizeCamTarget();

	




	
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);	
	glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light_direction);

	glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, fSpotLight);


	glLightfv(GL_LIGHT7, GL_POSITION, light_position);	
	glLightfv(GL_LIGHT7, GL_SPOT_DIRECTION, light_direction);

	glLightf(GL_LIGHT7, GL_SPOT_CUTOFF, fSpotLight);




// 	glLightfv(GL_LIGHT5, GL_POSITION, lightBody_position);	
// glLightfv(GL_LIGHT5, GL_SPOT_DIRECTION, light_direction);

	glLightf(GL_LIGHT5, GL_SPOT_CUTOFF, fSpotLight);



	// glLightfv(GL_LIGHT1, GL_POSITION, light1_position);	
	// glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, light1_direction);

	// glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, fSpotLight);


//glLoadIdentity();

	

	//135-206-250

	//glClearColor(0.52734375,0.8046875,0.9765625,0); //light blue

	//overcast
	//glClearColor(0.6796875,0.71484375,0.7421875,0);
	//darker overcast
	glClearColor(0.1796875,0.21484375,0.2421875,0);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



		glMatrixMode(GL_MODELVIEW);
	

	glLoadIdentity();




	// cam_position[0] = cam_radius * sin(cam_phi) * sin(cam_theta);
	// cam_position[1] = cam_radius * cos(cam_phi);
	// cam_position[2] = cam_radius * sin(cam_phi) * cos(cam_theta);


	cam_target[0] = dragonmodel.getTransformMatrixArrayValue(0,12);
	cam_target[1] = dragonmodel.getTransformMatrixArrayValue(0,13);
	cam_target[2] = dragonmodel.getTransformMatrixArrayValue(0,14);



	GLfloat x;
	GLfloat y;
	GLfloat z;
	GLfloat total;

	x = cam_position[0] - cam_target[0];
	y = cam_position[1] - cam_target[1];
	z = cam_position[2] - cam_target[2];

	total = x*x + y*y + z*z;
	total  = sqrt(total);

	//printf("\n");
	//printf(" wanted_cam_radius = %f\n" , wanted_cam_radius);
	////printf(" camradius = %f\n" , cam_radius);

	//printf(" dist = %f\n" , total);

	GLfloat diff = wanted_cam_radius - total;
	//diff = diff*diff;
	//diff = sqrt(diff);

	//printf(" diff = %f\n" , diff);

	// if (diff>10 || diff<-10)
	// {
	// 	cam_radius += diff;
	// }
	
	// if(cam_radius>wanted_cam_radius)
	// {
	// 	cam_radius += 0.05*(diff);
	// }
	// else
	// 	cam_radius  -= 0.05*(diff); //-= 0.5*(diff);

	

	cam_position[0] = cam_radius * sin(cam_phi) * sin(cam_theta)+ cam_target[0] ;
	cam_position[1] = cam_radius * cos(cam_phi)+ cam_target[1];
	cam_position[2] = cam_radius * sin(cam_phi) * cos(cam_theta)+cam_target[2];


	glLightfv(GL_LIGHT2, GL_POSITION, cam_position);	
	glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, light2_target);

	glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 20);


	
	if(cameraFlag == false)
	{
		

		gluLookAt(cam_position[0],cam_position[1],cam_position[2],
				  cam_target[0], cam_target[1], cam_target[2],
				  0,1,0);//cam_up[0], cam_up[1], cam_up[2]);
	}

	if(cameraFlag == true)
	{
		dragonmodel.updateCamera();
	}


	glPushMatrix();
	drawFloor();
	drawSun();



	//glPushMatrix();
	glScalef(0.5,0.5,0.5);



	dragonmodel.drawTrees();

	////////////forest
	//making trees


	float scale;

	
	for (int i = 0; i < amount; i++)
	{
				glPushAttrib(GL_ALL_ATTRIB_BITS);
				glPushMatrix();
				glTranslatef(location[i][0], 0, location[i][1]);



				if (location[i][2] == 0)
				{
					scale = (i % 50) + 1;
					glPushMatrix();
					glScalef( scale/25, scale/25, scale/25);
					dragonmodel.drawTrees();
					glPopMatrix();

	

				}

				else if (location[i][2] == 1)
				{
					scale = (i % 50) + 1;
					glPushMatrix();
					glScalef( scale/25, scale/25, scale/25);
					dragonmodel.drawTrees2();
					glPopMatrix();
				}
				
				else if (location[i][2] == 2)
				{
					scale = (i % 50) + 1;
					glPushMatrix();
					glScalef( scale/25, scale/25, scale/25);
					dragonmodel.drawTrees3();
					glPopMatrix();
				}
				else
				{
					scale = (i % 50) + 1;
					glPushMatrix();
					glScalef( scale/25, scale/25, scale/25);
					dragonmodel.drawTrees4();
					glPopMatrix();
				}					
				//printf("%d \n", location[i][2]);

				glPopMatrix();
				glPopAttrib();
			
	}

	glPopMatrix();

	glPopMatrix();


//Psuh Dragon up

glPushAttrib(GL_ALL_ATTRIB_BITS);
	glPushMatrix();

	glTranslatef(0,20,0);

	if(colorflag == 0)
	{
		glDisable(GL_COLOR_MATERIAL);
		glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, trans);
		glMaterialfv(GL_FRONT, GL_SHININESS, shine);
		glMaterialfv(GL_BACK, GL_AMBIENT_AND_DIFFUSE, trans);
		glMaterialfv(GL_BACK, GL_SHININESS, shine);
	}
		
	dragonmodel.drawDragon();

	if(colorflag == 0)
	{
		glEnable(GL_COLOR_MATERIAL);
	}



	glPopMatrix();

	glPopAttrib();


	glutSwapBuffers();


}
Esempio n. 25
0
void init(void) 
{


	dragonmodel.generateBody();
	dragonmodel.generateTail();
	// Shift values just once
	dragonmodel.animateDragon(&Pitch,&Yaw,&Roll,1.5);

	tex_2D = SOIL_load_OGL_texture
   (
       "dragonscales.jpg",
       SOIL_LOAD_RGBA,
       SOIL_CREATE_NEW_ID,
       SOIL_FLAG_NTSC_SAFE_RGB
   );

    // glGenTextures(1,&tex_2D);
    // glDeleteTextures(1,&tex_2D);

    ///////////////// fog stuff
	glEnable (GL_DEPTH_TEST); //enable the depth testing

glEnable (GL_FOG); //enable the fog

glEnable(GL_BLEND);//enables alpha blend
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


glFogi (GL_FOG_MODE, GL_EXP2); //set the fog mode to GL_EXP2

glFogfv (GL_FOG_COLOR, fogColor); //set the fog color to our color chosen above

//lFogf (GL_FOG_DENSITY, density); //set the density to the value above

glHint (GL_FOG_HINT, GL_NICEST); // set the fog to look the nicest, may slow down on older cards
	/////////////////////end of fog stuff

	cam_radius = 100;
	cam_phi = 0.69;
	cam_theta = -3.99;
	wanted_cam_radius = 45;


	// Setting cam position to origin
	// It is irreleveant since radius has been set to 10,
	// therefore, thses values will be recalculated later.
	cam_position[0] = 10;
	cam_position[1] = 10;
	cam_position[2] = 10;

	// Point camera to center of dragon
	cam_target[0] = 0;
	cam_target[1] = 40;
	cam_target[2] = 0;

	// Setting camera's Up vector
	// In this case, Up is the +Yaxis
	cam_up[0] = 0;
	cam_up[1] = 1;
	cam_up[2] = 0;

	//cam_phi = 0.99;
	//cam_theta = -3.99;

	glMatrixMode(GL_PROJECTION);
								
	glLoadIdentity();
								
	gluPerspective(90*zoom, (GLfloat)w/(GLfloat)h, 1.0, 10000.0);

	glMatrixMode(GL_MODELVIEW);	
								
	glLoadIdentity();
								
	//Background Color
		//Cornflower Blue
		//Original Code: 100-149-237
	//glClearColor (0.390625, 0.58203125, 0.92578125, 0.0);
	glClearColor(0,0,0,0);
	


	glEnable (GL_BLEND); 
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


	glEnable(GL_DEPTH_TEST);
	glShadeModel (GL_SMOOTH);

	
	//Sets lighting
	



//	glLightfv(GL_LIGHT0, GL_AMBIENT, white);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
	glLightfv(GL_LIGHT0, GL_SPECULAR, white);

	
	glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 2.0);
	
	// glLightf(GL_LIGHT0, disp, 1.0);
	// glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0);
	 glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0015);


	glLightfv(GL_LIGHT7, GL_DIFFUSE, white);
	glLightfv(GL_LIGHT7, GL_SPECULAR, white);


	glLightfv(GL_LIGHT5, GL_DIFFUSE, white);
	glLightfv(GL_LIGHT5, GL_SPECULAR, white);
	//glLightf(GL_LIGHT5, GL_SPOT_EXPONENT, 2.0);
	glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.15);

	glLightfv(GL_LIGHT1, GL_DIFFUSE, blue);
	glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 2.0);

	// glLightfv(GL_LIGHT2, GL_DIFFUSE, red);
	// glLightf(GL_LIGHT2, GL_SPOT_EXPONENT, 2.0);


	

	// Allows color on models with lighting
	glEnable(GL_COLOR_MATERIAL);
//	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	//glColorMaterial(GL_FRONT, GL_SPECULAR);
	//glMaterialf(GL_FRONT, GL_SHININESS, 100);


	glLightfv(GL_LIGHT4, GL_DIFFUSE, suncolor);

	glLightf(GL_LIGHT4, GL_LINEAR_ATTENUATION, 0.00);
	
	glLightfv(GL_LIGHT0, GL_SPECULAR, white);
	
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT4);
	glEnable(GL_LIGHT7);

	glEnable(GL_LIGHT5);
	//glEnable(GL_LIGHT1);
	//glEnable(GL_LIGHT2);

	glEnable(GL_LIGHTING);

	


}
Esempio n. 26
0
void initialize(void)
{
    glClearColor(0,0.2,0.4,0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60,1,0.5,100);
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
    glEnable (GL_LIGHTING);
    GLfloat density = 0.02;
    GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1.0};
//	glEnable (GL_FOG);
    glFogi (GL_FOG_MODE, GL_EXP2);
    glFogfv (GL_FOG_COLOR, fogColor);
    glFogf (GL_FOG_DENSITY, density);
    glHint (GL_FOG_HINT, GL_NICEST);
    GLfloat light_ambient[] = { 0.3, 0.3, 0.3, 0.3 };
    GLfloat spec_color[] = { 1.0, 1.0, 1.0, 0.0 };
    GLfloat spot_direction[] = { 0.0, sun_y, -4.0 };

    GLfloat mat_specular[] = { 0.0, 0.0, 0.0, 1.0 };
    GLfloat mat_shininess[] = { 50.0 };
    GLfloat pos[] = { 0.0, 4.0, -2.0, 0.3 };
    GLfloat light_position[] = { 1.0, 10.0, -6.0, 0.5 };

    GLfloat light_position1[] = { 10.0, 0.0, -4.0, 1.0 };

    //	glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_SMOOTH);

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);


    glLightfv(GL_LIGHT2, GL_POSITION, light_position1);
    glLightfv(GL_LIGHT1, GL_POSITION, pos);
    glLightfv(GL_LIGHT3, GL_AMBIENT, light_ambient);
    glLightfv(GL_LIGHT3, GL_DIFFUSE, spec_color);
    glLightfv(GL_LIGHT3, GL_POSITION, light_position);
    glLightf(GL_LIGHT3, GL_CONSTANT_ATTENUATION, 1.5);
    glLightf(GL_LIGHT3, GL_LINEAR_ATTENUATION, 0.05);
    glLightf(GL_LIGHT3, GL_QUADRATIC_ATTENUATION, 0.00);

//	glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 20.0);
//	glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, spot_direction);
//	glLightf(GL_LIGHT2, GL_SPOT_EXPONENT, 2.0);


//	glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
//	glEnable(GL_LIGHT2);
    glEnable(GL_LIGHT3);
    glEnable(GL_COLOR_MATERIAL);
//	loadTexture(0,"monitor.bmp",texture_id);
    loadTexture(1,"grass.bmp",texture_id);

    loadTexture(2,"road.bmp",texture_id);

//	loadTexture(2,"key.bmp",texture_id);
//	loadTexture(3,"brick.bmp",texture_id);
}
Esempio n. 27
0
		void drawLight(int particle){

			GLenum lights;

			float colorValue = 0.8;
			int degree = 20;

			if(particle == 0){
				colorValue = 0.8;
				degree = this->pacmanDegreeVisivility;
			}

			GLint position[4];
  			GLfloat color[4];
  			GLfloat dir[3];

  			switch(current_direction){
  				case UP:
  					dir[0]=0;dir[1]=0;dir[2]=-1;
  					break;
				case DOWN:
  					dir[0]=0;dir[1]=0;dir[2]=1;
  					break;
				case RIGHT:
  					dir[0]=1;dir[1]=0;dir[2]=0;
  					break;
				case LEFT:
  					dir[0]=-1;dir[1]=0;dir[2]=0;
  					break;
  			}

  			switch (particle){
  				case 0:
  					lights = GL_LIGHT2;
  					break;
				case 1:
  					lights = GL_LIGHT3;
  					break;
				case 2:
  					lights = GL_LIGHT4;
  					break;
				case 3:
  					lights = GL_LIGHT5;
  					break;
  			}
  				

  			glLightfv(lights,GL_SPOT_DIRECTION,dir);
  			glLightf(lights,GL_SPOT_CUTOFF,degree);
  			glLightf(lights,GL_SPOT_EXPONENT,10);

			position[0]=(x+0.5)*cellWidth; position[1]=Y+radiParticle; position[2]=(y+0.5)*cellHeight; position[3]=1; 
			glLightiv(lights,GL_POSITION,position);

			color[0]=colorValue; color[1]=colorValue; color[2]=colorValue; color[3]=1;
			glLightfv(lights,GL_DIFFUSE,color);

			glLightf(lights,GL_CONSTANT_ATTENUATION,1.0);
			glLightf(lights,GL_LINEAR_ATTENUATION,0.0);
			glLightf(lights,GL_QUADRATIC_ATTENUATION,0.0);

			glEnable(lights);
		}
Esempio n. 28
0
void
screen_display(void)
{
    GLfloat pos[4], lKa[4], lKd[4], lKs[4];
    GLfloat dir[3], mKa[4], mKd[4], mKs[4], mKe[4];
    GLfloat lmKa[4];

    cell_vector(pos, light_pos, 4);
    cell_vector(lKa, light_Ka, 4);
    cell_vector(lKd, light_Kd, 4);
    cell_vector(lKs, light_Ks, 4);
    cell_vector(dir, spot_direction, 3);
    cell_vector(mKa, material_Ka, 4);
    cell_vector(mKd, material_Kd, 4);
    cell_vector(mKs, material_Ks, 4);
    cell_vector(mKe, material_Ke, 4);
    cell_vector(lmKa, lmodel_Ka, 4);

    glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, local_viewer.value);
    glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, two_side.value);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmKa);

    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glLightfv(GL_LIGHT0, GL_AMBIENT, lKa);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lKd);
    glLightfv(GL_LIGHT0, GL_SPECULAR, lKs);
    glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
    glLighti(GL_LIGHT0, GL_SPOT_EXPONENT, (int)spot_exponent.value);
    if (spot_cutoff.value > 90)
        glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, 180);
    else
        glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, (int)spot_cutoff.value);
    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, Kc.value);
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, Kl.value);
    glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, Kq.value);

    glMaterialfv(GL_FRONT, GL_AMBIENT, mKa);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mKd);
    glMaterialfv(GL_FRONT, GL_SPECULAR, mKs);
    glMaterialfv(GL_FRONT, GL_EMISSION, mKe);
    glMaterialf(GL_FRONT, GL_SHININESS, material_Se.value);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glRotatef(spin_y, 1.0, 0.0, 0.0);
    glRotatef(spin_x, 0.0, 1.0, 0.0);
    glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
    if (pmodel)
        drawmodel();
    else
        glutSolidTorus(0.25, 0.75, 28, 28);
    glPopMatrix();

#if 0
#define TESS 20
    glNormal3f(0.0, 1.0, 0.0);
    for (i = 0; i < TESS; i++) {
        glBegin(GL_TRIANGLE_STRIP);
        for (j = 0; j <= TESS; j++) {
            glVertex3f(-1+(float)i/TESS*2, -1.0, -1+(float)j/TESS*2);
            glVertex3f(-1+(float)(i+1)/TESS*2, -1.0, -1+(float)j/TESS*2);
        }
        glEnd();
    }
#endif

    glutSwapBuffers();
}
Esempio n. 29
0
void
world_display(void)
{
    double length;
    float l[3];
    GLfloat pos[4], lKa[4], lKd[4], lKs[4];
    GLfloat dir[3], mKa[4], mKd[4], mKs[4], mKe[4];
    GLfloat lmKa[4];

    cell_vector(pos, light_pos, 4);
    cell_vector(lKa, light_Ka, 4);
    cell_vector(lKd, light_Kd, 4);
    cell_vector(lKs, light_Ks, 4);
    cell_vector(dir, spot_direction, 3);
    cell_vector(mKa, material_Ka, 4);
    cell_vector(mKd, material_Kd, 4);
    cell_vector(mKs, material_Ks, 4);
    cell_vector(mKe, material_Ke, 4);
    cell_vector(lmKa, lmodel_Ka, 4);

    glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, local_viewer.value);
    glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, two_side.value);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmKa);

    glMaterialfv(GL_FRONT, GL_AMBIENT, mKa);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mKd);
    glMaterialfv(GL_FRONT, GL_SPECULAR, mKs);
    glMaterialfv(GL_FRONT, GL_EMISSION, mKe);
    glMaterialf(GL_FRONT, GL_SHININESS, material_Se.value);

    glLightfv(GL_LIGHT0, GL_AMBIENT, lKa);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lKd);
    glLightfv(GL_LIGHT0, GL_SPECULAR, lKs);
    glLighti(GL_LIGHT0, GL_SPOT_EXPONENT, (int)spot_exponent.value);
    if (spot_cutoff.value > 90)
        glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, 180);
    else
        glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, (int)spot_cutoff.value);
    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, Kc.value);
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, Kl.value);
    glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, Kq.value);

    l[0] = at[0] - eye[0];
    l[1] = at[1] - eye[1];
    l[2] = at[2] - eye[2];

    invert(modelview, inverse);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
    glMultMatrixd(inverse);
    glTranslatef(l[0], l[1], l[2]);
    glColor3fv(lKd);
    glBegin(GL_LINE_STRIP);
    if (spot_cutoff.value > 90)
        glVertex3f(0, 0, 0);
    else
        glVertex3f(pos[0]+spot_direction[0].value,
                   pos[1]+spot_direction[1].value,
                   pos[2]+spot_direction[2].value);

    if (pos[3] == 0)        /* 10.0 = 'infinite' light */
        glVertex3f(pos[0]*10.0,pos[1]*10.0,pos[2]*10.0);
    else
        glVertex3f(pos[0], pos[1], pos[2]);
    glEnd();
    glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glPopMatrix();

    length = normalize(l);

    if (world_draw) {
        glEnable(GL_LIGHTING);
        if (pmodel)
            drawmodel();
        else
            glutSolidTorus(0.25, 0.75, 28, 28);
        glDisable(GL_LIGHTING);
    }

#if 0
#define TESS 20
    glNormal3f(0.0, 1.0, 0.0);
    for (i = 0; i < TESS; i++) {
        glBegin(GL_TRIANGLE_STRIP);
        for (j = 0; j <= TESS; j++) {
            glVertex3f(-1+(float)i/TESS*2, -1.0, -1+(float)j/TESS*2);
            glVertex3f(-1+(float)(i+1)/TESS*2, -1.0, -1+(float)j/TESS*2);
        }
        glEnd();
    }
#endif

    glPushMatrix();
    glMultMatrixd(inverse);

    /* draw the axis and eye vector */
    glPushMatrix();
    glColor3ub(0, 0, 255);
    glBegin(GL_LINE_STRIP);
    glVertex3f(0.0, 0.0, 0.0);
    glVertex3f(0.0, 0.0, -1.0*length);
    glVertex3f(0.1, 0.0, -0.9*length);
    glVertex3f(-0.1, 0.0, -0.9*length);
    glVertex3f(0.0, 0.0, -1.0*length);
    glVertex3f(0.0, 0.1, -0.9*length);
    glVertex3f(0.0, -0.1, -0.9*length);
    glVertex3f(0.0, 0.0, -1.0*length);
    glEnd();
    glColor3ub(255, 255, 0);
    glRasterPos3f(0.0, 0.0, -1.1*length);
    glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, 'e');
    glColor3ub(255, 0, 0);
    glScalef(0.4, 0.4, 0.4);
    drawaxes();
    glPopMatrix();

    invert(projection, inverse);
    glMultMatrixd(inverse);

    /* draw the viewing frustum */
    glColor3f(0.2, 0.2, 0.2);
    glBegin(GL_QUADS);
    glVertex3i(1, 1, 1);
    glVertex3i(-1, 1, 1);
    glVertex3i(-1, -1, 1);
    glVertex3i(1, -1, 1);
    glEnd();

    glColor3ub(128, 196, 128);
    glBegin(GL_LINES);
    glVertex3i(1, 1, -1);
    glVertex3i(1, 1, 1);
    glVertex3i(-1, 1, -1);
    glVertex3i(-1, 1, 1);
    glVertex3i(-1, -1, -1);
    glVertex3i(-1, -1, 1);
    glVertex3i(1, -1, -1);
    glVertex3i(1, -1, 1);
    glEnd();

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glColor4f(0.2, 0.2, 0.4, 0.5);
    glBegin(GL_QUADS);
    glVertex3i(1, 1, -1);
    glVertex3i(-1, 1, -1);
    glVertex3i(-1, -1, -1);
    glVertex3i(1, -1, -1);
    glEnd();
    glDisable(GL_BLEND);

    glPopMatrix();
    glutSwapBuffers();
}
Esempio n. 30
0
void myWindow::paintGL()
{
    double deltaTime = t_Timer->interval()/1000.0;

    int LightPos[4] = {1,5,-1,0};
    int Light2Pos[4] = {-2,7,2,0};
    int Light3Pos[4] = {5,4,0,0};
    _fx += _speed;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );

    glLightiv(GL_LIGHT0,GL_POSITION,LightPos);
    glLightiv(GL_LIGHT1,GL_POSITION,Light2Pos);
    glLightiv(GL_LIGHT2,GL_POSITION,Light3Pos);
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 1);
    glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 10);

    //zoom
    if(_zooming){
        multiplicateurovertimezoom += 0.15;
        _zoom += _zoomspeed * multiplicateurovertimezoom * deltaTime;
    }else if(_dezooming){
        multiplicateurovertimezoom += 0.15;
        _zoom -= _zoomspeed * multiplicateurovertimezoom * deltaTime;
    }else{
        multiplicateurovertimezoom = 1.0;
    }
    //rotation
    if(_turningleft){
        multiplicateurovertimerotation += 0.15;
        _fx -= _rotationspeed * multiplicateurovertimerotation * deltaTime;
    }else if(_turningright){
        multiplicateurovertimerotation += 0.15;
        _fx += _rotationspeed * multiplicateurovertimerotation * deltaTime;
    }else{
        multiplicateurovertimerotation = 1.0;
    }
    //angle
    if(_plonger){
        multiplicateurovertimeplonger += 0.15;
        _angle += _rotationspeed* multiplicateurovertimeplonger *deltaTime;
    }else if(_deplonger){
        multiplicateurovertimeplonger += 0.15;
        _angle -= _rotationspeed* multiplicateurovertimeplonger *deltaTime;
    }else{
        multiplicateurovertimeplonger = 1.0;
    }
    //hauteur camera
    if(_monter){
        multiplicateurovertimemonter += 0.15;
        _hauteurcam -= 2 * multiplicateurovertimemonter *deltaTime;
    }else if(_demonter){
        multiplicateurovertimemonter += 0.15;
        _hauteurcam += 2 * multiplicateurovertimemonter *deltaTime;
    }else{
        multiplicateurovertimemonter = 1.0;
    }

    glTranslatef(0.f, _hauteurcam, _zoom);
    glRotated(_angle,1,0,0);
    glRotated(_fx,0,0,1);

    //***************************************//
    //************* Création Mesh ***********//
    //***************************************//

    if(!meshUpToDate){
        _par.resetEtageLePlusHaut();

        qDebug()<<_mesh.nbFace();
        largeur = 40; //du terrain
        longueur = 40;

        int largeurQuartier = 10;
        int longueurQuartier = 10;
/*
        float angle = 2*3.14159265359 / 6;
        _mesh = Mesh::createHexaangle3D(Vector3D(cos(0),sin(0),0),
                                        Vector3D(cos(angle),sin(angle),0),
                                        Vector3D(cos(2*angle),sin(2*angle),0),
                                        Vector3D(cos(3*angle),sin(3*angle),0),
                                        Vector3D(cos(4*angle),sin(4*angle),0),
                                        Vector3D(cos(5*angle),sin(5*angle),0),1.0);
*/
/*
        Mesh m1;
        for(float i=-largeur/2;i<largeur/2;i+=3.1){
            for(float j=-longueur/2; j<longueur/2; j+=3.1){
        //for(float i=-largeur/2;i<largeur/2;i+=largeurQuartier+1){
            //for(float j=-longueur/2; j<longueur/2; j+=longueurQuartier+1){
                int tmp = (int)rand()%4;
                //tmp = 0;
                //qDebug()<<tmp;
                if(tmp == 0){
                    //PaterneQuad p1(Vector2D(i,j), Vector2D(i,j+longueurQuartier), Vector2D(i+largeurQuartier,j+longueurQuartier), Vector2D(i+largeurQuartier,j),&_par);
                     //m1.merge(p1.generate());
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }else if(tmp == 1){
                    float offset = (rand()%21)*0.1;
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }else if(tmp == 2){
                    float offset = (rand()%21)*0.1;
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }else{
                    float offset = (rand()%21)*0.1;
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }
            }
        }
        _mesh = m1;*/
        /*Batiment test(Vector3D(-3+(rand()%100)*0.001,-3+(rand()%100)*0.001,0),
                      Vector3D(-3+(rand()%100)*0.001,3+(rand()%100)*0.001,0),
                      Vector3D(3+(rand()%100)*0.001,3+(rand()%100)*0.001,0),
                      Vector3D(3+(rand()%100)*0.001,-3+(rand()%100)*0.001,0),
                      &_par);
        _mesh = test.generate();*/

        TerrainBase base(400,400, &_par);
        base.decoupeSimple(4000);
        base.shrink(4.f);
        base.supprPetitQuartier(400);
        _mesh = base.generate();

        //Mesh m1 = base.generate();


/*
        TerrainBase base(2000,2000, &_par);
        base.decoupeSimple();
        base.shrink(10.f);
        base.supprPetitQuartier(1000);
        Mesh m = base.generate();

        _mesh = m;

*/
        /*
        TerrainBase base(1000,1000);
        base.decoupeSimple();
        for(Quartier* q : base.quartiers){

        }*/
        meshUpToDate = true;
        frame->update_values();
    }
    glEnable(GL_LIGHTING);
    int nbfaces = _mesh.nbFace();
    for(int i=0; i<nbfaces; i+=3){
        Vector3D dir1, dir2; //pour le calcul des normals
        Vector3D normal;
        Vector3D p1 = _mesh.getVertex(_mesh.getFace(i));
        Vector3D p2 = _mesh.getVertex(_mesh.getFace(i+1));
        Vector3D p3 = _mesh.getVertex(_mesh.getFace(i+2));
        dir1 = p2-p1;
        dir2 = p3-p1;
        normal = dir1.crossProduct(dir2);
        normal.normalize();;
        glColor3f(0.0,1.0,0.0); //Y vert
        glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
        glBegin(GL_TRIANGLES);
            glNormal3f(normal.x,normal.y,normal.z);
            glVertex3f(p1.x,p1.y,p1.z);
            glVertex3f(p2.x,p2.y,p2.z);
            glVertex3f(p3.x,p3.y,p3.z);
        glEnd();
    }

    glDisable(GL_LIGHTING);
    float angle = (2*M_PI)/64;
    glColor3f(1.0,0.2,0.2);
    glLineWidth(4.0f);
    glBegin(GL_LINE_STRIP);

    for(float i = 0; i < 2*M_PI ; i+=angle){
        glVertex3f(cos(i)*200*_par.influenceCentreVille+_par._centreVille.x, sin(i)*200*_par.influenceCentreVille+_par._centreVille.y,10);
    }
    glEnd();
    _draw_text(_par.hauteurEtageLePlusHaut.x,_par.hauteurEtageLePlusHaut.y,_par.hauteurEtageLePlusHaut.z,QString(QString::number(_par.etageLePlusHaut)));
}