Пример #1
0
/** Returns the world matrix **/
void VRTransform::getWorldMatrix(Matrix& _m, bool parentOnly) {
    //if (checkWorldChange()) {
    if (true) {
        vector<Matrix> tv;

        Matrix m;
        VRObject* obj = this;
        if (parentOnly and obj->getParent() != 0) obj = obj->getParent();

        VRTransform* tmp;
        while(true) {
            if (obj->hasAttachment("transform")) {
                tmp = (VRTransform*)obj;
                tmp->getMatrix(m);
                //cout << "\nPARENT: " << tmp->getName();
                //cout << "\n" << m;
                tv.push_back(m);
            }

            if (obj->getParent() == 0) break;
            else obj = obj->getParent();
        }

        WorldTransformation = computeMatrixVector(tv);
    }

    _m = WorldTransformation;
    //if (getName() == "Box") cout << WorldTransformation << endl;
    //cout << "\nGETWM: " << getName() << endl << _m << endl;
}
Пример #2
0
void VRSceneLoader::optimizeGraph(VRObject* obj) { //TODO
    VRObject* p = obj->getParent();
    if (obj->getType() == "Geometry" && p->getType() == "Transform" && p->getChildrenCount() == 1) {
        obj->switchParent(p->getParent());
        obj->setName(p->getName());
        //obj->setMatrix(p->getMatrix()); //TODO: cast
        p->hide();
    }

    for (uint i=0;i<obj->getChildrenCount();i++)
        optimizeGraph(obj->getChild(i));
}
Пример #3
0
bool VRTransform::checkWorldChange() {
    if (frame == 0) {
        frame = 1;
        return true;
    }

    if (hasGraphChanged()) return true;

    VRObject* obj = this;
    VRTransform* ent;
    while(obj) {
        if (obj->hasAttachment("transform")) {
            ent = (VRTransform*)obj;
            if (ent->change) return true;
        }
        obj = obj->getParent();
    }

    return false;
}