Beispiel #1
0
void Application::createCamera()
{
    _camera = _scene->createCamera("camera");
    _camera->setPosition(Vector3(1000,1000,1000));
    _camera->lookAt(Vector3(0,-1000,0));
    _camera->setNearClipDistance(1);
    _camera->setFarClipDistance(100000);

    Viewport* vp = _window->addViewport(_camera);
    _camera->setAspectRatio(Real(vp->getActualWidth())/Real(vp->getActualHeight()));
    //_camera->setPolygonMode(Ogre::PM_WIREFRAME);
    vp->setBackgroundColour(ColourValue(0,0,0));
}
Beispiel #2
0
Datei: Bond.cpp Projekt: Leph/SMA
void Bond::updateNode()
{
    Real distance = _end1->getPosition()
        .distance(_end2->getPosition())/2.0;
    Vector3 middle = 
        (_end1->getPosition()+_end2->getPosition())/2.0;
    _node->setPosition(middle);
    _node->setScale(Vector3(distance, 20, 20));
    _node->setOrientation(
        Vector3(1, 0, 0).getRotationTo(
            _end1->getPosition()-_end2->getPosition()
        )
    );
}
Beispiel #3
0
void Application::initSimulation()
{
    //Initialisation le générateur aléatoire
    //(debug)
    int seed = (int)Math::RangeRandom(20, 10000000);
    std::cout << "===>" << (int)seed << std::endl;
    //int seed = 6486951;//7264745 8983653;
    //int seed = 7264745;
    //int seed = 8983653;
    //int seed = 9765800;
    srand(seed);

    _scene->setAmbientLight(ColourValue(0.1, 0.1, 0.1));
    Ogre::Light *light1 = _scene->createLight();
    light1->setDiffuseColour(1.0, 1.0, 1.0);
    light1->setSpecularColour(1.0, 1.0, 1.0);
    light1->setPosition(-100, 200, 100);

    Entity* ent = _scene->createEntity("ogrehead.mesh");
    SceneNode* node = _scene->getRootSceneNode()->createChildSceneNode();
    node->attachObject(ent);

    for (int i=0;i<2000;i++) {
        Vector3 position = Vector3(
            Math::RangeRandom(-1500, 1500),
            Math::RangeRandom(-1500, 1500),
            Math::RangeRandom(-1500, 1500));
        Atom* a;
        Real r = Math::RangeRandom(0,100);
        if (r>=90) a = new Atom_Lambda(position);
        else if (r>=80) a = new Atom_Lambda_Virt(position);
        else if (r>=70) a = new Atom_Apply(position);
        else if (r>=60) a = new Atom_Apply_Virt(position);
        else if (r>=50) a = new Atom_Association(position);
        else if (r>=40) a = new Atom_Association_Virt(position);
        else if (r>=35) a = new Atom_Bound(position);
        else if (r>=30) a = new Atom_Bound_Virt(position);
        else if (r>=25) a = new Atom_Unbound(position);
        else if (r>=20) a = new Atom_Unbound_Virt(position);
        else if (r>=10) a = new Atom_Term(
            position, 
            (int)Math::RangeRandom(0.0, 2.0)
        );
        else if (r>=0) a = new Atom_Term_Virt(
            position, 
            (int)Math::RangeRandom(0.0, 2.0)
        );
        if (!_positionResolver->checkCollisionAtoms(
            a->getPosition(), a->getRadius())) 
        {
            _atoms->add(a);
            _scene->_updateSceneGraph(0);
        } else {
            delete a;
        }
    }
    
    /*
    _atoms->createBond(
        _atoms->get(0),
        _atoms->get(1),
        150
    );
    _atoms->createBond(
        _atoms->get(1),
        _atoms->get(2),
        150
    );
    _atoms->createBond(
        _atoms->get(2),
        _atoms->get(3),
        150
    );
    _atoms->createBond(
        _atoms->get(3),
        _atoms->get(0),
        150
    );
    _atoms->get(0)->transfertBonds(_atoms->get(1));
    _atoms->get(1)->transfertBonds(_atoms->get(2));

    Graph* g = 0;
    for (size_t i=0;i<_atoms->getSize();i++) {
        if (_atoms->get(i)->isType<Atom_Lambda>()) {
            g = new Graph();
            g->build(_atoms->get(i));
            break;
        }
    }
    TransformLambda t = TransformLambda(*g);
    std::cout << t.isValid() << std::endl;
    if (t.isValid()) {
        while(t.doTransformStep());
    }
    */
}