//=====================================================================================
void YSLaboratoryView::initializeGL()
{
    // initiallisation (called once)

    Debugger(true);

    Scene()->SetContext(context());
    
    if (mAlice) {
    for (int index = 0; index < mAlice->Elements().size(); index++) {
        YSShape * shape = mAlice->Elements().at(index);
        Scene()->AddShape(shape);
    }
    }
    
//    for (int index = 0; index < mCollision->FSParticles().size(); index++) {
//        YSShape * shape = mCollision->FSParticles().at(index);
//        Scene()->AddShape(shape);
//    }
    
    Scene()->AddShape(new YSSphere(0.1, 20, 0.0, this));
    Scene()->CreateShapes();
    context()->functions()->glViewport(0, 0, width(), height());
    
    
//    glShadeModel(GL_SMOOTH);              // specify shading technique (FLAT or SMOOTH)
//    glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // specify clear values for the color buffer
//    glClearDepth(1.0f);                   // specify the clear value for the depth buffer
//    glEnable(GL_DEPTH_TEST);              // do depth comparisons and update the depth buffer
//    glDepthFunc(GL_LEQUAL);               // depth buffer comparison: passes if incoming depth <= stored depth value
//    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // specify implementation-specific hints

}
//=====================================================================================
void YSLaboratoryView::paintGL()
{
    // painting (called for each view update)

    Scene()->SetPerspective(Aspect(), (double)width() / (double)height(), 1, 100.0);
    Scene()->LookAt(CameraPosition(), CameraPosition() + CameraFront(), CameraUp());
    Scene()->Draw();
}
Beispiel #3
0
int main(int argc, char **argv)
{
	string scenefile;	//If aren't specified, it will render the default scene with only a cube
	string outfilename("scenes/default_output.bmp");	//NOTE: here we only support bmp output
	string outfilename_depth("scenes/default_depth_output.bmp");

    // Scene filename specified
	if (argc > 1)
	{
		scenefile = string(argv[1]);
		int dot = scenefile.find_last_of('.');
		outfilename = scenefile.substr(0, dot) + "_output.bmp";
		outfilename_depth = scenefile.substr(0, dot) + "_depth_output.bmp";
	}

    std::cout << "Rendering " << (scenefile.empty() ? "default scene" : scenefile) << std::endl;
    std::cout << "Output to " << outfilename << std::endl;
   
	Raytracer raytracer;
	if (scenefile.empty())
	{
		//render default scene
		raytracer.render(
			outfilename.c_str(),
			outfilename_depth.c_str(),
			Scene()
			);
	}
	else
	{
		// Parse the scene file
		Parser parser(new std::ifstream(scenefile.c_str()));
		if (!parser.parse()) {
			puts("Scene file can't be parsed. Use default scene.");
			raytracer.render(
				outfilename.c_str(),
				outfilename_depth.c_str(),
				Scene()
				);
		}
		else
		{
			// Render the input scene with our raytracer.
			raytracer.render(
				outfilename.c_str(),
				outfilename_depth.c_str(),
				parser.scene
				);
		}
	}
	
	// Use if you're running visual studio
	// system("pause");
	return 0;
}
Beispiel #4
0
void Render::loadScene(const char * exePath)
{
  const std::string skyboxTextureFileName = std::string(exePath) + "./textures/skybox.tga";
  const std::string planeTextureFileName = std::string(exePath) + "./textures/himiya.tga";

  camera = Camera(Vector3(7.427f, 3.494f, -3.773f), Vector3(6.5981f, 3.127f, -3.352f), 1.05f);

  scene = Scene(Color(0.95f, 0.95f, 1.0f), 0.15f);
  scene.setSkyboxTexture(skyboxTextureFileName.c_str());

  scene.addLight(Vector3(11.8e9f, 4.26e9f, 3.08e9f), 3.48e8f, Color(1.0f, 1.0f, 0.95f), 0.85f);
  //scene.addLight(Vector3(-1.26e9f, 11.8e9f, 1.08e9f), 6.96e8f, Color(1.0f, 0.5f, 0.5f), 0.2f);
  //scene.addLight(Vector3(11.8e9f, 4.26e9f, 3.08e9f), 6.96e9f, Color(1.0f, 1.0f, 0.95f), 0.85f);

  scene.addSphere(Vector3(-1.25f, 1.5f, -0.25f), 1.5f, Material(Material::mtMetal, Color(1.0f, 1.0f, 1.0f), 1.0f, 0.0f));
  scene.addSphere(Vector3(0.15f, 1.0f, 1.75f), 1.0f, Material(Material::mtMetal, Color(1.0f, 1.0f, 1.0f), 0.95f, 0.0f));

  scene.addSphere(Vector3(-3.0f, 0.6f, -3.0f), 0.6f, Material(Material::mtDielectric, Color(1.0f, 1.0f, 1.0f), 0.0f, 0.0f));
  scene.addSphere(Vector3(-0.5f, 0.5f, -2.5f), 0.5f, Material(Material::mtDielectric, Color(0.5f, 1.0f, 0.15f), 0.75f, 0.0f));
  scene.addSphere(Vector3(1.0f, 0.4f, -1.5f), 0.4f, Material(Material::mtDielectric, Color(0.0f, 0.5f, 1.0f), 1.0f, 0.0f));

  scene.addSphere(Vector3(1.8f, 0.4f, 0.1f), 0.4f, Material(Material::mtMetal, Color(1.0f, 0.65f, 0.45f), 1.0f, 0.0f));
  scene.addSphere(Vector3(1.7f, 0.5f, 1.9f), 0.5f, Material(Material::mtMetal, Color(1.0f, 0.90f, 0.60f), 0.75f, 0.0f));
  scene.addSphere(Vector3(0.6f, 0.6f, 4.2f), 0.6f, Material(Material::mtMetal, Color(0.9f, 0.9f, 0.9f), 0.0f, 0.0f));

  Texture * planeTexture = scene.addTexture(planeTextureFileName.c_str());
  Triangle * tr1 = scene.addTriangle(Vector3(-14.0f, 0.0f, -10.0f), Vector3(-14.0f, 0.0f, 10.0f), Vector3(14.0f, 0.0f, -10.0f), Material(Material::mtDielectric, Color(1.0f, 1.0f, 1.0f), 0.95f, 0.0f));
  tr1->setTexture(planeTexture, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
  Triangle * tr2 = scene.addTriangle(Vector3(-14.0f, 0.0f, 10.0f), Vector3(14.0f, 0.0f, 10.0f), Vector3(14.0f, 0.0f, -10.0f), Material(Material::mtDielectric, Color(1.0f, 1.0f, 1.0f), 0.95f, 0.0f));
  tr2->setTexture(planeTexture, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
}
Beispiel #5
0
 void GameState::displayLoop(SDL_Surface * surface) {
     Item item1 = Item(1,"Obj1",false,1,Coordinates(0,0),Resource());
     Item item01 = Item(6,"Obj01",false,1,Coordinates(0,1),Resource());
     Item item10 = Item(7,"Obj10",false,1,Coordinates(1,0),Resource());
     Item item11 = Item(8,"Obj11",false,1,Coordinates(1,1),Resource());
     Item item02 = Item(9,"Obj02",false,1,Coordinates(0,2),Resource());
     Item item20 = Item(10,"Obj20",false,1,Coordinates(2,0),Resource());
     Item item22 = Item(11,"Obj22",false,1,Coordinates(2,2),Resource());
     Item item2 = Item(2,"Obj2",false,1,Coordinates(9,9),Resource());
     Item item3 = Item(3,"Obj3",false,1,Coordinates(9,0),Resource());
     Item item4 = Item(4,"Obj4",false,1,Coordinates(0,9),Resource());
     Item item5 = Item(5,"Obj5",false,1,Coordinates(4,4),Resource());
     std::vector<Item> items;
     Scene mainScene = Scene(1,items ,LocalPlayer());
     mainScene.addItem(item1);
     mainScene.addItem(item2);
     mainScene.addItem(item3);
     mainScene.addItem(item4);
     mainScene.addItem(item5);
     mainScene.addItem(item10);
     mainScene.addItem(item01);
     mainScene.addItem(item11);
     mainScene.addItem(item20);
     mainScene.addItem(item02);
     mainScene.addItem(item22);
     mainScene.render(surface);
 }
Beispiel #6
0
void display (void)
{
    /** Create Scene, This will parse the scenefile and start off the rendering process
     */
    
    printf("Display function \n");
    Scene myScene = Scene(scenefile);
    float width = myScene.imgWidth;
    float height = myScene.imgHeight;
    
    glWindowSizeX = width;
    glWindowSizeY = height;
    
    gluOrtho2D(0., glWindowSizeX, 0., glWindowSizeY);
    glViewport(0., 0., glWindowSizeX, glWindowSizeY);
    glutReshapeWindow(glWindowSizeX, glWindowSizeY);
    
    for (float i = 0; i < width; i++) {
        for (float j = 0; j < height; j++) {
            myScene.RenderScene(i, j);
        }
    }
    /* Perform Reflection now after all pixels havebeen rendered */
    
    myScene.DrawScene();
    glutSwapBuffers();
}
Beispiel #7
0
int main(int argc, char** argv) {
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	Scene scene =  Scene();
	scene.Start();

	return 0;
}
Beispiel #8
0
void ts::scene::Loading_sequence::async_load(const action::Stage* stage)
{
    loaded_scene_ = Scene();
    exception_ptr_ = nullptr;
    stage_ = stage;

    set_finished(false);
    set_loading(true);

    scene_loader_.set_completion_handler([this]()
    {
        load_scripts_if_ready();
    });

    scene_loader_.set_state_change_handler([this](Scene_loader_state new_state)
    {
        state_change(to_string(new_state));
    });

    audio_loader_.set_completion_handler([this]()
    {
        load_scripts_if_ready();
    });

    scene_loader_.async_load(stage, resource_store_->video_settings());
    audio_loader_.async_load(stage, resource_store_->audio_settings());
}
Beispiel #9
0
void PVSPreprocessor::buildPVS()
{
	//Create scene
	SceneOptions ocSceneOptions;
	ocSceneOptions.setMaxCellSize((int)maxCellSize.x, (int)maxCellSize.y, (int)maxCellSize.z);
	ocSceneOptions.setVoxelSize(voxelSize.x,voxelSize.y, voxelSize.z);
	Scene ocScene = Scene(ocSceneOptions, sceneName);

	//Add meshes to scene
	vector<Model*> ocModels;
	Matrix4x4 identityMat;
	for(unsigned int i = 0; i < meshes.size(); i++)
	{
		MeshData meshData = meshes[i];

		//Sequential index data
		int indexCount = meshData.trianglesCount * 3;
		int* indexData = new int[indexCount];
		for(int i = 0; i < indexCount; i++)
		{
			indexData[i] = i;
		}

		//Create model
		Model* ocModel = new Model(meshData.vertexData, indexCount, indexData, meshData.trianglesCount);
		
		//Add model to scene
		ocModels.push_back(ocModel);
		ocScene.addModelInstance((*ocModel), meshData.id, identityMat, meshData.type);

		delete[] indexData;
	}

	//Generate voxels from the scene
 	PVSGenerator gen = PVSGenerator(ocScene);
	shared_ptr<PVSDatabase> ocDatabase = gen.generatePVSDatabase();

	//Export to file
	PVSDatabaseExporter dbExporter(*ocDatabase);
	int allocatedSize = dbExporter.getBufferSize();
	char *buffer = new char[allocatedSize];
	dbExporter.saveToBuffer(buffer);
	FILE *file = fopen(outputPath.c_str(), "wb");
	fwrite( buffer, 1, allocatedSize, file);
	fclose(file);
	delete [] buffer;

}
Beispiel #10
0
int main (int argc, char * argv[]){
  backBuffer = new ColorFloat[640*480];
  // allocate the ray direction lookup table
  Vector *directionTable = GenerateRayDirectionTable();

  const int numPrimitives = 1;
  Primitive *primitives = new Primitive[numPrimitives];
  
  const int numLightSources = 1;
  LightSource *lightSources = new LightSource[numLightSources];

  const int numVertices = 4;

  Vector *vertices = new Vector[numVertices];
  Scene(primitives, numPrimitives, vertices, numVertices, lightSources, numLightSources);
  
  SetupScene(primitives, numPrimitives, vertices, numVertices, lightSources, numLightSources);

  TraceScene(primitives, numPrimitives, lightSources, numLightSources, backBuffer, directionTable);

  /*alboroto para opengl*/
  glutInit(&argc, argv);  
  glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);  
  glutInitWindowSize(width, height);  
  glutInitWindowPosition(initx, inity);  
  window = glutCreateWindow("final");
  glutDisplayFunc(&DrawGLScene);  
  glutIdleFunc(&DrawGLScene);
  glutKeyboardFunc(&keyPressed);
  InitGL(width, height);

  /*  float * a = new float[3];
      glGetFloatv(GL_CURRENT_RASTER_POSITION,a);
      printf("x=%f y=%f z=%f\n",a[0],a[1],a[2]);*/
  glutMainLoop();
  /*fin alboroto de opengl*/

  // clean up
  for(int i=0; i<numPrimitives; i++) ClearPrimitiveType(primitives[i]);    
  delete[] lightSources;
  delete[] vertices;
  delete[] directionTable;
  delete[] backBuffer;
  return 0;
}
Beispiel #11
0
Scene configureScene(){
	// Create and configure camera
    Camera eye = Camera(Vector3f(0.0f, 0.0f, 0.0f),
						Vector3f(1.0f, 0.0f, 0.0f),
						Vector3f(0.0f, 1.0f, 0.0f),
						Vector3f(0.0f, 0.0f, -1.0f),
						0.1);
	float l = -0.1, r = 0.1, b = -0.1, t = 0.1, d = 0.1;
	eye.setResolution(nx, ny);
	eye.setFocalLength(d);
	eye.setPlane(l, r, t, b);

	// Create geometry
	Surface* p = new Plane(0.0f, 1.0f, 0.0f, 2.0f,
		new Material(Color(0.2f, 0.2f, 0.2f),
					 Color(1.0f, 1.0f, 1.0f),
					 Color(0.0f, 0.0f, 0.0f), 0));

	Surface* s1 = new Sphere(Vector3f(-4.0f, 0.0f, -7.0f), 1.0f,
		new Material(Color(0.2f, 0.0f, 0.0f),
					 Color(1.0f, 0.0f, 0.0f),
					 Color(0.0f, 0.0f, 0.0f), 0));

	Surface* s2 = new Sphere(Vector3f(0.0f, 0.0f, -7.0f), 2.0f,
		new Material(Color(0.0f, 0.2f, 0.0f),
					 Color(0.0f, 0.5f, 0.0f),
					 Color(0.5f, 0.5f, 0.5f), 32));

	Surface* s3 = new Sphere(Vector3f(4.0f, 0.0f, -7.0f), 1.0f,
		new Material(Color(0.0f, 0.0f, 0.2f),
					 Color(0.0f, 0.0f, 1.0f),
					 Color(0.0f, 0.0f, 0.0f), 0));

	Surface* objs[] = {s1, s2, s3, p};

	// Create light(s)
	LightGroup *lights = new LightGroup();
	(*lights).push_back((Light *)new PointLight(Vector3f(-4.0f, 4.0f, -3.0), 1.0f, 1, 0, 0));

	// Create scene
	Scene scene = Scene(&eye, new SurfaceGroup(objs, 4), lights);
	return scene;
}
Beispiel #12
0
/* Checks for and applies pending this->ui updates. */
void Renderer::checkUIState() {
    // If the shader mode has changed, re-link the mode variable
    if (this->shader->mode != this->ui->shader_mode) {
        this->shader->mode = this->ui->shader_mode;
        char mode_name[5] = "mode";
        this->shader->linkf(this->shader->mode, mode_name);
    }
    // If we need to rebuild the vertex buffers, do so
    if (this->ui->rebuild_scene) {
        this->ui->rebuild_scene = false;
        //this->scene->update();
    }
    // If we need to raytrace the scene, do so
    if (this->ui->raytrace_scene) {
        this->ui->raytrace_scene = false;
        // Spawn the raytracer thread and detach it to keep doing OpenGL stuff
        thread(Assignment::raytrace, this->ui->camera, Scene(*this->scene))
            .detach();
    }
}
Beispiel #13
0
void main(int argc, char* argv[]){
	/****************************************/
	/*   Initialize GLUT and create window  */
	/****************************************/

	glutInit(&argc, argv);

	//  Set the window x and y coordinates such that the 
	//  window becomes centered
	window.centerOnScreen();

	//  Connect to the windowing system + create a window
	//  with the specified dimensions and position
	//  + set the display mode + specify the window title.
	glutInitWindowSize(window.window_width, window.window_height);
	glutInitWindowPosition(window.window_x, window.window_y);

	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	main_window = glutCreateWindow("Bind Mesh");
	
	init();

	glutDisplayFunc(onDisplay);
	glutReshapeFunc(onReshape);
	glutKeyboardFunc(onKeyboard);
	glutMouseFunc(onMouse);
	glutMotionFunc(onMotion);
	glutEntryFunc(onEntry);

	scene = Scene(800, 600);
	scene.createModel("wasp.skel", "wasp.skin");
	//scene.createSkel("tube.skel");

	window = Window(800, 600, scene);
	window.main_window = main_window;

	//  Setup all GLUI stuff
	setupGLUI();

	glutMainLoop();
}
Beispiel #14
0
Scene Scene::operator+(Scene* other)
{
	//seting dimensions of new Scene to bigest from both Scenes
	double min_x = other->_range_x->getBegin() < this->_range_x->getBegin() ? other->_range_x->getBegin() : this->_range_x->getBegin();
	double max_x = other->_range_x->getEnd() > this->_range_x->getEnd() ? other->_range_x->getEnd() : this->_range_x->getEnd();
	double min_y = other->_range_y->getBegin() < this->_range_y->getBegin() ? other->_range_y->getBegin() : this->_range_y->getBegin();
	double max_y = other->_range_y->getEnd() > this->_range_y->getEnd() ? other->_range_y->getEnd() : this->_range_y->getEnd();

	Scene new_scene = Scene(new Range(min_x,max_x), new Range(min_y,max_y));

	//copying every object from both Scenes
	for (int i = 0; i < this->_internal_objects.size(); i++)
	{
		Object* new_o = this->_internal_objects[i]->copy();
		new_scene.add(new_o);
	}
	for (int i = 0; i < other->_internal_objects.size(); i++)
	{
		Object* new_o = other->_internal_objects[i]->copy();
		new_scene.add(new_o);
	}
	return new_scene;
}
Beispiel #15
0
 _scn_impl( const std::string &fileName, bool verbose )
     : m_scene( Scene( fileName, verbose ) )
     , m_currentSeconds( m_scene.getMinTime() )
 {
 }
Beispiel #16
0
Game::Game()
{
    Scene();
    view = new sf::View(sf::FloatRect(0, 0, 100, 100));

}
Beispiel #17
0
// The MAIN function, from here we start the application and run the game loop
int main()
{
	// Init GLFW
	glfwInit();

	GLFWmonitor* primary = glfwGetPrimaryMonitor();
	const GLFWvidmode* mode = glfwGetVideoMode(primary);
	
	// Set all the required options for GLFW
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
	glfwWindowHint(GLFW_SAMPLES, 4);

	// Create a GLFWwindow object that we can use for GLFW's functions
	GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "LearnOpenGL", primary, nullptr);
	glfwMakeContextCurrent(window);

	// Set the required callback functions
	glfwSetKeyCallback(window, key_callback);
	glfwSetCursorPosCallback(window, mouse_callback);
	glfwSetScrollCallback(window, scroll_callback);

	// Options
	glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

	// Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions
	glewExperimental = GL_TRUE;
	// Initialize GLEW to setup the OpenGL Function pointers
	glewInit();

	// Define the viewport dimensions
	glViewport(0, 0, mode->width, mode->height);

	// Setup some OpenGL options
	glEnable(GL_DEPTH_TEST);

	Scene scene = Scene("default");

	// Build and compile our shader program
	Shader defaultShader("default.vs", "default.frag", "default.gs");
	Shader alternateShader("alternate.vs", "alternate.frag", "alternate.gs");
	Shader* currentShader = &defaultShader;
	Shader skyboxShader("skybox.vs", "skybox.frag");

	#pragma region "object_initialization"

	GLfloat skyboxVertices[] = {
		// Positions          
		-10.0f,  10.0f, -10.0f,
		-10.0f, -10.0f, -10.0f,
		10.0f, -10.0f, -10.0f,
		10.0f, -10.0f, -10.0f,
		10.0f,  10.0f, -10.0f,
		-10.0f,  10.0f, -10.0f,

		-10.0f, -10.0f,  10.0f,
		-10.0f, -10.0f, -10.0f,
		-10.0f,  10.0f, -10.0f,
		-10.0f,  10.0f, -10.0f,
		-10.0f,  10.0f,  10.0f,
		-10.0f, -10.0f,  10.0f,

		10.0f, -10.0f, -10.0f,
		10.0f, -10.0f,  10.0f,
		10.0f,  10.0f,  10.0f,
		10.0f,  10.0f,  10.0f,
		10.0f,  10.0f, -10.0f,
		10.0f, -10.0f, -10.0f,

		-10.0f, -10.0f,  10.0f,
		-10.0f,  10.0f,  10.0f,
		10.0f,  10.0f,  10.0f,
		10.0f,  10.0f,  10.0f,
		10.0f, -10.0f,  10.0f,
		-10.0f, -10.0f,  10.0f,

		-10.0f,  10.0f, -10.0f,
		10.0f,  10.0f, -10.0f,
		10.0f,  10.0f,  10.0f,
		10.0f,  10.0f,  10.0f,
		-10.0f,  10.0f,  10.0f,
		-10.0f,  10.0f, -10.0f,

		-10.0f, -10.0f, -10.0f,
		-10.0f, -10.0f,  10.0f,
		10.0f, -10.0f, -10.0f,
		10.0f, -10.0f, -10.0f,
		-10.0f, -10.0f,  10.0f,
		10.0f, -10.0f,  10.0f
	};

	 //wVertex data
	GLfloat vertices[] = {
		//positions			//colors
		-0.5f,  0.5f, 0.0f,	1.0f, 0.0f, 0.0f, // Top-left
		0.5f,  0.5f, 0.0f,	0.0f, 1.0f, 0.0f, // Top-right
		0.5f, -0.5f, 0.0f,	0.0f, 0.0f, 1.0f, // Bottom-right
		-0.5f, -0.5f, 0.0f,	1.0f, 1.0f, 0.0f  // Bottom-left
	};

	/*GLfloat* floatVertices = scene.getVertices();
	GLfloat vertices[sizeof(floatVertices)/sizeof(GLfloat)];
	for (int i = 0; i < 24 ; i++) {
		vertices[i] = floatVertices[i];
	}*/
	
	glGenBuffers(1, &VBO);
	glGenVertexArrays(1, &VAO);
	//// Bind the Vertex Array Object first, then bind and set vertex buffer(s) and attribute pointer(s).
	glBindVertexArray(VAO);

	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), &vertices, GL_STATIC_DRAW);

	//// Position attribute
	//setAttributeData(0, 3, 6, 0);
	//// Color attribute
	//setAttributeData(1, 3, 6, 3);

	// Position attribute
	std::vector<int> va = scene.getVecAtrib();
	setAttributeData(va[0], va[1], va[2], va[3]);
	// Color attribute
	std::vector<int> ca = scene.getColAtrib();
	setAttributeData(ca[0], ca[1], ca[2], ca[3]);

	// Unbind VAO
	glBindVertexArray(0);

	// Setup skybox VAO
	GLuint skyboxVAO, skyboxVBO;
	glGenVertexArrays(1, &skyboxVAO);
	glGenBuffers(1, &skyboxVBO);
	glBindVertexArray(skyboxVAO);
	glBindBuffer(GL_ARRAY_BUFFER, skyboxVBO);
	glBufferData(GL_ARRAY_BUFFER, sizeof(skyboxVertices), &skyboxVertices, GL_STATIC_DRAW);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
	glBindVertexArray(0);

	#pragma endregion

	// Cubemap (Skybox)
	std::vector<const GLchar*> faces = scene.getFaces();
	/*faces.push_back("Resources/skybox/right.jpg");
	faces.push_back("Resources/skybox/left.jpg");
	faces.push_back("Resources/skybox/top.jpg");
	faces.push_back("Resources/skybox/bottom.jpg");
	faces.push_back("Resources/skybox/back.jpg");
	faces.push_back("Resources/skybox/front.jpg");*/
	GLuint cubemapTexture = loadCubemap(faces);

	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	

	// Game loop
	while (!glfwWindowShouldClose(window))
	{
		// Set frame time
		GLfloat currentFrame = glfwGetTime();
		deltaTime = currentFrame - lastFrame;
		lastFrame = currentFrame;

		// Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions
		glfwPollEvents();
		Input_Switch_Shader(&currentShader, &defaultShader, &alternateShader);
		Do_Movement();

		// Check camera position and see if it reaches the boundary of the room 
		// reset the camera to the other side of the room when it crosses the boundary
		glm::vec3 camPos = camera.getPostion();
		if (abs(camPos.x) > 5.0f)
		{
			camPos.x = -1 * camPos.x;
			camera.setPosition(camPos);
			Switch_Shader(&currentShader, &defaultShader, &alternateShader);
		}
		if (abs(camPos.y) > 5.0f)
		{
			camPos.y = -1 * camPos.y;
			camera.setPosition(camPos);
			Switch_Shader(&currentShader, &defaultShader, &alternateShader);
		}
		if (abs(camPos.z) > 5.0f)
		{
			camPos.z = -1 * camPos.z;
			camera.setPosition(camPos);
			Switch_Shader(&currentShader, &defaultShader, &alternateShader);
		}

		// Render
		// Clear the colorbuffer
		glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		// Draw the scene
		currentShader->Use();

		// Create camera transformation
		glm::mat4 view = camera.GetViewMatrix();
		GLint viewLoc = glGetUniformLocation(currentShader->Program, "view");
		glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));

		// Calculate the model matrix for each object and pass it to shader before drawing
		glm::mat4 model;
		GLint modelLoc = glGetUniformLocation(currentShader->Program, "model");
		glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));

		glm::mat4 projection = glm::perspective(camera.Zoom, (float)mode->width / (float)mode->height, 0.1f, 1000.0f);
		//currentShader->Use();
		GLint projLoc = glGetUniformLocation(currentShader->Program, "projection");
		glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));

		glBindVertexArray(VAO);
		glDrawArrays(GL_POINTS, 0, 4);
		glBindVertexArray(0);

		//Draw skybox as last
		glDepthFunc(GL_LEQUAL);  // Change depth function so depth test passes when values are equal to depth buffer's content
		skyboxShader.Use();
		view = glm::mat4(glm::mat3(camera.GetViewMatrix()));	// Remove any translation component of the view matrix
		glUniformMatrix4fv(glGetUniformLocation(skyboxShader.Program, "view"), 1, GL_FALSE, glm::value_ptr(view));
		glUniformMatrix4fv(glGetUniformLocation(skyboxShader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
		// skybox cube
		glBindVertexArray(skyboxVAO);
		glActiveTexture(GL_TEXTURE0);
		glUniform1i(glGetUniformLocation(skyboxShader.Program, "skybox"), 0);
		glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
		glDrawArrays(GL_TRIANGLES, 0, 36);
		glBindVertexArray(0);
		glDepthFunc(GL_LESS); // Set depth function back to default

		// Swap the screen buffers
		glfwSwapBuffers(window);
	}
	// Properly de-allocate all resources once they've outlived their purpose
	glDeleteVertexArrays(1, &VAO);
	glDeleteBuffers(1, &VBO);
	glDeleteVertexArrays(1, &VAO);
	glDeleteBuffers(1, &VBO);
	// Terminate GLFW, clearing any resources allocated by GLFW.
	glfwTerminate();
	return 0;
}
Beispiel #18
0
/*
 *  Draw scene using shadow volumes
 */
