Esempio n. 1
0
const float Astronomy::earthShineIntensity(
    const t_aTime &aTime
,   const float latitude
,   const float longitude) const
{
    const osg::Vec3f m = moonPosition(aTime, latitude, longitude, false);
    const osg::Vec3f s = sunPosition(aTime, latitude, longitude, false);

    // ("Multiple Light Scattering" - 1980 - Van de Hulst) and 
    // ("A Physically-Based Night Sky Model" - 2001 - Wann Jensen et al.) -> the 0.19 is the earth full intensity
    
    const float ep  = (_PI - acos(s * (-m))) * 0.5;
    const float Eem = 0.19 * 0.5 * (1.0 - sin(ep) * tan(ep) * log(1.0 / tan(ep * 0.5)));

    return Eem;
}
Esempio n. 2
0
void OgreApplication::createScene(std::list<std::shared_ptr<OgreActor> > actors)
{
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
    mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

    for(std::shared_ptr<OgreActor> actor : actors){
        addActor(actor);
    }

    Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);

    Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        plane, 1500, 1500, 20, 20, true, 1, 500, 500, Ogre::Vector3::UNIT_Z);

    Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity", "ground");
    mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);

    entGround->setMaterialName("Examples/Rockwall");
    entGround->setCastShadows(false);

    Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
    directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
    directionalLight->setDiffuseColour(Ogre::ColourValue(0.75, 0.75, 0.75));
    directionalLight->setSpecularColour(Ogre::ColourValue(1.0, 1.0, 1.0));
    directionalLight->setDirection(Ogre::Vector3( 0, -1, -1 ));

    Ogre::Vector3 sunPosition(15, 15, -90);
    Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
    pointLight->setType(Ogre::Light::LT_POINT);
    pointLight->setPosition(sunPosition);
    pointLight->setDiffuseColour(1.0, 1.0, 1.0);
    pointLight->setSpecularColour(1.0, 1.0, 1.0);

    Ogre::SceneNode *sunNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("SUN_NODE");
    sunNode->setPosition(sunPosition);
    sunNode->attachObject(mSceneMgr->createParticleSystem("SUN_PARTICLE", "Space/Sun"));
}
Esempio n. 3
0
int main(int argc, char** argv) {
    Engine* engine = new Engine();
    if(!engine->init()) {
        std::cout << "Engine initialization failed\n";
        return 1;
    }

    engine->getShaderManager()->createProgram("mainShader", "Shaders/VertexShader.glsl", "Shaders/FragmentShader.glsl");
    GLuint program = engine->getShaderManager()->getProgram("mainShader");
    if(program == 0) {
        std::cout << "Program initialization failed\n";
        return 2;
    }
    engine->getSceneManager()->setProgram(program);

    Skybox* skybox = new Skybox();
    skybox->create(40.0f);
    skybox->setRotation(glm::vec3(0.0f, 180.0f, 0.0f));
    skybox->addMaterial(0, "Resources/Copyrighted/skybox1.png", 1.0f, 0.0f, 0.0f, 0.0f, engine->getTextureLoader());
    engine->getModelManager()->setModel("skybox", skybox);

    Cuboid* floorBox = new Cuboid();
    floorBox->create(40.0f, 1.0f, 40.0f, glm::vec4(0.24f, 0.267f, 0.337f, 1.0f));
    floorBox->setPosition(glm::vec3(0.0f, -8.0f, 0.0f));
    engine->getModelManager()->setModel("floorBox", floorBox);

    glm::vec3 sunPosition(-8.7f, 20.0f, 11.1f);
    engine->getSceneManager()->addLight(0, sunPosition, glm::vec3(1.0), 1.0f, 0.0, 0.0);
    Sphere* sun = new Sphere();
    sun->create(1.2f, 16, 16, glm::vec4(1.0f, 1.0f, 0.9f, 1.0f));
    sun->setBaseMaterial(1.0f, 0.0f, 0.0f, 0.0f);
    sun->setPosition(sunPosition);
    engine->getModelManager()->setModel("sun", sun);

    glm::vec3 lampPosition(8.0f, -1.0f, 5.0f);
    engine->getSceneManager()->addLight(1, lampPosition, glm::vec3(4.0f, 1.0f, 1.0f), 1.0f, 0.003f, 0.0005f);
    Sphere* lamp = new Sphere();
    lamp->create(0.3f, 16, 16, glm::vec4(1.0f, 0.2f, 0.2f, 1.0f));
    lamp->setBaseMaterial(1.0f, 0.0f, 0.0f, 0.0f);
    lamp->setPosition(lampPosition);
    engine->getModelManager()->setModel("lamp", lamp);

    Eel* eel = new Eel();
    eel->create(10.0f, 0.5f, 16);
    eel->setPosition(glm::vec3(0.0f, 0.0f, 0.0f));
    eel->addMaterial(0, "Resources/Copyrighted/scales1_2.png", 0.05f, 0.6f, 3.5f, 12.0f, engine->getTextureLoader());
    eel->addMaterial(1, "Resources/Textures/sphere_dots.png", 0.25f, 0.4f, 0.7f, 1.0f, engine->getTextureLoader());
    eel->addNormalMap("Resources/Copyrighted/scales1-normal3.png", engine->getTextureLoader());
    engine->getModelManager()->setModel("eel", eel);

    Sphere* sphere = new Sphere();
    sphere->create(1.0f, 24, 48);
    sphere->setPosition(glm::vec3(0.0f, -2.0f, 14.0f));
    sphere->setRotation(glm::vec3(30.0f, 0.0f, 0.0f));
    sphere->setRotationSpeed(glm::vec3(0.0f, 20.0f, 0.0f));
    sphere->addMaterial(0, "Resources/Textures/sphere1.bmp", 0.02f, 0.3f, 2.5f, 15.0f, engine->getTextureLoader());
    sphere->addMaterial(1, "Resources/Textures/sphere_dots.png", 0.02f, 0.8f, 1.0f, 1.0f, engine->getTextureLoader());
    sphere->addNormalMap("Resources/Copyrighted/fish-normal.bmp", engine->getTextureLoader());
    engine->getModelManager()->setModel("sphere", sphere);

    engine->run();

    delete engine;
    return 0;
}