~connorbell/ShaderChain

f2df01bce6663313d514db5f48ad121142abc548 — Connor Bell 4 years ago a948ffa + 450a952
Merge branch 'master' of git.sr.ht:~connorbell/ShaderChain
M src/Parameters/CameraParameter.cpp => src/Parameters/CameraParameter.cpp +15 -7
@@ 5,7 5,14 @@ CameraParameter::CameraParameter(glm::vec3 pos, glm::vec3 rot, float sens) {
    this->uniform = "camera";
    this->camera.setPosition(pos);
    this->camera.setOrientation(rot);
    glm::vec3 r = camera.getOrientationEulerDeg();
    this->movementSensitivity = sens;
}

CameraParameter::CameraParameter(glm::vec3 pos, glm::quat rot, float sens) {
    this->uniform = "camera";
    this->camera.setPosition(pos);
    cout << rot.x << " " << rot.y << " " << rot.z << " " << rot.w << endl;
    this->camera.setOrientation(rot);
    this->movementSensitivity = sens;
}



@@ 42,8 49,6 @@ void CameraParameter::UpdateShader(ofxAutoReloadedShader *shader, RenderStruct *
    shader->setUniform3f("_CamForward", camera.getZAxis());
    shader->setUniform3f("_CamUp", camera.getYAxis());
    shader->setUniform3f("_CamRight", camera.getXAxis());

    cout << "Updated camera params" << endl;
}

void CameraParameter::AddToGui(ofxGuiGroup2 *gui) {


@@ 57,10 62,13 @@ void CameraParameter::UpdateJson(Json::Value &val) {
    val["value"]["pos"]["y"] = camera.getY();
    val["value"]["pos"]["z"] = camera.getZ();

    glm::vec3 rot = camera.getOrientationEulerDeg();
    val["value"]["rot"]["x"] = rot.x;
    val["value"]["rot"]["y"] = rot.y;
    val["value"]["rot"]["z"] = rot.z;
    glm::quat q = camera.getOrientationQuat();
    cout << "saving " << q.x << " " << q.y << " " << q.z << " " << q.w << endl;

    val["value"]["rot"]["qx"] = q.x;
    val["value"]["rot"]["qy"] = q.y;
    val["value"]["rot"]["qz"] = q.z;
    val["value"]["rot"]["qw"] = q.w;

    val["type"] = "camera";
    val["movementSensitivity"] = (float)movementSensitivity;

M src/Parameters/CameraParameter.h => src/Parameters/CameraParameter.h +2 -0
@@ 8,6 8,8 @@ class CameraParameter : public Parameter {
public:

    CameraParameter(glm::vec3 pos, glm::vec3 rot, float sens);
    CameraParameter(glm::vec3 pos, glm::quat rot, float sens);

    ~CameraParameter();
    ofParameter<ofVec3f> position;
    ofVec3f left;

M src/ShaderPass.cpp => src/ShaderPass.cpp +21 -7
@@ 72,6 72,11 @@ void ShaderPass::addCameraParameter(glm::vec3 pos, glm::vec3 rot, float sens) {
    this->params.push_back(std::move(ptr));
}

void ShaderPass::addCameraParameter(glm::vec3 pos, glm::quat rot, float sens) {
    auto ptr = std::make_unique<CameraParameter>(pos, rot, sens);
    this->params.push_back(std::move(ptr));
}

void ShaderPass::AddIntParameter(std::string s, int startValue, glm::vec2 range, bool show, int midi) {
    auto ptr = std::make_unique<IntParameter>(s, startValue, range, show, midi);
    this->params.push_back(std::move(ptr));


@@ 332,16 337,25 @@ void ShaderPass::LoadParametersFromJson(Json::Value &json) {

            glm::vec3 pos = glm::vec3(xPos, yPos, zPos);

            float xRot = json["parameters"][j]["value"]["rot"]["x"].asFloat();
            float yRot = json["parameters"][j]["value"]["rot"]["y"].asFloat();
            float zRot = json["parameters"][j]["value"]["rot"]["z"].asFloat();

            float sens = json["parameters"][j]["value"]["rot"]["z"].asFloat();
            float sens = json["parameters"][j]["movementSensitivity"].asFloat();
            sens = (sens >= 0.01 && sens <= 2.0) ? sens : 1.0;

            glm::vec3 rot = glm::vec3(xRot, yRot, zRot);
            if (json["parameters"][j]["value"]["rot"].isMember("x")) {
                float xRot = json["parameters"][j]["value"]["rot"]["x"].asFloat();
                float yRot = json["parameters"][j]["value"]["rot"]["y"].asFloat();
                float zRot = json["parameters"][j]["value"]["rot"]["z"].asFloat();
                glm::vec3 rot = glm::vec3(xRot, yRot, zRot);
                addCameraParameter(pos, rot, sens);

            } else if (json["parameters"][j]["value"]["rot"].isMember("qx")) {
                float xRot = json["parameters"][j]["value"]["rot"]["qx"].asFloat();
                float yRot = json["parameters"][j]["value"]["rot"]["qy"].asFloat();
                float zRot = json["parameters"][j]["value"]["rot"]["qz"].asFloat();
                float wRot = json["parameters"][j]["value"]["rot"]["qw"].asFloat();
                glm::quat rot = glm::quat(wRot, xRot, yRot, zRot);
                addCameraParameter(pos, rot, sens);
            }

            addCameraParameter(pos, rot, sens);
        } else if (type == "audioFloat") {
            float val = json["parameters"][j]["value"].asFloat();
            float x = json["parameters"][j]["range"]["x"].asFloat();

M src/ShaderPass.h => src/ShaderPass.h +1 -0
@@ 62,6 62,7 @@ class ShaderPass {
    void AddAudioFloatParameter(std::string s, float startValue, glm::vec2 range, glm::vec2 frequencyRange, float scaleFactor, float expFactor, bool accumulate, bool show, int midi);
    void AddColorParameter(string s, float r, float g, float b, float a, bool show, int midi[]);
    void addCameraParameter(glm::vec3 pos, glm::vec3 rot, float sens);
    void addCameraParameter(glm::vec3 pos, glm::quat rot, float sens);
    void Render(ofFbo *previousBuffer, RenderStruct *renderStruct);
    void SetInputTexture(ofFbo *buffer);
    void UpdateTime(float time);