static void DrawSceneWithShadows()
{
   //  PASS 1:
   //  Draw whole scene as shadowed
   //  Lighting is still off
   //  The color should be what the object looks like when in the shadow
   //  This sets the object depths in the Z-buffer
   Scene(-1);

   //  Make color buffer and Z buffer read-only
   glColorMask(0,0,0,0);
   glDepthMask(0);
   //  Enable stencil
   glEnable(GL_STENCIL_TEST);
   //  Always draw regardless of the stencil value
   glStencilFunc(GL_ALWAYS,0,0xFFFFFFFF);

   //  Enable face culling
   glEnable(GL_CULL_FACE);

   //  This switch is for demonstration purposes only
   //  Normally you would pick just one method (mode=4 or mode=5)
   //  Modes 0 to 3 are for demonstration purposes
   //  which do not result in correctly rendered shadows
   switch (mode)
   {
      //  Shadowed objects only - do nothing
      case 0:
         break;
      //  Front shadows
      //  This is for demonstation purposes only
      case 1:
         glFrontFace(GL_CCW);
         glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);
         Scene(0);
         break;
      //  Back shadows
      //  This is for demonstation purposes only
      case 2:
         glFrontFace(GL_CW);
         glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);
         Scene(0);
         break;
      //  Lit parts of objects only (do Z-pass to help find this)
      case 3:
      //  Z-pass variation
      //  Count from the eye to the object
      case 4:
         //  PASS 2:
         //  Draw only the front faces of the shadow volume
         //  Increment the stencil value on Z pass
         //  Depth and color buffers unchanged
         glFrontFace(GL_CCW);
         glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);
         Scene(0);
         //  PASS 3:
         //  Draw only the back faces of the shadow volume
         //  Decrement the stencil value on Z pass
         //  Depth and color buffers unchanged
         glFrontFace(GL_CW);
         glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);
         Scene(0);
         break;
      //  Z-fail variation
      //  Count from the object to infinity
      case 5:
         //  PASS 2:
         //  Draw only the back faces of the shadow volume
         //  Increment the stencil value on Z fail
         //  Depth and color buffers unchanged
         glFrontFace(GL_CW);
         glStencilOp(GL_KEEP,GL_INCR,GL_KEEP);
         Scene(0);
         //  PASS 3:
         //  Draw only the front faces of the shadow volume
         //  Decrement the stencil value on Z fail
         //  Depth and color buffers unchanged
         glFrontFace(GL_CCW);
         glStencilOp(GL_KEEP,GL_DECR,GL_KEEP);
         Scene(0);
         break;
      default:
         break;
   }

   //  Disable face culling
   glDisable(GL_CULL_FACE);
   //  Make color mask and depth buffer read-write
   glColorMask(1,1,1,1);
   //  Update the color only where the stencil value is 0
   //  Do not change the stencil
   glStencilFunc(GL_EQUAL,0,0xFFFFFFFF);
   glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
   //  Redraw only if depth matches front object
   glDepthFunc(GL_EQUAL);

   //  PASS 4:
   //  Enable lighting
   //  Render the parts of objects not in shadows
   //  (The mode test is for demonstrating unlit objects only)
   Light(1);
   if (mode) Scene(1);

   //  Undo changes (no stencil test, draw if closer and update Z-buffer)
   glDisable(GL_STENCIL_TEST);
   glDepthFunc(GL_LESS); 
   glDepthMask(1);
   //  Disable lighting
   Light(0);
}
Beispiel #19
0
Renderer::Renderer() {
    camera = Camera(Point3(0.0f, 0.0f, 2.0f), Vector3(0.0f, 0.0f, -1.0f));
    scene = Scene();
}
Beispiel #20
0
Panel::Panel()
{
    Scene();

}
Beispiel #21
0
void XMLWriter::Body(QDomElement& root){
    auto body = doc.createElement("Body");
    root.appendChild(body);
    Scene(body);
}
Beispiel #22
0
GLFWwindow* createWindow()
{
    if (!glfwInit()) {
        return NULL;
    }
    
    glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 );
    glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 2 );
    glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
    glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
    
    return glfwCreateWindow(1024, 640, gltutglfwName, NULL, NULL);
}

