glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
free(data);
}
glActiveTexture(GL_TEXTURE0 + slot);
glBindTexture(GL_TEXTURE_2D, this->texture_id);
}*/
+};
+
+class WGradientTexture : public Texture{
+public:
+ WGradientTexture(std::vector<entity*>& tarcol) {
+ std::map<float, Color255> colorMap;
+
+ for (auto && i : tarcol) {
+ colorMap.insert({ i->m_origin.y, kv::tryGetStringValue(i->m_keyvalues, "_light", "128 128 128 255") });
+ }
+
+ // Fill with blank color
+ if (colorMap.size() < 1) {
+ colorMap.insert({ 0.0f, Color255("128 128 128 255") });
+ }
+
+ // Copy first to last
+ if (colorMap.size() < 2) {
+ colorMap.insert({ 949.4342231f , colorMap.begin()->second });
+ }
+
+ std::map<float, Color255>::iterator it_end = colorMap.end();
+ it_end--;
+
+ float dy = it_end->first - colorMap.begin()->first;
+
+ std::map<float, Color255>::iterator it = colorMap.begin();
+ std::map<float, Color255>::iterator it_next = colorMap.begin();
+ it_next++;
+
+ glGenTextures(1, &this->texture_id);
+ unsigned char* data = (unsigned char*)malloc(2048 * 4);
+
+ for (int i = 0; i < 2048; i++) {
+ float pc = (float)i / (float)2048;
+ float absdist = colorMap.begin()->first + (pc * dy);
+
+ if (absdist > it_next->first) {
+ if (it_next != colorMap.end()) {
+ it++;
+ it_next++;
+ }
+ }
+
+ float subpc = remap(absdist, it->first, it_next->first, 0, 1);
+
+ data[i * 4 + 0] = lerpT<float>(it->second.r, it_next->second.r, subpc);
+ data[i * 4 + 1] = lerpT<float>(it->second.g, it_next->second.g, subpc);
+ data[i * 4 + 2] = lerpT<float>(it->second.b, it_next->second.b, subpc);
+ data[i * 4 + 3] = lerpT<float>(it->second.a, it_next->second.a, subpc);
+ }
+
+ glBindTexture(GL_TEXTURE_2D, this->texture_id);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2048, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ free(data);
+ }
};
\ No newline at end of file
{
"editorversion" "400"
"editorbuild" "8075"
- "mapversion" "357"
+ "mapversion" "379"
"formatversion" "100"
"prefab" "0"
}
world
{
"id" "1"
- "mapversion" "357"
+ "mapversion" "379"
"classname" "worldspawn"
"detailmaterial" "detail/detailsprites"
"detailvbsp" "detail.vbsp"
}
}
entity
+{
+ "id" "3061"
+ "classname" "tar_color"
+ "_light" "0 255 0 255"
+ "origin" "-393 -64 48"
+ editor
+ {
+ "color" "220 30 220"
+ "visgroupshown" "1"
+ "visgroupautoshown" "1"
+ "logicalpos" "[0 0]"
+ }
+}
+entity
+{
+ "id" "3159"
+ "classname" "tar_color"
+ "_light" "255 255 0 255"
+ "origin" "-393 -64 208"
+ editor
+ {
+ "color" "220 30 220"
+ "visgroupshown" "1"
+ "visgroupautoshown" "1"
+ "logicalpos" "[0 0]"
+ }
+}
+entity
+{
+ "id" "3165"
+ "classname" "tar_color"
+ "_light" "198 57 149 255"
+ "origin" "-393 -64 224"
+ editor
+ {
+ "color" "220 30 220"
+ "visgroupshown" "1"
+ "visgroupautoshown" "1"
+ "logicalpos" "[0 0]"
+ }
+}
+entity
+{
+ "id" "3004"
+ "classname" "tar_color"
+ "_light" "255 0 0 255"
+ "origin" "-393 -64 80"
+ editor
+ {
+ "color" "220 30 220"
+ "visgroupshown" "1"
+ "visgroupautoshown" "1"
+ "logicalpos" "[0 0]"
+ }
+}
+entity
+{
+ "id" "3026"
+ "classname" "tar_color"
+ "_light" "0 0 255 255"
+ "origin" "-393 -64 104.5"
+ editor
+ {
+ "color" "220 30 220"
+ "visgroupshown" "1"
+ "visgroupautoshown" "1"
+ "logicalpos" "[0 0]"
+ }
+}
+entity
{
"id" "2969"
"classname" "tar_max"
- "origin" "-368.448 -11.867 140.175"
+ "origin" "-368.448 16 128"
editor
{
"color" "127 224 0"
{
"id" "2971"
"classname" "tar_min"
- "origin" "-344.583 -139.156 33"
+ "origin" "-344.583 640 -192"
editor
{
"color" "127 224 0"
"classname" "tar_config"
"aoSize" "1000"
"background" "grid.png"
- "colorScheme" "7"
+ "colorScheme" "-2"
"customCol0" "104 15 15"
"customCol1" "64 166 38"
"customCol2" "44 199 199"
"zColCover2" "85 85 85 170"
"zColObjective" "0 128 255 255"
"zColOutline" "204 204 204 255"
- "origin" "-240 592 33"
+ "origin" "-352 -144 33"
editor
{
"color" "127 224 0"
// Load color scheme gradient
// TODO: Entity based gradients
std::string schemeNum = kv::tryGetStringValue(kvs, "colorScheme", "0");
- if (schemeNum == "-1" || schemeNum == "-2") {
+ if (schemeNum == "-1") {
this->m_texture_gradient = new GradientTexture(
kv::tryGetStringValue(kvs, "customCol0", "39 56 79 255"),
kv::tryGetStringValue(kvs, "customCol1", "77 74 72 255"),
kv::tryGetStringValue(kvs, "customCol2", "178 113 65 255")
);
- } else {
+ }
+ else if (schemeNum == "-2") {
+ // Do thi thening
+ this->m_texture_gradient = new WGradientTexture(v->get_entities_by_classname("tar_color"));
+ }
+ else {
this->m_texture_gradient = new Texture("textures/gradients/gradientmap_" + schemeNum + ".png", true);
}