示例#1
0
文件: main.cpp 项目: Blizzara/ART
void CornellBox(Scene& scene)
{
// 	Scene scene;
	Color white(1,1,1);
	Color red(1,0,0);
	Color green(0,1,0);
	Color blue(0,0,1);
	Color yellow(0,1,1);
	Color lila(1,0,1);
	
	scene.AddPlane(Vector(5,0,0), Vector(-1,0,0), false, Texture(green,0,0.6));	// right
	scene.AddPlane(Vector(-5,0,0), Vector( 1,0,0), false, Texture(red,0,0.6));	// left
	scene.AddPlane(Vector(0,0,5), Vector( 0,0,-1), false, Texture(lila,0,0.6));	// back 
	scene.AddPlane(Vector(0,0,-5), Vector(0,0,1), false, Texture(white,0,0.6));	// front (behind camera)
// 	scene.AddBox(Vector(5,5,5), Vector(-5,6,-5), false, Texture(white,1,0.0));	// top
	scene.AddPlane(Vector(0,5,0), Vector(0,-1,0), false, Texture(blue,0,0.6));	// top
	scene.AddPlane(Vector(0,0,0), Vector(0,1,0), false, Texture(white,0,0.6));	// bottom
	
// 	scene.AddBox(Vector(-4,-5,4.5), Vector(-2,-1,2.5), false, Texture(blue,0,0.6));
// 	scene.AddBox(Vector( 0,-5,3.5), Vector( 2,-3,4.5), false, Texture(white,0,0.6));
	scene.AddBox(Vector( -4,0,4.5), Vector( -2,2,2.5), false, Texture(white,0,0,0,0.7)); //reflection
	scene.AddBox(Vector(  4,0,4.5), Vector(  2,2,2.5), false, Texture(white,0,0,0,0,1)); //transmit/refraction

	scene.AddSphere(Vector(3.5,3.5,3), 1, false, Texture(white,1,0));	//the lamp

	scene.AddCamera(Vector(0,2.5,-4.9), Vector(0,2.5,-3.9));
	
	// 	Sphere sphere(Vector(0.1,0,0), 0.3, false, Texture());
	// 	Sphere sphere2(Vector(-0.1,0,0), 0.2, false, Texture());
	// 	
	// 	scene.AddIntersection(&sphere, &sphere2);
	
	
// 	return (Scene&)scene;
}
示例#2
0
文件: main.cpp 项目: Blizzara/ART
void TransmitTest(Scene& scene) //Scene has no copy constructor, can't be returned
{
	//Texture(Color a_color, float a_ambient, float a_diffuse, float a_specular, float a_reflection, float a_transmit)

// 	scene.AddPlane(Vector( 0,-0.1,0), Vector(0,1,0), false, Texture(Color(0.5),0,0.2,0,0.8,0));
	
	scene.AddCamera(Vector(0,0,-10), Vector(0,0,8));
	scene.AddSphere(Vector( 5, 8, 8), 0.45, false, Texture(Color(1, 1,1),1,0,0,0,0));
	scene.AddSphere(Vector( 0, 0, 8), 0.1, false, Texture(Color(1, 1,0),0,0,0,0,1));

}
示例#3
0
void SceneLoader::ImportCamera(Scene& scene, const aiCamera* const camera) {
    float width = camera->mAspect;
    float height = 1.0;
    glm::mat4x4 persp = glm::perspective(camera->mHorizontalFOV, camera->mAspect,
                                         camera->mClipPlaneNear, camera->mClipPlaneFar);
    aiVector3D ai_at = camera->mLookAt;
    aiVector3D ai_pos = camera->mPosition;
    aiVector3D ai_up = camera->mUp;
    glm::vec3 at = glm::vec3(ai_at[0], ai_at[1], ai_at[2]);
    glm::vec3 pos = glm::vec3(ai_pos[0], ai_pos[1], ai_pos[2]);
    glm::vec3 up = glm::vec3(ai_up[0], ai_up[1], ai_up[2]);
    glm::mat4x4 look_at = glm::lookAt(pos, at, up);
    scene.AddCamera(Camera(width, height, persp, look_at));
}
示例#4
0
void Test::LoadResources()
{
	time = 0.f;
	isFinished = false;
	skipFrames = 100;

	Scene *scene = new Scene();
	scene->AddNode(scene->GetRootNode(fullName));
	DVASSERT_MSG(scene, "Could not load the scene");

	Camera* cam = new Camera();
	scene->AddCamera(cam);

	Core* core = DAVA::Core::Instance();
	float32 aspect = core->GetVirtualScreenHeight() / core->GetVirtualScreenWidth();

	cam->Setup(70.f, aspect, 1.f, 5000.f);
	cam->SetLeft(Vector3(1, 0, 0));
	cam->SetUp(Vector3(0, 0, 1));
    
    scene->SetCurrentCamera(cam);
	SafeRelease(cam);

	UI3DView *sceneView = new UI3DView(Rect(0, 0, GetSize().x, GetSize().y));
	sceneView->SetScene(scene);
	AddControl(sceneView);
	SafeRelease(sceneView);

	Landscape* landscape = GetLandscape();
	DVASSERT_MSG(scene, "There is no landscape in a scene");
	landscape->SetTiledShaderMode(Landscape::TILED_MODE_TEXTURE);

	uint32 textureMemory = TextureHelper::GetSceneTextureMemory(scene, GetFilePath());
	testData.SetTextureMemorySize(textureMemory);

	File* file = File::Create(fullName, File::OPEN | File::READ);
	DVASSERT_MSG(file, "Could not open file scene file");
	testData.SetSceneFileSize(file->GetSize());
	SafeRelease(file);

	PreparePath();
    PrepareFpsStat();
    PrepareCameraAnimation();
    ZeroCurFpsStat();
    MoveToNextPoint();

    SafeRelease(scene);
}
示例#5
0
文件: main.cpp 项目: Blizzara/ART
void SphereWall(Scene& scene) //Scene has no copy constructor, can't be returned
{
	//Texture(Color a_color, float a_ambient, float a_diffuse, float a_specular, float a_reflection, float a_transmit)

	scene.AddSphere(Vector(3,10,0), 1, true, Texture(Color(1), 1, 0,0,0,0)); // Light
// 	
	scene.AddPlane(Vector( 0,-1,0), Vector(0,1,0), false, Texture(Color(0.5),0,0.2,0,0.8,0));
	
	scene.AddCamera(Vector(0,3,-10), Vector(0,3,-8.5));
		
	for(float x = -7; x <= 7; ++x)
	{
		for(float y = -0.5; y <= 6.5; ++y)
		{
			scene.AddSphere(Vector( x, y, 8), 0.45, false, Texture(Color((x+7)/14, 1-((y+0.5)/7),(x+y+8)/21),0,0.7,0.3,0,0));
		}
	}
}
示例#6
0
文件: main.cpp 项目: Blizzara/ART
void BuildAnotherScene(Scene& scene) //Scene has no copy constructor, can't be returned
{
// 	Scene scene;
	// 	scene.AddLight(Vector(-3,10,0), Vector(1,1,1));
	// 	Texture(Color a_color, a_ambient = 0,a_diffuse = 0.6, a_specular = 0, a_reflection = 0, a_transmit = 0)
	
	
	scene.AddSphere(Vector(3,0,5), 1, false, Texture(Vector(1,0,0), 0, 0.6,0,0,0));

	scene.AddSphere(Vector(0,0,2), 1, false, Texture(Vector(1,1,1), 1, 0.0,0,0,0));

 	scene.AddSphere(Vector(-2,0,0), 1, false, Texture(Vector(0,1,1), 0, 0.6,0,0,0));
	
// 	scene.AddBox(Vector(-3,-1,-1), Vector(-1,1,1), false, Texture(Vector(0,1,1), 0, 0.6,0,0,0));
	scene.AddSphere(Vector(2.5,0,1), 1, false, Texture(Vector(1,1,1), 0, 0.0,0,1,0));
	
	scene.AddPlane(Vector( 0,-1,0), Vector(0,1,0), false, Texture(Color(0.5,0.5,0.5),0,0.6,0,0,0));
	
// 	scene.AddSphere(Vector(0,0,-8),1, false,Texture(Color(1,0,1), 0,0.5)); // tests for see-through
	scene.AddCamera(Vector(0,0,-8), Vector(0,0,-7));
	
// 	return scene;
}
示例#7
0
bool AppWindow::init ()
{
	// Get comnmand line
	std::string str = getCmdLine();
	if ( str == "" )
		str = "-i lucy.scn -s 8";

	std::vector<std::string>	args;
	while ( str.length() > 0) {
		args.push_back ( strSplit ( str, " " ) );		
	}
	std::string filename = "";
	for (int n=0; n < args.size(); n++ ) {
		if ( args[n].compare ( "-p" ) == 0 ) {		// added path
			scene.AddPath ( std::string( args[n+1] ) );			
		}
		if ( args[n].compare ( "-i" ) == 0 ) {		// input file (scn)
			filename = args[n+1];
		}
		if ( args[n].compare ( "-t" ) == 0 ) {		// timing output
			gTimingFile = "timing.csv";
		}
		if ( args[n].compare ( "-s" ) == 0 ) {		// # samples
			num_samples = atoi ( args[n+1].c_str() );
		}
	}

	// Write timing file
	gTimingFP = 0x0;
	if ( gTimingFile != "" ) {
		char name[1024];
		strcpy ( name, gTimingFile.c_str() );
		gTimingFP = fopen ( name, "wt" );
	}

	nvprintf  ( "OpenGL + OptiX Compositing Demo\n" );
	nvprintf  ( "Copyright (c) 2014, NVIDIA Corporation\n" );	

	//-------- GUI
	addGui (  20,  20, 200, 24, "Frame Time (ms)",		GUI_PRINT,  GUI_FLOAT,	&frameTime, 0, 0 );

	//-------- Scene 
	
	// Create camera
	nvprintf  ( "Creating camera...\n" );
	Camera3D* cam = scene.AddCamera ();
	cam->setOrbit ( Vector3DF(45,30,0), Vector3DF(0,0,0), 120, 120 );
	cam->setNearFar ( 1, 1000 );
	cam->setFov ( 71.635 );
	cam->updateMatricies ();

	// Create model(s)
	nvprintf ( "Creating model(s)...\n" );
	nvprintf ( "  Project path: %s\n", std::string(PROJECT_ABSDIRECTORY).c_str() );
	scene.AddPath ( "..\\assets\\" );
	scene.AddPath ( "..\\shaders\\" );
	scene.AddPath ( std::string(PROJECT_RELDIRECTORY) );
	scene.AddPath ( std::string(PROJECT_RELDIRECTORY) + "\\assets\\" );
	scene.AddPath ( std::string(PROJECT_RELDIRECTORY) + "\\shaders\\" );
	scene.AddPath ( std::string(PROJECT_ABSDIRECTORY) );
	scene.AddPath ( std::string(PROJECT_ABSDIRECTORY) + "\\assets\\" );
	scene.AddPath ( std::string(PROJECT_ABSDIRECTORY) + "\\shaders\\" );
	scene.LoadFile ( filename );
	
	// Initialize fonts
	/* init2D ( "data/arial_24" );
	setText ( 0.5, -0.5 );
	setview2D ( getWidth(), getHeight() );
	setorder2D ( true, -0.00001 );*/		

	//MoveWindow ( 5, 5, window_width, window_height );

	// Setup OpenGL default render
	nvprintf  ( "Creating OpenGL shader...\n" );
	renderAddShaderGL    ( scene, "render_GL.vert.glsl", "render_GL.frag.glsl" );

	// Setup OptiX
	#ifdef BUILD_OPTIX
		nvprintf  ( "Creating Optix shader..\n" );
		renderAddShaderOptix ( scene, "render_Optix.vert.glsl", "render_Optix.frag.glsl" );
		nvprintf  ( "Initializing Optix..\n" );
		renderInitializeOptix ( getWidth(), getHeight() );
		nvprintf  ( "Adding models to Optix..\n" );
		int mat_id = renderAddMaterialOptix ( scene, "optix_shadow_rays.ptx" );
		
		for (int n=0; n < scene.getNumModels(); n++ )
			renderAddModelOptix ( scene.getModel(n), mat_id );

		nvprintf  ( "Validating Optix..\n" );				
		renderValidateOptix ();
	#endif

	// Setup OptiX Prime
	#ifdef BUILD_OPTIX_PRIME
		nvprintf  ( "Creating Optix Prime shader..\n" );		
		renderAddShaderOptixPrime ( scene, "render_Optix.vert.glsl", "render_Optix.frag.glsl" );
		nvprintf  ( "Initializing Optix Prime..\n" );
		renderInitializeOptixPrime ( scene, getWidth(), getHeight() );
		nvprintf  ( "Adding models to Optix..\n" );		
		for (int n=0; n < 1; n++ )
			renderAddModelOptixPrime ( scene.getModel(n) );
	#endif

	draw_mode = MODE_OPENGL;
	#ifdef BUILD_OPTIX
		draw_mode = MODE_OPTIX;
	#else
		nvprintf ( "***** ERROR:\n" );
		nvprintf ( " OptiX 3.6.3 was not found.\n");
		nvprintf ( " Please specify CUDA_LOCATION variable for CUDA 5.5 during cmake generate step.\n" );
		nvprintf ( " Running sample with OpenGL only. No hard shadows will appear.\n");
		nvprintf ( "*****\n\n" );
	#endif
	cam_mode = MODE_CAMERA;
	
	PERF_INIT ( 64, true, false, false, 0, "" );		// 32/64bit, CPU?, GPU?, Cons out?, Level, Log file	

	return "OpenGL + OptiX Compositing";
}