Scene scene = Scene();

void onFramebufferResize(GLFWwindow* window, int width, int height)
{
    scene.reshape(width, height);
    glfwSwapBuffers(window);

}

static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    static bool depthClampingActive = false;

    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
        glfwSetWindowShouldClose(window, GL_TRUE);
    } else if (key == GLFW_KEY_1 && action == GLFW_PRESS) {
Beispiel #23
0
Scene* Scene::addScene() {
    Scene::scenes.push_back(Scene());
    return &(Scene::scenes.back());
}
Beispiel #24
0
bool RenderHub::addScene()
{
    sceneList.push_back(Scene());

    return true;
}
//The main function
int Main::start() {

	//Init
	if (init() == -1) {
		fprintf(stderr, "Could not initialise the program\n");
		return -1;
	}
	
	//Create the scene
	Scene scene = Scene(window);
	Camera* camera = scene.getCamera();
	camera->setFOV(45);

	//Create the loaders
	ModelLoader loader = ModelLoader();
	TextureLoader textureLoader = TextureLoader();

	//Create the models
	Model texturedModel = loader.loadToVao_OBJ_Textured("models/cube.obj", "textures/cube.bmp", glm::vec3(-3, 0, -5));
	Model monkey = loader.loadToVao_OBJ("models/suzanne.obj", glm::vec3(0, 0, -5));
	monkey.texture(textureLoader.loadBMP_custom("textures/suzanne texture.bmp"));
	monkey.setReflectivity(0.0);

	//Create an array of the same entities and add them to the scene
	std::vector<Entity> cubes;
	std::vector<glm::vec3> positions;
	int numOfCubes = 1000;
	Cube cubeTemp = Cube();

	//Create the positions array
	for (int i = 0; i < numOfCubes; i++) {
		positions.insert(positions.end(), glm::vec3(rand() % 100, rand() % 100, rand() % 100));
	}

	//Generate cloned cubes and put them at different positions
	cubes = cubeTemp.cloneEntity(positions);

	//Add the cubes to the entity map
	for (int i = 0; i < cubes.size(); i++) {
		scene.addEntity(&cubes[i]);
	}

	//Add the models to the scene
	scene.addModel(texturedModel);
	scene.addModel(monkey);

	//Create the onclick function
	auto onClick = []() {
		exit(0);
	};

	//Create the UIs
	UIButton button = UIButton(0.06f, 0.05f, glm::vec2(1, -1), window, onClick);
	button.setAlignment(UIButton::ALIGN_BOTTOM_RIGHT);
	button.texture(textureLoader.loadBMP_custom("textures/Exit.bmp"));
	UIElement* ui = &button;

	//Add the UI
	scene.addPauseUI(ui);

	//Main loop
	while (!window.shouldClose()) {

		//Run the scene
		scene.run();

		//Run the UI

		//Swap the buffers and poll events
		glfwSwapBuffers(window.getWindow());
		glfwPollEvents();
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	}

	//Terminate glfw
	glfwTerminate();

	return 0;
}
Beispiel #26
0
void Parser::parse(vector<Light> &lights,
                   vector<Primitive*> &primitives,
                   Scene &scene){
    FILE *file;
    file = fopen(INPUT_FILE, "r");
    if (file == NULL){
        cout << "Error: opening input file" << endl;
        exit(1);
    }
    char next_line[MAX_LINE_LENGTH] = "";
    while (!feof(file)){
        int successful_read;
        // the if statement prevents parsing the last line twice, causing the last primitive to have 2 instances
        if((successful_read = fscanf(file, "%s", next_line)) > 0){
            if (strncmp(next_line, "scene", 5) == 0){
                float upVectorX, upVectorY, upVectorZ, centerX, centerY, centerZ, width;
                unsigned int Rx, Ry;
                float ambient[3]; // ambient[0] = R, ambient[1] = G, ambient[2] = B
                fscanf(file, " %f,%f,%f,%f,%f,%f,%f,%u,%u,%f,%f,%f", &upVectorX, &upVectorY, &upVectorZ, &centerX, &centerY, &centerZ, &width, &Rx, &Ry, ambient, ambient + 1, ambient + 2);
                scene = Scene(Vector3f(upVectorX, upVectorY, upVectorZ),
                            Vector3f(centerX, centerY, centerZ),
                            width,
                            Ry,
                            Rx,
                            Vector3f(ambient),
                            &primitives,
                            &lights);
                            cout << "Scene created!" << endl;
            }
            if (strcmp(next_line, "spher") == 0){
                float x, y, z, radius, shine;
                float ka[3];
                float ks[3];
                float kd[3];
                char mirror = '\0';
                bool isMirror = false;
                fscanf(file, " %f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%c", &x, &y, &z, &radius, ka, ka + 1, ka + 2, kd, kd + 1, kd + 2, ks, ks + 1, ks + 2, &shine, &mirror);
                if (mirror == 'M') {
                    isMirror = true;
                }
                Sphere *spher = new Sphere(Vector3f(x, y, z),
                             radius,
                             Vector3f(ka),
                             Vector3f(ks),
                             Vector3f(kd),
                             shine,
                             isMirror);
                primitives.push_back(spher);
                cout << "Sphere created!" << endl;
            }
            if (strncmp(next_line, "plane", 5) == 0){
                float normalX, normalY, normalZ, centerX, centerY, centerZ, width, length, shine;
                float ka[3];
                float ks[3];
                float kd[3];
                char mirror = '\0';
                bool isMirror = false;
                fscanf(file, " %f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f %c", &normalX, &normalY, &normalZ, &centerX, &centerY, &centerZ, &width, &length, ka, ka + 1, ka + 2, kd, kd + 1, kd + 2, ks, ks + 1, ks + 2, &shine, &mirror);
                if (mirror == 'M') {
                    isMirror = true;
                }
                Plane *plane = new Plane(Vector3f(normalX, normalY, normalZ),
                            Vector3f(centerX, centerY, centerZ),
                            width,
                            length,
                            shine,
                            Vector3f(ka),
                            Vector3f(kd),
                            Vector3f(ks),
                            isMirror);
                primitives.push_back(plane);
                cout << "Plane created!" << endl;
            }
            if (strncmp(next_line, "light", 5) == 0){
                float dirX, dirY, dirZ;
                float intensity[3];
                float positionX, positionY, positionZ, angle;
                int params = fscanf(file, " %f,%f,%f,%f,%f,%f,%f", &dirX, &dirY, &dirZ, intensity, intensity + 1, intensity + 2, &positionX);
                if (params < 7){
                    Light light(Vector3f(dirX, dirY, dirZ),
                                Vector3f(intensity));
                    lights.push_back(light);
                }
                else {
                    fscanf(file, ",%f,%f,%f", &positionY, &positionZ, &angle);
                    Light spot_light(Vector3f(dirX, dirY, dirZ),
                                     Vector3f(intensity),
                                     Vector3f(positionX, positionY, positionZ),
                                     angle);
                    lights.push_back(spot_light);
                }
                cout << "Light created!" << endl;
            }
        }
    }
    fclose(file);
}
Beispiel #27
0
Scene::Scene()
{
	this->NO_ERROR = new GraphicError("no error");
	Scene(-100, 100, -100, 100); //default widith, and height
}
Beispiel #28
0
//
//  glMethods.cpp
//  CLTest
//
//  Created by Antar - SSD on 08/12/12.
//  Copyright (c) 2012 Àlex Vergara. All rights reserved.
//

#include "glMethods.h"

//globals
static int mode = NORMAL_MODE;
static double aWidth = SCREEN_W, aheigth = SCREEN_H;
static Scene scene = Scene();
static ContainSphere contSphere = scene.calculateSphere();

//Cams
static Cam camera = Cam(CAM_MOVEMENT_LOOKAT, Point (0,1,0), Point (0,0,0), contSphere, SCREEN_W, SCREEN_H);
static int zoomMode = CAM_ZOOM_FOVYORTHO;
static int lightMode = GL_FILL;

//mouse
static int xO, yO;


void firstPaint(void)
{
    //Clear Zone
    glClearColor(0.0 , 0.0, 0.0,0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
void Render()
{
	ovrFrameTiming frameTiming = ovrHmd_BeginFrameTiming(HMD, 0);

	// 箱の回転の値を更新
	rotationBoxValue += 2.0f*frameTiming.DeltaSeconds;

	// キーボード等で操作する場合の目の位置を指定します。
	static OVR::Vector3f EyePos;
	EyePos.x = 0.0f, EyePos.y = 0.0f, EyePos.z = 0.0f;

	// マウスの回転等でYawを操作する場合に使用する。
	static float eyeYaw = 0;

	// センサーから取得
	ovrPosef movePose = ovrHmd_GetSensorState(HMD, frameTiming.ScanoutMidpointSeconds).Predicted.Pose;
	static ovrPosef eyeRenderPose[2];

	//身長ぶんの考慮をする際の計算
	//EyePos.y = ovrHmd_GetFloat(HMD, OVR_KEY_EYE_HEIGHT, EyePos.y);	

	// 今回は TriangleList しか使わない。
	g_pImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	//レンダーターゲットの設定
	g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetViewOculus, g_pDepthStencilViewOculus);

	//画面のクリア・深度バッファクリア
	float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; // R,G,B,A の順番
	g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetViewOculus, ClearColor);
	g_pImmediateContext->ClearDepthStencilView(g_pDepthStencilViewOculus, D3D11_CLEAR_DEPTH, 1.0f, 0);

	//それぞれの目に対応するシーンを描画します。
	for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
	{
		ConstantBuffer cb;
		ovrEyeType eye = HMDDesc.EyeRenderOrder[eyeIndex];
		eyeRenderPose[eye] = ovrHmd_GetEyePose(HMD, eye);

		// ビュー行列を計算します。
		OVR::Matrix4f rotation = OVR::Matrix4f::RotationY(eyeYaw);											// あらかじめ(マウスなどで)計算された回転行列を適用する
		OVR::Matrix4f resultRotation = rotation * OVR::Matrix4f(eyeRenderPose[eye].Orientation) *			// 目の姿勢(回転)を計算する
										OVR::Matrix4f(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1);	// 軸に合うように方向を合わせる
		OVR::Vector3f resultUp = resultRotation.Transform(OVR::Vector3f(0, 1, 0));							// 上ベクトルを計算
		OVR::Vector3f forward = resultRotation.Transform(OVR::Vector3f(0, 0, -1));							// 前ベクトルを計算
		OVR::Vector3f resultEyePos = EyePos + rotation.Transform(eyeRenderPose[eye].Position);				// 最終的な目の位置を計算する
		OVR::Vector3f resultEyeAt = EyePos + rotation.Transform(eyeRenderPose[eye].Position) + forward;		// 最終的な目視先を計算する

		// 計算した値から xnamath でビュー行列を計算します。
		XMVECTOR Eye = XMVectorSet(resultEyePos.x, resultEyePos.y, resultEyePos.z, 0.0f);		//カメラの位置
		XMVECTOR At = XMVectorSet(resultEyeAt.x, resultEyeAt.y, resultEyeAt.z, 0.0f);			//カメラの注視先
		XMVECTOR Up = XMVectorSet(resultUp.x, resultUp.y, resultUp.z, 0.0f);					//カメラの真上のベクトル
		g_View = XMMatrixLookAtLH(Eye, At,Up) * XMMatrixTranslation(EyeRenderDesc[eye].ViewAdjust.x, EyeRenderDesc[eye].ViewAdjust.y, EyeRenderDesc[eye].ViewAdjust.z);

		// EyeRenderDesc からプロジェクション行列を計算します。
		// 目の中心からそれぞれ上下左右のfovの正接値(tan)が格納されているので libovr 専用の関数で計算します。
		// OVR::Matrix4f は xnamath と違い行と列が反対なので転置にしておきます。
		OVR::Matrix4f proj = OVR::CreateProjection(false, EyeRenderDesc[eye].Fov, 0.01f, 100.0f);
		proj.Transpose();
		memcpy_s(&g_Projection, 64, &proj, 64);		

		//ビューポートの設定(片目ぶんずつ設定)
		D3D11_VIEWPORT vp;
		vp.TopLeftX = EyeRenderViewport[eye].Pos.x;
		vp.TopLeftY = EyeRenderViewport[eye].Pos.y;
		vp.Width = EyeRenderViewport[eye].Size.w;
		vp.Height = EyeRenderViewport[eye].Size.h;
		vp.MinDepth = 0.0f;
		vp.MaxDepth = 1.0f;
		g_pImmediateContext->RSSetViewports(1, &vp);

		// コンスタントバッファに投げるための行列を設定
		// シェーダーに渡す際に転置行列になるため、ここで転置しておきます。
		cb.mView = XMMatrixTranspose(g_View);
		cb.mProjection = XMMatrixTranspose(g_Projection);

		//シーンを描画
		Scene(cb);
	}


	//ここでレンダーターゲットに描画したシーンをゆがませてバックバッファに描画します。
	DistortionMeshRender(3, HMD, frameTiming.TimewarpPointSeconds,eyeRenderPose);

	g_pSwapChain->Present(0, 0);
	//pRender->WaitUntilGpuIdle();  //今回はクエリ実装してない
	ovrHmd_EndFrameTiming(HMD);

}
Beispiel #30
0
#include <vector>
#include <map>

#include "Material.h"
#include "Mesh.h"
#include "Scene.h"


// global application data

// screen resolution
const int screenWidth = 600;
const int screenHeight = 600;

//scene object
Scene scene = Scene(std::vector<Mesh*>());

// vector of the keys that kaye been pressed
std::vector<bool> keysPressed;

//////////////////////////////////////////////////////
// Audio playback methods, just using bash commands
//////////////////////////////////////////////////////

void playAudio()
{
    system("afplay /Users/ataylor/Documents/Williams/Graphics/worldsurfer/incremental/mario_rr.mp3");
}

void killAudio()
{