From 1d518a54914531d7a4fab3a6835b75de85bd7bc7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 9 Jul 2014 19:18:31 +0000 Subject: Initial support for multi-layered materials, requires shaders files in the new format. --- src/model/mapfile.cc | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'src/model/mapfile.cc') diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index b78448c..49122d5 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -382,13 +382,8 @@ bool MapFile::read_patchdef() } } - // find the material for this patch - Material *material = Material::find("textures/" + materialname); - if (!material) { - material = new Material("textures/" + materialname); - Material::add(material); - material->set_texture(material->name()); - } + // load the material for this patch + Material *material = Material::load("textures/" + materialname); // find the primitives for the current material, // allocate a new one if necessary @@ -707,13 +702,7 @@ bool MapFile::getline() linestream >> texture; aux::to_lowercase(texture); - Material *material = Material::find("textures/" + texture); - if (!material) { - material = new Material("textures/" + texture); - Material::add(material); - //material->set_flags(Material::Texture); - material->set_texture(material->name()); - } + Material *material = Material::load("textures/" + texture); face->set_material(material); // texture alignment @@ -998,12 +987,10 @@ void MapFile::make_brushface(Face *face) Quad *quad = new Quad(*(*vn2) * SCALE, *(*vn1) * SCALE, *(*vn) * SCALE, *(*v0) * SCALE, face_normal, face->detail()); primitives->add_quad(quad); - if (face->material()->has_flag_texture()) { - quad->t0().assign(map_texture_coords(face, *(*vn2))); - quad->t1().assign(map_texture_coords(face, *(*vn1))); - quad->t2().assign(map_texture_coords(face, *(*vn))); - quad->t3().assign(map_texture_coords(face, *(*v0))); - } + quad->t0().assign(map_texture_coords(face, *(*vn2))); + quad->t1().assign(map_texture_coords(face, *(*vn1))); + quad->t2().assign(map_texture_coords(face, *(*vn))); + quad->t3().assign(map_texture_coords(face, *(*v0))); delete(*vn); delete(*vn1); @@ -1022,11 +1009,9 @@ void MapFile::make_brushface(Face *face) Triangle * triangle = new Triangle(*(*vn1) * SCALE, *(*vn) * SCALE, *(*v0) * SCALE, face_normal, face->detail()); primitives->add_triangle(triangle); - if (face->material()->has_flag_texture()) { - triangle->t0().assign(map_texture_coords(face, *(*vn1))); - triangle->t1().assign(map_texture_coords(face, *(*vn))); - triangle->t2().assign(map_texture_coords(face, *(*v0))); - } + triangle->t0().assign(map_texture_coords(face, *(*vn1))); + triangle->t1().assign(map_texture_coords(face, *(*vn))); + triangle->t2().assign(map_texture_coords(face, *(*v0))); delete(*vn); vl.pop_back(); -- cgit v1.2.3