Beispiel #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;
}
Beispiel #2
0
void VRSceneLoader_saveObject(VRObject* p, xmlpp::Element* e) {
    if (e == 0) return;
    p->save(e);
    for (uint i=0; i<p->getChildrenCount(); i++) {
        VRObject* c = p->getChild(i);
        if (c->getPersistency() == 0) continue; // generated objects are not be saved
        if (c->hasAttachment("global")) continue; // global objects are not be saved
        //xmlpp::Element* ce = e->add_child(c->getName());
        xmlpp::Element* ce = e->add_child("Object");
        VRSceneLoader_saveObject(c, ce);
    }
}
Beispiel #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;
}