|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Glew include
|
|
Toshihiro Shimizu |
890ddd |
#include <gl glew.h=""></gl>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmsgcore.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Jeremy Bullock |
1ef2a2 |
#include <qopenglshaderprogram></qopenglshaderprogram>
|
|
Jeremy Bullock |
1ef2a2 |
#include <qopenglshader></qopenglshader>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdir></qdir>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx/shaderinterface.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(ShaderInterface, "ShaderInterface")
|
|
Shinya Kitaoka |
120a6e |
PERSIST_IDENTIFIER(ShaderInterface::ParameterConcept,
|
|
Shinya Kitaoka |
120a6e |
"ShaderInterface::ParameterConcept")
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(ShaderInterface::Parameter, "ShaderInterface::Parameter")
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(ShaderInterface::ShaderData, "ShaderInterface::ShaderData")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Local Namespace stuff
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Filescope declarations
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
typedef std::pair<qopenglshaderprogram *,="" qdatetime=""> CompiledShader;</qopenglshaderprogram>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct CaselessCompare {
|
|
Shinya Kitaoka |
120a6e |
const QString &m_str;
|
|
Shinya Kitaoka |
120a6e |
CaselessCompare(const QString &str) : m_str(str) {}
|
|
Shinya Kitaoka |
120a6e |
bool operator()(const QString &str) const {
|
|
Shinya Kitaoka |
120a6e |
return (m_str.compare(str, Qt::CaseInsensitive) == 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Filescope variables
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const static QString l_typeNames[ShaderInterface::TYPESCOUNT] = {
|
|
Shinya Kitaoka |
120a6e |
"", "bool", "float", "vec2", "vec3", "vec4",
|
|
Shinya Kitaoka |
120a6e |
"int", "ivec2", "ivec3", "ivec4", "rgba", "rgb"};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const static QString l_conceptNames[ShaderInterface::CONCEPTSCOUNT] = {
|
|
Shinya Kitaoka |
120a6e |
"none", "percent", "length", "angle", "point",
|
|
Shinya Kitaoka |
120a6e |
"radius_ui", "width_ui", "angle_ui", "point_ui", "xy_ui",
|
|
Shinya Kitaoka |
120a6e |
"vector_ui", "polar_ui", "size_ui", "quad_ui", "rect_ui"};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const static QString l_hwtNames[ShaderInterface::HWTCOUNT] = {"none", "any",
|
|
Shinya Kitaoka |
120a6e |
"isotropic"};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
enum Names {
|
|
Shinya Kitaoka |
120a6e |
MAIN_PROGRAM,
|
|
Shinya Kitaoka |
120a6e |
INPUT_PORTS,
|
|
Shinya Kitaoka |
120a6e |
INPUT_PORT,
|
|
Shinya Kitaoka |
120a6e |
PORTS_PROGRAM,
|
|
Shinya Kitaoka |
120a6e |
PARAMETERS,
|
|
Shinya Kitaoka |
120a6e |
PARAMETER,
|
|
Shinya Kitaoka |
120a6e |
NAME,
|
|
Shinya Kitaoka |
120a6e |
PROGRAM_FILE,
|
|
Shinya Kitaoka |
120a6e |
CONCEPT,
|
|
Shinya Kitaoka |
120a6e |
DEFAULT_,
|
|
Shinya Kitaoka |
120a6e |
RANGE,
|
|
Shinya Kitaoka |
120a6e |
HANDLED_WORLD_TRANSFORMS,
|
|
Shinya Kitaoka |
120a6e |
BBOX_PROGRAM,
|
|
Shinya Kitaoka |
120a6e |
NAMESCOUNT
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const static std::string l_names[NAMESCOUNT] = {
|
|
Shinya Kitaoka |
120a6e |
"MainProgram", "InputPorts", "InputPort", "PortsProgram",
|
|
Shinya Kitaoka |
120a6e |
"Parameters", "Parameter", "Name", "ProgramFile",
|
|
Shinya Kitaoka |
120a6e |
"Concept", "Default", "Range", "HandledWorldTransforms",
|
|
Shinya Kitaoka |
120a6e |
"BBoxProgram"};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Filescope functions
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
inline bool loadShader(QOpenGLShader::ShaderType type, const TFilePath &fp,
|
|
Shinya Kitaoka |
120a6e |
CompiledShader &cs) {
|
|
Jeremy Bullock |
1ef2a2 |
QOpenGLShader *shader = new QOpenGLShader(type, cs.first);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const QString &qfp = QString::fromStdWString(fp.getWideString());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QFileInfo shaderFileInfo(qfp);
|
|
Shinya Kitaoka |
120a6e |
cs.second = shaderFileInfo.lastModified();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return shader->compileSourceFile(qfp) && cs.first->addShader(shader);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void dumpError(TIStream &is, const std::wstring &err = std::wstring()) {
|
|
Shinya Kitaoka |
120a6e |
DVGui::info("Error reading " +
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(is.getFilePath().getLevelNameW()) +
|
|
Shinya Kitaoka |
120a6e |
" (line " + QString::number(is.getLine()) + ")" +
|
|
Shinya Kitaoka |
120a6e |
(err.empty() ? QString() : QString::fromStdWString(L": " + err)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void skipTag(TIStream &is, const std::string &tagName) {
|
|
Shinya Kitaoka |
120a6e |
DVGui::info("Error reading " +
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(is.getFilePath().getLevelNameW()) +
|
|
Shinya Kitaoka |
120a6e |
" (line " + QString::number(is.getLine()) + "): Unknown tag '<" +
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdString(tagName) + ">'");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
is.skipCurrentTag();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ShaderInterface implementation
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ShaderInterface::ShaderInterface() : m_hwt(ANY) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::clear() {
|
|
Shinya Kitaoka |
120a6e |
m_mainShader = m_portsShader = ShaderData();
|
|
Shinya Kitaoka |
120a6e |
m_parameters.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool ShaderInterface::isValid() const { return m_mainShader.isValid(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const std::vector<shaderinterface::parameter> &ShaderInterface::parameters()</shaderinterface::parameter>
|
|
Shinya Kitaoka |
120a6e |
const {
|
|
Shinya Kitaoka |
120a6e |
return m_parameters;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const std::vector<qstring> &ShaderInterface::inputPorts() const {</qstring>
|
|
Shinya Kitaoka |
120a6e |
return m_ports;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const ShaderInterface::ShaderData &ShaderInterface::mainShader() const {
|
|
Shinya Kitaoka |
120a6e |
return m_mainShader;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const ShaderInterface::ShaderData &ShaderInterface::inputPortsShader() const {
|
|
Shinya Kitaoka |
120a6e |
return m_portsShader;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const ShaderInterface::ShaderData &ShaderInterface::bboxShader() const {
|
|
Shinya Kitaoka |
120a6e |
return m_bboxShader;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ShaderInterface::HandledWorldTransformsType ShaderInterface::hwtType() const {
|
|
Shinya Kitaoka |
120a6e |
return m_hwt;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
std::pair<qopenglshaderprogram *,="" qdatetime=""> ShaderInterface::makeProgram(</qopenglshaderprogram>
|
|
Shinya Kitaoka |
120a6e |
const ShaderData &sd, int varyingsCount,
|
|
Shinya Kitaoka |
120a6e |
const GLchar **varyingNames) const {
|
|
Shinya Kitaoka |
120a6e |
CompiledShader result;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!isValid()) return result;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
result.first = new QOpenGLShaderProgram;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
::loadShader(sd.m_type, sd.m_path, result);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (varyingsCount > 0)
|
|
Shinya Kitaoka |
120a6e |
glTransformFeedbackVaryings(result.first->programId(), varyingsCount,
|
|
Shinya Kitaoka |
120a6e |
varyingNames, GL_INTERLEAVED_ATTRIBS);
|
|
Shinya Kitaoka |
120a6e |
// NOTE: Since we'll be drawing a single vertex, GL_INTERLEAVED_ATTRIBS is
|
|
Shinya Kitaoka |
120a6e |
// less restrictive than GL_SEPARATE_ATTRIBS.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
result.first->link();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return result;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::saveData(TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
struct locals {
|
|
Shinya Kitaoka |
120a6e |
inline static TFilePath getRelativePath(const TFilePath &file,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &relTo) {
|
|
Shinya Kitaoka |
120a6e |
QDir relToDir(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(relTo.getParentDir().getWideString()));
|
|
Shinya Kitaoka |
120a6e |
QString relFileStr(relToDir.relativeFilePath(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(file.getWideString())));
|
|
Shinya Kitaoka |
120a6e |
return TFilePath(relFileStr.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(isValid());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isValid()) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[MAIN_PROGRAM]);
|
|
Shinya Kitaoka |
120a6e |
os << m_mainShader;
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[INPUT_PORTS]);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
int i, iCount = int(m_ports.size());
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i != iCount; ++i) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[INPUT_PORT]);
|
|
Shinya Kitaoka |
120a6e |
os << m_ports[i];
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_portsShader.isValid()) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[PORTS_PROGRAM]);
|
|
Shinya Kitaoka |
120a6e |
os << m_portsShader;
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_bboxShader.isValid()) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[BBOX_PROGRAM]);
|
|
Shinya Kitaoka |
120a6e |
os << m_bboxShader;
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_hwt != ANY) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[HANDLED_WORLD_TRANSFORMS]);
|
|
Shinya Kitaoka |
120a6e |
os << l_names[m_hwt];
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[PARAMETERS]);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
int p, pCount = int(m_parameters.size());
|
|
Shinya Kitaoka |
120a6e |
for (p = 0; p != pCount; ++p) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[PARAMETER]);
|
|
Shinya Kitaoka |
120a6e |
os << m_parameters[p];
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::loadData(TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
struct locals {
|
|
Shinya Kitaoka |
120a6e |
inline static TFilePath getAbsolutePath(const TFilePath &file,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &relTo) {
|
|
Shinya Kitaoka |
120a6e |
QDir relToDir(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(relTo.getParentDir().getWideString()));
|
|
Shinya Kitaoka |
120a6e |
QString absFileStr(relToDir.absoluteFilePath(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(file.getWideString())));
|
|
Shinya Kitaoka |
120a6e |
return TFilePath(absFileStr.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool nameMatch(const QString &name, const Parameter ¶m) {
|
|
Shinya Kitaoka |
120a6e |
return (name == param.m_name);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
while (is.openChild(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == l_names[MAIN_PROGRAM]) {
|
|
Shinya Kitaoka |
120a6e |
is >> m_mainShader;
|
|
Jeremy Bullock |
1ef2a2 |
m_mainShader.m_type = QOpenGLShader::Fragment;
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[INPUT_PORTS]) {
|
|
Shinya Kitaoka |
120a6e |
while (is.openChild(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == l_names[INPUT_PORT]) {
|
|
Shinya Kitaoka |
120a6e |
QString portName;
|
|
Shinya Kitaoka |
120a6e |
is >> portName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_ports.push_back(portName);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[PORTS_PROGRAM]) {
|
|
Shinya Kitaoka |
120a6e |
is >> m_portsShader;
|
|
Jeremy Bullock |
1ef2a2 |
m_portsShader.m_type = QOpenGLShader::Vertex;
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
::skipTag(is, tagName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[BBOX_PROGRAM]) {
|
|
Shinya Kitaoka |
120a6e |
is >> m_bboxShader;
|
|
Jeremy Bullock |
1ef2a2 |
m_bboxShader.m_type = QOpenGLShader::Vertex;
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[HANDLED_WORLD_TRANSFORMS]) {
|
|
Shinya Kitaoka |
120a6e |
QString hwtName;
|
|
Shinya Kitaoka |
120a6e |
is >> hwtName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_hwt = HandledWorldTransformsType(
|
|
Shinya Kitaoka |
120a6e |
std::find_if(l_hwtNames, l_hwtNames + HWTCOUNT,
|
|
Shinya Kitaoka |
120a6e |
::CaselessCompare(hwtName)) -
|
|
Shinya Kitaoka |
120a6e |
l_hwtNames);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_hwt == HWTCOUNT) {
|
|
Shinya Kitaoka |
120a6e |
m_hwt = HWT_UNKNOWN;
|
|
Shinya Kitaoka |
120a6e |
::dumpError(is, L"Unrecognized HandledWorldTransforms type '" +
|
|
Shinya Kitaoka |
120a6e |
hwtName.toStdWString() + L"'");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[PARAMETERS]) {
|
|
Shinya Kitaoka |
120a6e |
while (is.openChild(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == l_names[PARAMETER]) {
|
|
Shinya Kitaoka |
120a6e |
Parameter param;
|
|
Shinya Kitaoka |
120a6e |
is >> param;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_parameters.push_back(param);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
::skipTag(is, tagName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[CONCEPT]) {
|
|
Shinya Kitaoka |
120a6e |
ParameterConcept concept;
|
|
Shinya Kitaoka |
120a6e |
is >> concept;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_parConcepts.push_back(concept);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
::skipTag(is, tagName);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
} catch (const TException &e) {
|
|
Shinya Kitaoka |
120a6e |
::dumpError(is, e.getMessage());
|
|
Shinya Kitaoka |
120a6e |
clear();
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
::dumpError(is);
|
|
Shinya Kitaoka |
120a6e |
clear();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ShaderInterface::ShaderData implementation
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::ShaderData::saveData(TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
struct locals {
|
|
Shinya Kitaoka |
120a6e |
inline static TFilePath getRelativePath(const TFilePath &file,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &relTo) {
|
|
Shinya Kitaoka |
120a6e |
QDir relToDir(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(relTo.getParentDir().getWideString()));
|
|
Shinya Kitaoka |
120a6e |
QString relFileStr(relToDir.relativeFilePath(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(file.getWideString())));
|
|
Shinya Kitaoka |
120a6e |
return TFilePath(relFileStr.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[NAME]);
|
|
Shinya Kitaoka |
120a6e |
os << m_name;
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[PROGRAM_FILE]);
|
|
Shinya Kitaoka |
120a6e |
os << locals::getRelativePath(m_path, os.getFilePath());
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::ShaderData::loadData(TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
struct locals {
|
|
Shinya Kitaoka |
120a6e |
inline static TFilePath getAbsolutePath(const TFilePath &file,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &relTo) {
|
|
Shinya Kitaoka |
120a6e |
QDir relToDir(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(relTo.getParentDir().getWideString()));
|
|
Shinya Kitaoka |
120a6e |
QString absFileStr(relToDir.absoluteFilePath(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(file.getWideString())));
|
|
Shinya Kitaoka |
120a6e |
return TFilePath(absFileStr.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (is.openChild(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == l_names[NAME])
|
|
Shinya Kitaoka |
120a6e |
is >> m_name, is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == l_names[PROGRAM_FILE]) {
|
|
Shinya Kitaoka |
120a6e |
is >> m_path;
|
|
Shinya Kitaoka |
120a6e |
m_path = locals::getAbsolutePath(m_path, is.getFilePath());
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
::skipTag(is, tagName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ShaderInterface::ParameterConcept implementation
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::ParameterConcept::saveData(TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
os << l_conceptNames[m_type];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_label.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[NAME]);
|
|
Shinya Kitaoka |
120a6e |
os << m_label;
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int n, nCount = int(m_parameterNames.size());
|
|
Shinya Kitaoka |
120a6e |
for (n = 0; n != nCount; ++n) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[PARAMETER]);
|
|
Shinya Kitaoka |
120a6e |
os << m_parameterNames[n];
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::ParameterConcept::loadData(TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
// Read the concept type
|
|
Shinya Kitaoka |
120a6e |
QString conceptName;
|
|
Shinya Kitaoka |
120a6e |
is >> conceptName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_type = ParameterConceptType(std::find_if(l_conceptNames,
|
|
Shinya Kitaoka |
120a6e |
l_conceptNames + CONCEPTSCOUNT,
|
|
Shinya Kitaoka |
120a6e |
::CaselessCompare(conceptName)) -
|
|
Shinya Kitaoka |
120a6e |
l_conceptNames);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_type == CONCEPTSCOUNT) {
|
|
Shinya Kitaoka |
120a6e |
m_type = CONCEPT_NONE;
|
|
Shinya Kitaoka |
120a6e |
::dumpError(
|
|
Shinya Kitaoka |
120a6e |
is, L"Unrecognized concept type '" + conceptName.toStdWString() + L"'");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Read any associated parameter names
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (is.openChild(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == l_names[PARAMETER]) {
|
|
Shinya Kitaoka |
120a6e |
QString name;
|
|
Shinya Kitaoka |
120a6e |
is >> name;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_parameterNames.push_back(name);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[NAME])
|
|
Shinya Kitaoka |
120a6e |
is >> m_label, is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
::skipTag(is, tagName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ShaderInterface::Parameter implementation
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::Parameter::saveData(TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
os << l_typeNames[m_type] << m_name;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[CONCEPT]);
|
|
Shinya Kitaoka |
120a6e |
os << m_concept;
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[DEFAULT_]);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (m_type) {
|
|
Shinya Kitaoka |
120a6e |
case BOOL:
|
|
Shinya Kitaoka |
120a6e |
os << (int)m_default.m_bool;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case FLOAT:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_default.m_float;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC2:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_default.m_vec2[0] << (double)m_default.m_vec2[1];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC3:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_default.m_vec3[0] << (double)m_default.m_vec3[1]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_default.m_vec3[2];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC4:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_default.m_vec4[0] << (double)m_default.m_vec4[1]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_default.m_vec4[2] << (double)m_default.m_vec4[3];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case INT:
|
|
Shinya Kitaoka |
120a6e |
os << m_default.m_int;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC2:
|
|
Shinya Kitaoka |
120a6e |
os << m_default.m_ivec2[0] << m_default.m_ivec2[1];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC3:
|
|
Shinya Kitaoka |
120a6e |
os << m_default.m_ivec3[0] << m_default.m_ivec3[1] << m_default.m_ivec3[2];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC4:
|
|
Shinya Kitaoka |
120a6e |
os << m_default.m_ivec4[0] << m_default.m_ivec4[1] << m_default.m_ivec4[2]
|
|
Shinya Kitaoka |
120a6e |
<< m_default.m_ivec4[3];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case RGBA:
|
|
Shinya Kitaoka |
120a6e |
os << (int)m_default.m_rgba[0] << (int)m_default.m_rgba[1]
|
|
Shinya Kitaoka |
120a6e |
<< (int)m_default.m_rgba[2] << (int)m_default.m_rgba[3];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case RGB:
|
|
Shinya Kitaoka |
120a6e |
os << (int)m_default.m_rgb[0] << (int)m_default.m_rgb[1]
|
|
Shinya Kitaoka |
120a6e |
<< (int)m_default.m_rgb[2];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Rozhuk Ivan |
823a31 |
default:
|
|
Rozhuk Ivan |
823a31 |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(l_names[RANGE]);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (m_type) {
|
|
Shinya Kitaoka |
120a6e |
case FLOAT:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_range[0].m_float << (double)m_range[1].m_float;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC2:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_range[0].m_vec2[0] << (double)m_range[1].m_vec2[0]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_range[0].m_vec2[1] << (double)m_range[1].m_vec2[1];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC3:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_range[0].m_vec3[0] << (double)m_range[1].m_vec3[0]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_range[0].m_vec3[1] << (double)m_range[1].m_vec3[1]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_range[0].m_vec3[2] << (double)m_range[1].m_vec3[2];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC4:
|
|
Shinya Kitaoka |
120a6e |
os << (double)m_range[0].m_vec4[0] << (double)m_range[1].m_vec4[0]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_range[0].m_vec4[1] << (double)m_range[1].m_vec4[1]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_range[0].m_vec4[2] << (double)m_range[1].m_vec4[2]
|
|
Shinya Kitaoka |
120a6e |
<< (double)m_range[0].m_vec4[3] << (double)m_range[1].m_vec4[3];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case INT:
|
|
Shinya Kitaoka |
120a6e |
os << m_range[0].m_int << m_range[1].m_int;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC2:
|
|
Shinya Kitaoka |
120a6e |
os << m_range[0].m_ivec2[0] << m_range[1].m_ivec2[0]
|
|
Shinya Kitaoka |
120a6e |
<< m_range[0].m_ivec2[1] << m_range[1].m_ivec2[1];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC3:
|
|
Shinya Kitaoka |
120a6e |
os << m_range[0].m_ivec3[0] << m_range[1].m_ivec3[0]
|
|
Shinya Kitaoka |
120a6e |
<< m_range[0].m_ivec3[1] << m_range[1].m_ivec3[1]
|
|
Shinya Kitaoka |
120a6e |
<< m_range[0].m_ivec3[2] << m_range[1].m_ivec3[2];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC4:
|
|
Shinya Kitaoka |
120a6e |
os << m_range[0].m_ivec4[0] << m_range[1].m_ivec4[0]
|
|
Shinya Kitaoka |
120a6e |
<< m_range[0].m_ivec4[1] << m_range[1].m_ivec4[1]
|
|
Shinya Kitaoka |
120a6e |
<< m_range[0].m_ivec4[2] << m_range[1].m_ivec4[2]
|
|
Shinya Kitaoka |
120a6e |
<< m_range[0].m_ivec4[3] << m_range[1].m_ivec4[3];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Rozhuk Ivan |
823a31 |
default:
|
|
Rozhuk Ivan |
823a31 |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShaderInterface::Parameter::loadData(TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
// Load type and name
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString typeName;
|
|
Shinya Kitaoka |
120a6e |
is >> typeName >> m_name;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_type = ShaderInterface::ParameterType(
|
|
Shinya Kitaoka |
120a6e |
std::find_if(l_typeNames, l_typeNames + TYPESCOUNT,
|
|
Shinya Kitaoka |
120a6e |
::CaselessCompare(typeName)) -
|
|
Shinya Kitaoka |
120a6e |
l_typeNames);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_type == TYPESCOUNT)
|
|
Shinya Kitaoka |
120a6e |
throw TException(L"Unrecognized parameter type '" +
|
|
Shinya Kitaoka |
120a6e |
typeName.toStdWString() + L"'");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Load range
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Initialize default values
|
|
Shinya Kitaoka |
120a6e |
m_concept = ParameterConcept();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (m_type) {
|
|
Shinya Kitaoka |
120a6e |
case BOOL:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_bool = false;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case FLOAT:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_float = 0.0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_float = -(std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_float = (std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC2:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_vec2[0] = m_default.m_vec2[1] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_vec2[0] = m_range[0].m_vec2[1] =
|
|
Shinya Kitaoka |
120a6e |
-(std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_vec2[0] = m_range[1].m_vec2[1] =
|
|
Shinya Kitaoka |
120a6e |
(std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC3:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_vec3[0] = m_default.m_vec3[1] = m_default.m_vec3[1] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_vec3[0] = m_range[0].m_vec3[1] = m_range[0].m_vec3[2] =
|
|
Shinya Kitaoka |
120a6e |
-(std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_vec3[0] = m_range[1].m_vec3[1] = m_range[1].m_vec3[2] =
|
|
Shinya Kitaoka |
120a6e |
(std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case VEC4:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_vec4[0] = m_default.m_vec4[1] = m_default.m_vec4[1] =
|
|
Shinya Kitaoka |
120a6e |
m_default.m_vec4[1] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_vec4[0] = m_range[0].m_vec4[1] = m_range[0].m_vec4[2] =
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_vec4[3] = -(std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_vec4[0] = m_range[1].m_vec4[1] = m_range[1].m_vec4[2] =
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_vec4[3] = (std::numeric_limits<glfloat>::max)();</glfloat>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case INT:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_int = 0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_int = -(std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_int = (std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC2:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_ivec2[0] = m_default.m_ivec2[1] = 0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec2[0] = m_range[0].m_ivec2[1] =
|
|
Shinya Kitaoka |
120a6e |
-(std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_ivec2[0] = m_range[1].m_ivec2[1] =
|
|
Shinya Kitaoka |
120a6e |
(std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC3:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_ivec3[0] = m_default.m_ivec3[1] = m_default.m_ivec3[1] = 0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec3[0] = m_range[0].m_ivec3[1] = m_range[0].m_ivec3[2] =
|
|
Shinya Kitaoka |
120a6e |
-(std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_ivec3[0] = m_range[1].m_ivec3[1] = m_range[1].m_ivec3[2] =
|
|
Shinya Kitaoka |
120a6e |
(std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case IVEC4:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_ivec4[0] = m_default.m_ivec4[1] = m_default.m_ivec4[1] =
|
|
Shinya Kitaoka |
120a6e |
m_default.m_ivec4[1] = 0;
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec4[0] = m_range[0].m_ivec4[1] = m_range[0].m_ivec4[2] =
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec4[3] = -(std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_ivec4[0] = m_range[1].m_ivec4[1] = m_range[1].m_ivec4[2] =
|
|
Shinya Kitaoka |
120a6e |
m_range[1].m_ivec4[3] = (std::numeric_limits<glint>::max)();</glint>
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case RGBA:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_rgba[0] = m_default.m_rgba[1] = m_default.m_rgba[2] =
|
|
Shinya Kitaoka |
120a6e |
m_default.m_rgba[3] = 255;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case RGB:
|
|
Shinya Kitaoka |
120a6e |
m_default.m_rgb[0] = m_default.m_rgb[1] = m_default.m_rgb[2] = 255;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Rozhuk Ivan |
823a31 |
default:
|
|
Rozhuk Ivan |
823a31 |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Attempt loading range from file
|
|
Shinya Kitaoka |
120a6e |
while (is.openChild(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == l_names[CONCEPT])
|
|
Shinya Kitaoka |
120a6e |
is >> m_concept, is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == l_names[DEFAULT_]) {
|
|
Shinya Kitaoka |
120a6e |
switch (m_type) {
|
|
Shinya Kitaoka |
120a6e |
case BOOL: {
|
|
Shinya Kitaoka |
120a6e |
int val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_bool = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case FLOAT: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_float = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case VEC2: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec2[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec2[1] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case VEC3: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec3[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec3[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec3[2] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case VEC4: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec4[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec4[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec4[2] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_vec4[3] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case INT:
|
|
Shinya Kitaoka |
120a6e |
is >> m_default.m_int;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case IVEC2:
|
|
Shinya Kitaoka |
120a6e |
is >> m_default.m_ivec2[0] >> m_default.m_ivec2[1];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case IVEC3:
|
|
Shinya Kitaoka |
120a6e |
is >> m_default.m_ivec3[0] >> m_default.m_ivec3[1] >>
|
|
Shinya Kitaoka |
120a6e |
m_default.m_ivec3[2];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case IVEC4:
|
|
Shinya Kitaoka |
120a6e |
is >> m_default.m_ivec4[0] >> m_default.m_ivec4[1] >>
|
|
Shinya Kitaoka |
120a6e |
m_default.m_ivec4[2] >> m_default.m_ivec4[3];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case RGBA: {
|
|
Shinya Kitaoka |
120a6e |
int val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_rgba[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_rgba[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_rgba[2] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_rgba[3] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case RGB: {
|
|
Shinya Kitaoka |
120a6e |
int val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_rgb[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_rgb[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_default.m_rgb[2] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Rozhuk Ivan |
823a31 |
default:
|
|
Rozhuk Ivan |
823a31 |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == l_names[RANGE]) {
|
|
Shinya Kitaoka |
120a6e |
switch (m_type) {
|
|
Shinya Kitaoka |
120a6e |
case FLOAT: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_float = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_float = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case VEC2: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec2[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec2[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec2[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec2[1] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case VEC3: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec3[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec3[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec3[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec3[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec3[2] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec3[2] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case VEC4: {
|
|
Shinya Kitaoka |
120a6e |
double val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec4[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec4[0] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec4[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec4[1] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec4[2] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec4[2] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[0].m_vec4[3] = val;
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_range[1].m_vec4[3] = val;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case INT:
|
|
Shinya Kitaoka |
120a6e |
is >> m_range[0].m_int >> m_range[1].m_int;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case IVEC2:
|
|
Shinya Kitaoka |
120a6e |
is >> m_range[0].m_ivec2[0] >> m_range[1].m_ivec2[0] >>
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec2[1] >> m_range[1].m_ivec2[1];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case IVEC3:
|
|
Shinya Kitaoka |
120a6e |
is >> m_range[0].m_ivec3[0] >> m_range[1].m_ivec3[0] >>
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec3[1] >> m_range[1].m_ivec3[1] >>
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec3[2] >> m_range[1].m_ivec3[2];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case IVEC4:
|
|
Shinya Kitaoka |
120a6e |
is >> m_range[0].m_ivec4[0] >> m_range[1].m_ivec4[0] >>
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec4[1] >> m_range[1].m_ivec4[1] >>
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec4[2] >> m_range[1].m_ivec4[2] >>
|
|
Shinya Kitaoka |
120a6e |
m_range[0].m_ivec4[3] >> m_range[1].m_ivec4[3];
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Rozhuk Ivan |
823a31 |
default:
|
|
Rozhuk Ivan |
823a31 |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.closeChild();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
::skipTag(is, tagName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Post-process loaded data
|
|
Shinya Kitaoka |
120a6e |
if (m_concept.m_label.isEmpty()) m_concept.m_label = m_name;
|
|
Toshihiro Shimizu |
890ddd |
}
|