Created
January 18, 2014 00:03
-
-
Save Yatekii/8484017 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // materialAdjuster.cpp | |
| // raytracer | |
| // | |
| // Created by Noah on 17/01/14. | |
| // Copyright (c) 2014 syx. All rights reserved. | |
| // | |
| #include "materialAdjuster.h" | |
| MaterialAdjuster::MaterialAdjuster(Material &material, std::string title): | |
| material(material), | |
| diffuseColor(ColorAdjuster(material.getDiffuse())), | |
| ambientColor(ColorAdjuster(material.getAmbient())), | |
| specularColor(ColorAdjuster(material.getSpecular())){ | |
| Color diffuse(material.getDiffuse()); | |
| diffuseCanvas = sfg::Canvas::Create(true); | |
| diffuseCanvas->SetRequisition(sf::Vector2f(40,40)); | |
| diffuseCanvas->Clear( sf::Color::Blue, true ); | |
| //sf::Color( diffuse.r * 255, diffuse.g * 255, diffuse.b * 255, 0 ) | |
| Color ambient(material.getAmbient()); | |
| ambientCanvas = sfg::Canvas::Create(true); | |
| ambientCanvas->SetRequisition(sf::Vector2f(40,40)); | |
| ambientCanvas->Clear( sf::Color( ambient.r * 255, ambient.g * 255, ambient.b * 255, 255 ), true ); | |
| Color specular(material.getSpecular()); | |
| specularCanvas = sfg::Canvas::Create(true); | |
| specularCanvas->SetRequisition(sf::Vector2f(40,40)); | |
| specularCanvas->Clear( sf::Color( specular.r * 255, specular.g * 255, specular.b * 255, 255 ), true ); | |
| table = sfg::Table::Create(); | |
| table->SetRowSpacings( 5.f ); | |
| table->SetColumnSpacings( 5.f ); | |
| table->Attach(diffuseCanvas, sf::Rect<sf::Uint32>( 0, 0, 1, 1 )); | |
| table->Attach(ambientCanvas, sf::Rect<sf::Uint32>( 0, 1, 1, 1 )); | |
| table->Attach(specularCanvas, sf::Rect<sf::Uint32>( 0, 2, 1, 1 )); | |
| table->Attach(diffuseColor.getTable(), sf::Rect<sf::Uint32>( 1, 0, 1, 2 ), sfg::Table::FILL, sfg::Table::FILL ); | |
| table->SetRequisition(sf::Vector2f(280,10)); | |
| window = sfg::Window::Create(); | |
| window->SetTitle(title); | |
| window->Add(table); | |
| window->SetRequisition(sf::Vector2f(10,10)); | |
| } | |
| std::shared_ptr<sfg::Window> MaterialAdjuster::getWindow(){ | |
| return window; | |
| } | |
| void MaterialAdjuster::update(){ | |
| diffuseColor.update(); | |
| ambientColor.update(); | |
| specularColor.update(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment