mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-25 16:14:20 +00:00
feat: raw terrain parsing for scene data
Replace old dNavigation/dTerrain raw parser with new Raw module in dZoneManager. Parse heightmaps, color maps, and scene maps from .raw files to determine which scene a position belongs to. Build scene adjacency graph from terrain data and scene transitions. Adds NiColor type, SceneColor lookup table, eSceneType enum, terrain mesh generation with OBJ export, and debug slash commands for scene visualization. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
dCommon/NiColor.h
Normal file
34
dCommon/NiColor.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef NICOLOR_H
|
||||
#define NICOLOR_H
|
||||
|
||||
struct NiColor {
|
||||
float m_Red;
|
||||
float m_Green;
|
||||
float m_Blue;
|
||||
|
||||
constexpr NiColor(float red, float green, float blue) : m_Red(red), m_Green(green), m_Blue(blue) {}
|
||||
constexpr NiColor() : NiColor(0.0f, 0.0f, 0.0f) {}
|
||||
|
||||
/* reduce RGB files to grayscale, with or without alpha
|
||||
* using the equation given in Poynton's ColorFAQ at
|
||||
* <http://www.inforamp.net/~poynton/> // dead link
|
||||
* Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net
|
||||
*
|
||||
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
|
||||
*
|
||||
* We approximate this with
|
||||
*
|
||||
* Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
|
||||
*
|
||||
* which can be expressed with integers as
|
||||
*
|
||||
* Y = (6969 * R + 23434 * G + 2365 * B)/32768
|
||||
*
|
||||
* The calculation is to be done in a linear colorspace.
|
||||
*
|
||||
* Other integer coefficents can be used via png_set_rgb_to_gray().
|
||||
*/
|
||||
float ToXYZ() const { return (m_Red * 0.212671f) + (m_Green * 0.71516f) + (m_Blue * 0.072169f); };
|
||||
};
|
||||
|
||||
#endif // NICOLOR_H
|
||||
166
dCommon/dClient/SceneColor.h
Normal file
166
dCommon/dClient/SceneColor.h
Normal file
@@ -0,0 +1,166 @@
|
||||
#ifndef SCENE_COLOR_H
|
||||
#define SCENE_COLOR_H
|
||||
|
||||
#include "NiColor.h"
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
namespace SceneColor {
|
||||
// these are not random values, they are the actual template colors used by the game
|
||||
static constexpr std::array<NiColor, 146> TEMPLATE_COLORS = {{
|
||||
{ 0.5019608f, 0.5019608f, 0.5019608f },
|
||||
{ 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f },
|
||||
{ 1.0f, 0.0f, 1.0f },
|
||||
{ 0.0f, 1.0f, 1.0f },
|
||||
{ 0.5019608f, 0.0f, 1.0f },
|
||||
{ 1.0f, 0.5019608f, 0.0f },
|
||||
{ 1.0f, 0.5019608f, 0.5019608f },
|
||||
{ 0.5019608f, 0.2509804f, 0.0f },
|
||||
{ 0.5019608f, 0.0f, 0.2509804f },
|
||||
{ 0.0f, 0.5019608f, 0.2509804f },
|
||||
{ 0.2509804f, 0.0f, 0.5019608f },
|
||||
{ 0.8745098f, 0.0f, 0.2509804f },
|
||||
{ 0.2509804f, 0.8745098f, 0.5019608f },
|
||||
{ 1.0f, 0.7490196f, 0.0f },
|
||||
{ 1.0f, 0.2509804f, 0.0627451f },
|
||||
{ 0.2509804f, 0.0f, 0.8745098f },
|
||||
{ 0.7490196f, 0.0627451f, 0.0627451f },
|
||||
{ 0.0627451f, 0.7490196f, 0.0627451f },
|
||||
{ 1.0f, 0.5019608f, 1.0f },
|
||||
{ 0.9372549f, 0.8705882f, 0.8039216f },
|
||||
{ 0.8039216f, 0.5843138f, 0.4588235f },
|
||||
{ 0.9921569f, 0.8509804f, 0.7098039f },
|
||||
{ 0.4705882f, 0.8588235f, 0.8862745f },
|
||||
{ 0.5294118f, 0.6627451f, 0.4196078f },
|
||||
{ 1.0f, 0.6431373f, 0.454902f },
|
||||
{ 0.9803922f, 0.9058824f, 0.7098039f },
|
||||
{ 0.6235294f, 0.5058824f, 0.4392157f },
|
||||
{ 0.9921569f, 0.4862745f, 0.4313726f },
|
||||
{ 0.0f, 0.0f, 0.0f },
|
||||
{ 0.6745098f, 0.8980392f, 0.9333333f },
|
||||
{ 0.1215686f, 0.4588235f, 0.9960784f },
|
||||
{ 0.6352941f, 0.6352941f, 0.8156863f },
|
||||
{ 0.4f, 0.6f, 0.8f },
|
||||
{ 0.05098039f, 0.5960785f, 0.7294118f },
|
||||
{ 0.4509804f, 0.4f, 0.7411765f },
|
||||
{ 0.8705882f, 0.3647059f, 0.5137255f },
|
||||
{ 0.7960784f, 0.254902f, 0.3294118f },
|
||||
{ 0.7058824f, 0.4039216f, 0.3019608f },
|
||||
{ 1.0f, 0.4980392f, 0.2862745f },
|
||||
{ 0.9176471f, 0.4941176f, 0.3647059f },
|
||||
{ 0.6901961f, 0.7176471f, 0.7764706f },
|
||||
{ 1.0f, 1.0f, 0.6f },
|
||||
{ 0.1098039f, 0.827451f, 0.6352941f },
|
||||
{ 1.0f, 0.6666667f, 0.8f },
|
||||
{ 0.8666667f, 0.2666667f, 0.572549f },
|
||||
{ 0.1137255f, 0.6745098f, 0.8392157f },
|
||||
{ 0.7372549f, 0.3647059f, 0.345098f },
|
||||
{ 0.8666667f, 0.5803922f, 0.4588235f },
|
||||
{ 0.6039216f, 0.8078431f, 0.9215686f },
|
||||
{ 1.0f, 0.7372549f, 0.8509804f },
|
||||
{ 0.9921569f, 0.8588235f, 0.427451f },
|
||||
{ 0.1686275f, 0.4235294f, 0.7686275f },
|
||||
{ 0.9372549f, 0.8039216f, 0.7215686f },
|
||||
{ 0.4313726f, 0.3176471f, 0.3764706f },
|
||||
{ 0.8078431f, 1.0f, 0.1137255f },
|
||||
{ 0.427451f, 0.682353f, 0.5058824f },
|
||||
{ 0.7647059f, 0.3921569f, 0.772549f },
|
||||
{ 0.8f, 0.4f, 0.4f },
|
||||
{ 0.9058824f, 0.7764706f, 0.5921569f },
|
||||
{ 0.9882353f, 0.8509804f, 0.4588235f },
|
||||
{ 0.6588235f, 0.8941177f, 0.627451f },
|
||||
{ 0.5843138f, 0.5686275f, 0.5490196f },
|
||||
{ 0.1098039f, 0.6745098f, 0.4705882f },
|
||||
{ 0.06666667f, 0.3921569f, 0.7058824f },
|
||||
{ 0.9411765f, 0.9098039f, 0.5686275f },
|
||||
{ 1.0f, 0.1137255f, 0.8078431f },
|
||||
{ 0.6980392f, 0.9254902f, 0.3647059f },
|
||||
{ 0.3647059f, 0.4627451f, 0.7960784f },
|
||||
{ 0.7921569f, 0.2156863f, 0.4039216f },
|
||||
{ 0.2313726f, 0.6901961f, 0.5607843f },
|
||||
{ 0.9882353f, 0.7058824f, 0.8352941f },
|
||||
{ 1.0f, 0.9568627f, 0.3098039f },
|
||||
{ 1.0f, 0.7411765f, 0.5333334f },
|
||||
{ 0.9647059f, 0.3921569f, 0.6862745f },
|
||||
{ 0.6666667f, 0.9411765f, 0.8196079f },
|
||||
{ 0.8039216f, 0.2901961f, 0.2980392f },
|
||||
{ 0.9294118f, 0.8196079f, 0.6117647f },
|
||||
{ 0.5921569f, 0.6039216f, 0.6666667f },
|
||||
{ 0.7843137f, 0.2196078f, 0.3529412f },
|
||||
{ 0.9372549f, 0.5960785f, 0.6666667f },
|
||||
{ 0.9921569f, 0.7372549f, 0.7058824f },
|
||||
{ 0.1019608f, 0.282353f, 0.4627451f },
|
||||
{ 0.1882353f, 0.7294118f, 0.5607843f },
|
||||
{ 0.772549f, 0.2941177f, 0.5490196f },
|
||||
{ 0.09803922f, 0.454902f, 0.8235294f },
|
||||
{ 0.7294118f, 0.7215686f, 0.4235294f },
|
||||
{ 1.0f, 0.4588235f, 0.2196078f },
|
||||
{ 1.0f, 0.1686275f, 0.1686275f },
|
||||
{ 0.972549f, 0.8352941f, 0.4078431f },
|
||||
{ 0.9019608f, 0.6588235f, 0.8431373f },
|
||||
{ 0.254902f, 0.2901961f, 0.2980392f },
|
||||
{ 1.0f, 0.4313726f, 0.2901961f },
|
||||
{ 0.1098039f, 0.6627451f, 0.7882353f },
|
||||
{ 1.0f, 0.8117647f, 0.6705883f },
|
||||
{ 0.772549f, 0.8156863f, 0.9019608f },
|
||||
{ 0.9921569f, 0.8666667f, 0.9019608f },
|
||||
{ 0.08235294f, 0.5019608f, 0.4705882f },
|
||||
{ 0.9882353f, 0.454902f, 0.9921569f },
|
||||
{ 0.9686275f, 0.5607843f, 0.654902f },
|
||||
{ 0.5568628f, 0.2705882f, 0.5215687f },
|
||||
{ 0.454902f, 0.2588235f, 0.7843137f },
|
||||
{ 0.6156863f, 0.5058824f, 0.7294118f },
|
||||
{ 1.0f, 0.2862745f, 0.4235294f },
|
||||
{ 0.8392157f, 0.5411765f, 0.3490196f },
|
||||
{ 0.4431373f, 0.2941177f, 0.1372549f },
|
||||
{ 1.0f, 0.282353f, 0.8156863f },
|
||||
{ 0.9333333f, 0.1254902f, 0.3019608f },
|
||||
{ 1.0f, 0.3254902f, 0.2862745f },
|
||||
{ 0.7529412f, 0.2666667f, 0.5607843f },
|
||||
{ 0.1215686f, 0.8078431f, 0.7960784f },
|
||||
{ 0.4705882f, 0.3176471f, 0.6627451f },
|
||||
{ 1.0f, 0.6078432f, 0.6666667f },
|
||||
{ 0.9882353f, 0.1568628f, 0.2784314f },
|
||||
{ 0.4627451f, 1.0f, 0.4784314f },
|
||||
{ 0.6235294f, 0.8862745f, 0.7490196f },
|
||||
{ 0.6470588f, 0.4117647f, 0.3098039f },
|
||||
{ 0.5411765f, 0.4745098f, 0.3647059f },
|
||||
{ 0.2705882f, 0.8078431f, 0.6352941f },
|
||||
{ 0.8039216f, 0.772549f, 0.7607843f },
|
||||
{ 0.5019608f, 0.854902f, 0.9215686f },
|
||||
{ 0.9254902f, 0.9176471f, 0.7450981f },
|
||||
{ 1.0f, 0.8117647f, 0.282353f },
|
||||
{ 0.9921569f, 0.3686275f, 0.3254902f },
|
||||
{ 0.9803922f, 0.654902f, 0.4235294f },
|
||||
{ 0.09411765f, 0.654902f, 0.7098039f },
|
||||
{ 0.9215686f, 0.7803922f, 0.8745098f },
|
||||
{ 0.9882353f, 0.5372549f, 0.6745098f },
|
||||
{ 0.8588235f, 0.8431373f, 0.8235294f },
|
||||
{ 0.8705882f, 0.6666667f, 0.5333334f },
|
||||
{ 0.4666667f, 0.8666667f, 0.9058824f },
|
||||
{ 1.0f, 1.0f, 0.4f },
|
||||
{ 0.572549f, 0.4313726f, 0.682353f },
|
||||
{ 0.1960784f, 0.2901961f, 0.6980392f },
|
||||
{ 0.9686275f, 0.3254902f, 0.5803922f },
|
||||
{ 1.0f, 0.627451f, 0.5372549f },
|
||||
{ 0.5607843f, 0.3137255f, 0.6156863f },
|
||||
{ 1.0f, 1.0f, 1.0f },
|
||||
{ 0.6352941f, 0.6784314f, 0.8156863f },
|
||||
{ 0.9882353f, 0.4235294f, 0.5215687f },
|
||||
{ 0.8039216f, 0.6431373f, 0.8705882f },
|
||||
{ 0.9882353f, 0.9098039f, 0.5137255f },
|
||||
{ 0.772549f, 0.8901961f, 0.5176471f },
|
||||
{ 1.0f, 0.682353f, 0.2588235f },
|
||||
}};
|
||||
|
||||
static constexpr NiColor FALLBACK_COLOR{ 1.0f, 1.0f, 1.0f };
|
||||
|
||||
inline const NiColor& Get(uint8_t index) {
|
||||
return (index < TEMPLATE_COLORS.size()) ? TEMPLATE_COLORS[index] : FALLBACK_COLOR;
|
||||
}
|
||||
} // namespace SceneColor
|
||||
|
||||
#endif // SCENE_COLOR_H
|
||||
Reference in New Issue
Block a user