Exemple #1
0
bool FObject::move(FNode* n, float dx) {
    bool done = false;
    VRTransform* trans = getTransformation();
    if (trans == 0) return true;
    if (n->getTransform() == 0) return true;

    Vec3f p = trans->getFrom();
    Vec3f c = n->getTransform()->getFrom();


    Vec3f d = c-p;
    if (d.length() < dx) { p = c; done = true; }
    else { d.normalize(); p = p+d*dx; }

    //cout << "MOVE " << p << "   " << c << endl;
    trans->setFrom(p);
    //trans->setDir(Vec3f(1,0,0));

    return done;
}
void VRSceneManager::newScene(string path) {
    removeScene(getCurrent());

    VRScene* scene = new VRScene();
    scene->setPath(path);
    setWorkdir(scene->getWorkdir());
    scene->setName(scene->getFileName());
    VRTransform* cam = scene->addCamera("Default");

    VRLight* headlight = scene->addLight("Headlight");
    headlight->setType("point");
    VRLightBeacon* headlight_B = new VRLightBeacon("Headlight_beacon");
    headlight->setBeacon(headlight_B);
    VRTransform* user = VRSetupManager::getCurrent()->getUser();
    scene->add(headlight);
    headlight->addChild(cam);
    if (user) user->addChild(headlight_B);
    else cam->addChild(headlight_B);

    cam->setFrom(Vec3f(0,0,3));
    addScene(scene);
}