From 18dc1f6d0e044e5e4b1f3a40fcc65e532ec2e765 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 28 Sep 2013 12:13:29 +0000 Subject: Cleanup of the material API: split flags into flags and colortype. --- src/model/material.cc | 85 +++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 37 deletions(-) (limited to 'src/model/material.cc') diff --git a/src/model/material.cc b/src/model/material.cc index ff9a257..5a99489 100644 --- a/src/model/material.cc +++ b/src/model/material.cc @@ -26,6 +26,7 @@ Material::Material(const std::string &name) : { aux::to_lowercase(material_name); material_flags = 0; + material_colortype = ColorMaterial; material_texture_id = 0; } @@ -37,43 +38,47 @@ Material::~Material() void Material::print() { con_print << name() << std::endl; - con_print << " color: " << material_color.r << " " << material_color.g << " " << material_color.b << " " << material_color.a << std::endl; - con_print << " flags: " << flags() << " "; - if (flags() == None) { + + con_print << " material color: " << material_color.r << " " << material_color.g << " " << material_color.b << " " << material_color.a << std::endl; + switch (colortype()) { + case ColorMaterial: + break; + case ColorPrimary: + con_print << " color type " << "entity primary" << std::endl; + break; + case ColorSecondary: + con_print << " color type " << "entity secondary" << std::endl; + break; + case ColorTertiary: + con_print << " color type " << "entity tertiary" << std::endl; + break; + case ColorEngine: + con_print << " color type " << "entity engine" << std::endl; + break; + } + con_print << " flags: " << flags() << " "; + if (flags() == FlagNone) { con_print << "none"; } else { - if ((flags() & Tertiary) == Tertiary) { - con_print << "entitythird "; - - } else if (flags() & Secondary) { - con_print << "entitysecond "; - - } else if (flags() & Primary) { - con_print << "entity "; - } - - if (flags() & Bright) { + if (flags() & FlagBright) { con_print << "bright "; } - if (flags() & Engine) { - con_print << "engine "; - } - if (flags() & Environment) { + if (flags() & FlagEnvironment) { con_print << "environment "; } - if (flags() & Texture) { + if (flags() & FlagTexture) { con_print << "texture "; } - if (flags() & Ignore) { + if (flags() & FlagIgnore) { con_print << "ignore "; } - if (flags() & Clip) { + if (flags() & FlagClip) { con_print << "clip "; } - if (flags() & Origin) { + if (flags() & FlagOrigin) { con_print << "origin "; } - if (flags() & Decal) { + if (flags() & FlagDecal) { con_print << "decal "; } } @@ -99,13 +104,13 @@ void Material::set_specular(const math::Color &color) void Material::set_texture(const std::string &texture) { if (texture.size()) { - set_flags(Texture); + set_flags(FlagTexture); material_texture.assign(texture); if (material_loaderfunc) { material_loaderfunc(this); } } else { - unset_flags(Texture); + unset_flags(FlagTexture); material_texture.clear(); material_texture_id = 0; } @@ -126,6 +131,11 @@ void Material::set_size(const math::Vector2f &size) material_size.assign(size); } +void Material::set_colortype(ColorType colortype) +{ + material_colortype = colortype; +} + void Material::init() { con_print << "^BInitializing materials..." << std::endl; @@ -249,25 +259,26 @@ void Material::load_shader(const std::string &shadername) material->set_specular(math::Color(r, g, b, a)); } } else if (firstword.compare("engine") == 0) { - material->set_flags(Engine); - } else if (firstword.compare("bright") == 0) { - material->set_flags(Bright); - } else if (firstword.compare("environment") == 0) { - material->set_flags(Environment); + material->set_colortype(ColorEngine); } else if (firstword.compare("entity") == 0) { - material->set_flags(Primary); + material->set_colortype(ColorPrimary); } else if (firstword.compare("entitysecond") == 0) { - material->set_flags(Secondary); + material->set_colortype(ColorSecondary); } else if (firstword.compare("entitythird") == 0) { - material->set_flags(Tertiary); + material->set_colortype(ColorTertiary); + + } else if (firstword.compare("bright") == 0) { + material->set_flags(FlagBright); + } else if (firstword.compare("environment") == 0) { + material->set_flags(FlagEnvironment); } else if (firstword.compare("ignore") == 0) { - material->set_flags(Ignore); + material->set_flags(FlagIgnore); } else if (firstword.compare("clip") == 0) { - material->set_flags(Clip); + material->set_flags(FlagClip); } else if (firstword.compare("origin") == 0) { - material->set_flags(Origin); + material->set_flags(FlagOrigin); } else if (firstword.compare("decal") == 0) { - material->set_flags(Decal); + material->set_flags(FlagDecal); } else if (firstword.compare("qer_editorimage") == 0) { // keyword qer_editorimage is ignored continue; -- cgit v1.2.3