void NorwegianWoodStyle::polish(QPalette &palette)
{
    QColor brown(212, 140, 95);
    QColor beige(212, 140, 95);
    QColor slightlyOpaqueBlack(0, 0, 0, 63);
    
    QPixmap backgroundIamge(":/images/woodbackground.png");
    QPixmap buttonImage(":/images/woodbutton.png");
    QPixmap midImage = buttonImage;
    
    QPainter painter;
    painter.begin(&midImage);
    painter.setPen(Qt::NoPen);
    painter.fillRect(midImage.rect(), slightlyOpaqueBlack);
    painter.end();

    palette = QPalette(brown);
    
    palette.setBrush(QPalette::BrightText, Qt::white);
    palette.setBrush(QPalette::Base, beige);
    palette.setBrush(QPalette::Highlight, Qt::darkGreen);
    setTexture(palette, QPalette::Button, buttonImage); 
    setTexture(palette, QPalette::Mid, midImage); 
    setTexture(palette, QPalette::Window, backgroundIamge); 

    QBrush brush = palette.background();
    brush.setColor(brush.color().dark());

    palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Text, brush);
    palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Base, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Button, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Mid, brush);
}
Пример #2
0
void CustomStyle::polish(QPalette &palette)
{
    QColor brown(Qt::white);
    QColor beige(Qt::transparent);
    QColor slightlyOpaqueBlack(0, 0, 0, 63);

//      QPainter painter;
//      painter.begin(&midImage);
//      painter.setPen(Qt::NoPen);
//      painter.fillRect(midImage.rect(), slightlyOpaqueBlack);
//      painter.end();

    palette = QPalette(brown);

    palette.setBrush(QPalette::BrightText, Qt::white);
    palette.setBrush(QPalette::Base, beige);
    palette.setBrush(QPalette::Highlight, Qt::darkGreen);
    palette.setBrush(QPalette::Button, beige);
    palette.setBrush(QPalette::ButtonText, Qt::white);
    palette.setBrush(QPalette::Mid, beige);
//	 palette.setBrush(QPalette::Window, QColor(158, 202, 243));
    palette.setBrush(QPalette::Window, beige);

    QBrush brush = palette.background();
    brush.setColor(brush.color().dark());

    palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Text, brush);
    palette.setBrush(QPalette::Disabled, QPalette::ButtonText, Qt::gray);
    palette.setBrush(QPalette::Disabled, QPalette::Base, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Button, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Mid, brush);
}
Пример #3
0
bool Assignment6::init()
{
	/*
	* This function is called by main() when the program is starting up.
	* It should initialize whatever data the assignment requires.
	*/

	if ( !m_scene.init() )
	{
		fprintf(stderr, "Could not initialize scene object\n");
		return false;
	}

	// Create the geometry.
	const int SPHERE_LOC = 0;
	const int OCTAHEDRON_LOC = 1;
	const int PLANE_LOC = 2;

	m_nGeometry = 11;
	m_geometry = new Object::Geometry*[m_nGeometry];
	memset(m_geometry, 0x00, sizeof(Object::Geometry*)*m_nGeometry);

	m_geometry[SPHERE_LOC] = new Object::Models::Sphere();
	if ( !m_geometry[SPHERE_LOC] || !((Object::Models::Sphere*)m_geometry[SPHERE_LOC])->init(3) || isGLError() )
	{
		return false;
	}
	m_geometry[OCTAHEDRON_LOC] = new Object::Models::Octahedron();
	if ( !m_geometry[OCTAHEDRON_LOC] || !((Object::Models::Octahedron*)m_geometry[OCTAHEDRON_LOC])->init() || isGLError())
	{
		return false;
	}
	m_geometry[PLANE_LOC] = new Object::Models::Plane();
	if ( !m_geometry[PLANE_LOC] || !((Object::Models::Plane*)m_geometry[PLANE_LOC])->init() || isGLError())
	{
		return false;
	}



	const float pi2 = (90.0f * M_PI) / 180.0f;

	m_scene.setAmbient(gml::vec3_t(0.0, 0.0, 0.0));
	m_scene.setLightPos(gml::vec4_t(4.5f, 4.5, 0.0 , 1.0));
	m_scene.setLightRad(gml::vec3_t(1.0, 1.0, 1.0));

	m_camera.lookAt(gml::vec3_t(0.0,2.0,3.0), gml::vec3_t(0.0,0.0,0.0) );
	m_camera.setDepthClip(0.5f, 30.0f);

	Material::Material mat;

	mat.setShaderType(Material::PHONG);

	gml::vec3_t beige(0.76, 0.75, 0.5);
	gml::vec3_t red(0.63, 0.06, 0.04);
	gml::vec3_t green(0.15, 0.48, 0.09);

	mat.setSpecExp(-1.0f); // turn off specular

	mat.setSurfReflectance(beige);
	// Ground plane
	mat.setTexture(0);
	m_scene.addObject(new Object::Object(m_geometry[PLANE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(0.0,0.0,0.0)), gml::scaleh(5.0, 1.0, 5.0)) ) );


	gml::mat4x4_t rotScale = gml::mul( gml::rotateYh((25.0f * M_PI)/180.0), gml::scaleh(0.5,0.5,0.5) );
	// Some other objects
	mat.setSurfReflectance(beige);

/*
	m_scene.addObject(new Object::Object(m_geometry[OCTAHEDRON_LOC], mat,
	gml::mul(gml::translate(gml::vec3_t(0.0,0.75,0.0)), rotScale)) );
*/
	// "Box" walls
	mat.setSurfReflectance(green);
	m_scene.addObject(new Object::Object(m_geometry[PLANE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(5.0,2.5,0.0)), gml::mul(gml::rotateZh(pi2),gml::scaleh(2.5, 1.0, 5.0))) ) );
	m_scene.addObject(new Object::Object(m_geometry[PLANE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(-5.0,2.5,0.0)), gml::mul(gml::rotateZh(-pi2),gml::scaleh(2.5, 1.0, 5.0))) ));
	mat.setSurfReflectance(red);
//	m_scene.addObject(new Object::Object(m_geometry[PLANE_LOC], mat,
//		gml::mul(gml::translate(gml::vec3_t(0.0,2.5,5.0)), gml::mul(gml::rotateXh(-pi2),gml::scaleh(5.0, 1.0, 2.5))) ));
	m_scene.addObject(new Object::Object(m_geometry[PLANE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(0.0,2.5,-5.0)), gml::mul(gml::rotateXh(pi2),gml::scaleh(5.0, 1.0, 2.5))) ));
	

	mat.setSpecExp(10.5f);
	mat.setSurfReflectance(gml::vec3_t(0.2,1.0,0.0));
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(0.0,0.75,-2.0)), rotScale)) );

	mat.setSpecExp(10.5f);
	mat.setSurfReflectance(gml::vec3_t(0.8,1.0,0.0));
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(2.0,0.75,-2.0)), rotScale)) );
	mat.setSpecExp(10.5f);

	mat.setSurfReflectance(gml::vec3_t(1.0,0.0,1.0));
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(3.0,0.75,-2.0)), rotScale)) );
	mat.setSpecExp(10.5f);

	mat.setSurfReflectance(gml::vec3_t(1.0,0.0,0.2));
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(-1.0,0.75,-2.0)), rotScale)) );
	mat.setSpecExp(10.5f);

	mat.setSurfReflectance(gml::vec3_t(0.4,1.0,1.0));
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(4.0,0.75,-2.0)), rotScale)) );

	mat.setSpecExp(10.5f);
	mat.setSurfReflectance(gml::vec3_t(1.0,0.0,0.0));
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(-2.0,0.75,-2.0)), rotScale)) );

	mat.setSpecExp(0.0f);
	mat.setShaderType(Material::MIRROR);
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(1.0,0.75,-2.0)), rotScale)) );

	mat.setSurfReflectance(beige);
/*	// Ground plane
	mat.setTexture(0);
	m_scene.addObject(new Object::Object(m_geometry[PLANE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(0.0,0.0,0.0)), gml::scaleh(5.0, 1.0, 5.0)) ) );
	mat.setSpecExp(0.0f);
	mat.setShaderType(Material::MIRROR);
	m_scene.addObject(new Object::Object(m_geometry[SPHERE_LOC], mat,
		gml::mul(gml::translate(gml::vec3_t(-2.0,0.75,-2.0)), rotScale)) );
*/
	// =============================================================================================

	if ( !m_shadowmap.init(m_shadowmapSize) )
	{
		fprintf(stderr, "Failed to initialize shadow mapping members.\n");
		return false;
	}

	// Ray tracing inits
	if (m_rtFBO) glDeleteFramebuffers(1, &m_rtFBO);
	glGenFramebuffers(1, &m_rtFBO);

	if (m_rtTex) glDeleteTextures(1, &m_rtTex);
	glGenTextures(1, &m_rtTex);

	printf(
		"Camera movement:\n"
		"  [w] -- Camera forward\n"
		"  [s] -- Camera backward\n"
		"  [q] -- Camera up\n"
		"  [e] -- Camera down\n"
		"  [a] -- Camera strafe left\n"
		"  [d] -- Camera strafe right\n"
		"Camera rotation:\n"
		"  [keypad 8] -- Rotate camera up\n"
		"  [keypad 5] -- Rotate camera down\n"
		"  [keypad 4] -- Rotate camera right\n"
		"  [keypad 6] -- Rotate camera left\n"
		"  [keypad 7] -- Spin camera left\n"
		"  [keypad 9] -- Spin camera right\n"
		"Other Controls:\n"
		"  [F1] -- Toggle shadows\n"
		"  [F2] -- Toggle ray tracing\n"
		"  [g] -- Toggle sRGB framebuffer\n"
		"  [f] -- Toggle wireframe rendering\n"
		"  [o] -- Set to orthographic camera\n"
		"  [p] -- Set to perspective camera\n"
		"  [ESC] -- Quit\n"
		);

	return true;
}