void App::LoadSNBTerrain()
{
	terrainload_ = true;

	g_ConfigFiles.push_back( L"Default_Config.txt");

	g_TerrainDX11Render.SetQuadTreePreviewPos(10, 290, 200, 200);

	LoadScene();

	// Setup the camera's view parameters
	D3DXVECTOR3 vecEye( 2643.75f, 2178.89f, 2627.14f );
	D3DXVECTOR3 vecAt ( 2644.52f, 2178.71f, 2627.74f );
	//D3DXVECTOR3 vecEye( 150.75f, 100.89f, 150.14f );
	//D3DXVECTOR3 vecAt ( 151.52f, 100.71f, 150.74f );
	//g_Camera.SetViewParams( &vecEye, &vecAt );
	//g_Camera.SetRotateButtons(true, false, false);
	ActiveCam_->setFrom((float*)vecEye);
	ActiveCam_->setTo((float*)vecAt);
	ActiveCam_->setFOV(RAD2DEG(noMath::PI / 4));
	ActiveCam_->setNear(CLIP_NEAR);
	ActiveCam_->setFar(CLIP_FAR);
	ActiveCam_->SetAspect(GetAspectRatio());
	ActiveCam_->computeModelView();	
	ActiveCam_->ComputeProjection();
	

	static bool bFirstTime = true;
	if( bFirstTime )
	{
		InitTerrainRender();
		bFirstTime = false;
	}
	g_TerrainDX11Render.OnD3D11CreateDevice( device, context );

	//ResizeSNBTerrain();

	D3DXCOLOR SunColor(1,1,1,1), AmbientLight(0,0,0,0);
	g_TerrainDX11Render.SetSunParams(g_vDirectionOnSun, SunColor, AmbientLight);
	g_TerrainDX11Render.EnableAdaptiveTriangulation(true);
}
Beispiel #2
0
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
{
    while (true)
    {
        std::string tag = cin->getString();
        if (tag == "") return;

        /* parse command line parameters from a file */
        else if (tag == "-c") {
            FileName file = path + cin->getFileName();
            parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
        }

        /* load OBJ model*/
        else if (tag == "-i") {
            filename = path + cin->getFileName();
        }

        /* parse camera parameters */
        else if (tag == "-vp") g_camera.from = cin->getVec3fa();
        else if (tag == "-vi") g_camera.to = cin->getVec3fa();
        else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
        else if (tag == "-vu") g_camera.up = cin->getVec3fa();
        else if (tag == "-fov") g_camera.fov = cin->getFloat();

        /* frame buffer size */
        else if (tag == "-size") {
            g_width = cin->getInt();
            g_height = cin->getInt();
        }

        /* full screen mode */
        else if (tag == "-fullscreen")
            g_fullscreen = true;

        /* output filename */
        else if (tag == "-o") {
            outFilename = cin->getFileName();
            g_interactive = false;
        }

        else if (tag == "-objlist") {
            keyframeList = cin->getFileName();
        }

        /* subdivision mode */
        else if (tag == "-cache")
            g_subdiv_mode = ",subdiv_accel=bvh4.subdivpatch1cached";

        else if (tag == "-pregenerate")
            g_subdiv_mode = ",subdiv_accel=bvh4.grid.eager";

        else if (tag == "-anim")
            g_anim_mode = true;

        else if (tag == "-instancing") {
            std::string mode = cin->getString();
            if      (mode == "none"    ) g_instancing_mode = 0;
            else if (mode == "geometry") g_instancing_mode = 1;
            else if (mode == "scene"   ) g_instancing_mode = 2;
            else throw std::runtime_error("unknown instancing mode: "+mode);
        }

        /* number of frames to render in benchmark mode */
        else if (tag == "-benchmark") {
            g_skipBenchmarkFrames = cin->getInt();
            g_numBenchmarkFrames  = cin->getInt();
            g_interactive = false;
        }

        /* rtcore configuration */
        else if (tag == "-rtcore")
            g_rtcore = cin->getString();

        /* number of threads to use */
        else if (tag == "-threads")
            g_numThreads = cin->getInt();

        /* ambient light source */
        else if (tag == "-ambientlight")
        {
            const Vec3fa L = cin->getVec3fa();
            g_scene->add(new SceneGraph::LightNode<AmbientLight>(AmbientLight(L)));
        }

        /* point light source */
        else if (tag == "-pointlight")
        {
            const Vec3fa P = cin->getVec3fa();
            const Vec3fa I = cin->getVec3fa();
            g_scene->add(new SceneGraph::LightNode<PointLight>(PointLight(P,I)));
        }

        /* directional light source */
        else if (tag == "-directionallight" || tag == "-dirlight")
        {
            const Vec3fa D = cin->getVec3fa();
            const Vec3fa E = cin->getVec3fa();
            g_scene->add(new SceneGraph::LightNode<DirectionalLight>(DirectionalLight(D,E)));
        }

        /* distant light source */
        else if (tag == "-distantlight")
        {
            const Vec3fa D = cin->getVec3fa();
            const Vec3fa L = cin->getVec3fa();
            const float halfAngle = cin->getFloat();
            g_scene->add(new SceneGraph::LightNode<DistantLight>(DistantLight(D,L,halfAngle)));
        }

        /* skip unknown command line parameter */
        else {
            std::cerr << "unknown command line parameter: " << tag << " ";
            while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " ";
            std::cerr << std::endl;
        }
    }
}
 ptr<AmbientLight> AmbientLight::create(Color color) {
     return make_shared<AmbientLight>( AmbientLight(color) );
 }