コード例 #1
0
RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary)
    : Renderable(dictionary)
    , _texture("texture", "Texture", -1, -1, 255)
    , _billboard("billboard", "Billboard", false)
    , _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f))
    , _origin(Origin::Center)
    , _shader(nullptr)
    , _quad(0)
    , _vertexPositionBuffer(0)
{
    glm::vec2 size;
    dictionary.getValue("Size", size);
    _size = size;

    if (dictionary.hasKey("Name")){
        dictionary.getValue("Name", _nodeName);
    }

    if (dictionary.hasKey("Texture")) {
        int t;
        dictionary.getValue("Texture", t);
        _texture = t;
    }

    std::string origin;
    if (dictionary.getValue("Origin", origin)) {
        if (origin == "LowerLeft") {
            _origin = Origin::LowerLeft;
        }
        else if (origin == "LowerRight") {
            _origin = Origin::LowerRight;
        }
        else if (origin == "UpperLeft") {
            _origin = Origin::UpperLeft;
        }
        else if (origin == "UpperRight") {
            _origin = Origin::UpperRight;
        }
        else if (origin == "Center") {
            _origin = Origin::Center;
        }
    }

    // Attempt to get the billboard value
    bool billboard = false;
    if (dictionary.getValue("Billboard", billboard)) {
        _billboard = billboard;
    }

    int texture;
    if (dictionary.getValue("Texture", texture))
        _texture = texture;
    addProperty(_texture);

    addProperty(_billboard);

    addProperty(_size);
    _size.onChange([this](){ _planeIsDirty = true; });

    setBoundingSphere(_size.value());
}