bool CMeshLoader::loadVertexBufferObjectFromMesh(std::string const & fileName, int & TriangleCount, GLuint & PositionBufferHandle, GLuint & ColorBufferHandle, GLuint & NormalBufferHandle)
{
	CMesh * Mesh = loadASCIIMesh(fileName);
	if (! Mesh)
		return false;
   
	Mesh->resizeMesh(SVector3(1));
	Mesh->centerMeshByExtents(SVector3(0));
   Mesh->computeNormals();
   
	createVertexBufferObject(* Mesh, TriangleCount, PositionBufferHandle, ColorBufferHandle, NormalBufferHandle);
	
	return true;
}
Beispiel #2
0
Enemy::Enemy (float random)
{
	srand(random);

	Translation.X = rand() % 9 + 0.5;
	Translation.Y = 0.5;
	Translation.Z = rand() % 9 + 0.5;

	Scale.X = 1; 
	Scale.Y = 1;
	Scale.Z = 1;

	Rotation.Z = 0;
	Rotation.X = 0;
	Rotation.Y = rand() % 360;
	alive = 1;


	size = 0.38;

	next = 0;

	// First create a shader loader and check if our hardware supports shaders
	CShaderLoader ShaderLoader;
	if (! ShaderLoader.isValid())
	{
		std::cerr << "Shaders are not supported by your graphics hardware, or the shader loader was otherwise unable to load." << std::endl;
		waitForUser();
	}

	// Now attempt to load the shaders
	Shader = ShaderLoader.loadShader("Shaders/Lab3_vert.glsl", "Shaders/Lab3_frag.glsl");
	if (! Shader)
	{
		std::cerr << "Unable to open or compile necessary shader." << std::endl;
		waitForUser();
	}
	Shader->loadAttribute("aPosition");
	Shader->loadAttribute("aColor");
        Shader->loadAttribute("aNormal");

	// Now attempt to load the shaders
	Shader2 = ShaderLoader.loadShader("Shaders/Lab3_vert2.glsl", "Shaders/Lab3_frag.glsl");
	if (! Shader2)
	{
		std::cerr << "Unable to open or compile necessary shader." << std::endl;
		waitForUser();
	}
	Shader2->loadAttribute("aPosition");
	Shader2->loadAttribute("aColor");
        Shader2->loadAttribute("aNormal");
	

	// Attempt to load mesh
	CMesh * Mesh = CMeshLoader::loadASCIIMesh("Models/gargoyle500.m");
	if (! Mesh)
	{
		std::cerr << "Unable to load necessary mesh." << std::endl;
		waitForUser();
	}
	// Make out mesh fit within camera view
	Mesh->resizeMesh(SVector3(1));
	// And center it at the origin
	Mesh->centerMeshByExtents(SVector3(0));

	// Now load our mesh into a VBO, retrieving the number of triangles and the handles to each VBO
	CMeshLoader::createVertexBufferObject(* Mesh, TriangleCount, PositionBufferHandle, ColorBufferHandle, NormalBufferHandle);

}