Commit 788b7836 authored by Pavel Rojtberg's avatar Pavel Rojtberg
Browse files

ovis: allow setting material at sub-entity granularity

parent 1d77931b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -109,7 +109,8 @@ public:
    CV_WRAP virtual void setEntityProperty(const String& name, int prop, const Scalar& value) = 0;

    /// @overload
    CV_WRAP virtual void setEntityProperty(const String& name, int prop, const String& value) = 0;
    CV_WRAP virtual void setEntityProperty(const String& name, int prop, const String& value,
                                           int subEntityIdx = -1) = 0;

    /**
     * get the property of an entity
+7 −2
Original line number Diff line number Diff line
@@ -687,7 +687,7 @@ public:
        frameCtrlrs.erase(animstate);
    }

    void setEntityProperty(const String& name, int prop, const String& value) CV_OVERRIDE
    void setEntityProperty(const String& name, int prop, const String& value, int subEntityIdx) CV_OVERRIDE
    {
        CV_Assert(prop == ENTITY_MATERIAL);
        SceneNode& node = _getSceneNode(sceneMgr, name);
@@ -698,13 +698,18 @@ public:
        Camera* cam = dynamic_cast<Camera*>(node.getAttachedObject(name));
        if(cam)
        {
            CV_Assert(subEntityIdx == -1 && "Camera Entities do not have SubEntities");
            cam->setMaterial(mat);
            return;
        }

        Entity* ent = dynamic_cast<Entity*>(node.getAttachedObject(name));
        CV_Assert(ent && "invalid entity");

        if (subEntityIdx < 0)
            ent->setMaterial(mat);
        else
            ent->getSubEntities()[subEntityIdx]->setMaterial(mat);
    }

    void setEntityProperty(const String& name, int prop, const Scalar& value) CV_OVERRIDE