Exemple #1
0
FBXObject::FBXObject(GLFWwindow* window, unsigned int programID, FreeCamera* _camera, const char* filename)
{
	m_programID = programID;
	m_camera = _camera;

	m_fbx = new FBXFile();
	m_fbx->load(filename);
	m_fbx->initialiseOpenGLTextures();
	CreateOpenGLBuffers(m_fbx);

	m_timer = 0.0f;

	m_lightYPos = vec3(10);
	m_fbx->getAnimationByIndex(0)->m_endFrame = 85;
}
void FBXProgram::Startup(const char* fileName, glm::mat4 position,
	char* name, float scale)
{
	this->scale = scale;
	this->name = name;
	this->position = position;

	fbx = new FBXFile();
	fbx->load(fileName);
	fbx->initialiseOpenGLTextures();
	CreateOpenGLBuffers();

	std::string vsSource = AssetLoader::ReadFile("./data/Shaders/FBXVS.txt");

	std::string fsSource = AssetLoader::ReadFile("./data/Shaders/FBXFS.txt");

	Create(vsSource, fsSource);
}
FBXObject::FBXObject(char * filename, unsigned int program, TweakBar* tweaks, bool animated)
{
	m_programID = program;
	m_tweaks = tweaks;
	m_timer = 0;
	m_animated = animated;

	m_fbx = new FBXFile();
	
	if(!(m_fbx->load(filename, FBXFile::UNITS_CENTIMETER)))
	{
		std::cout << filename << " could not be loaded." << std::endl;
	}

	m_fbx->initialiseOpenGLTextures();

	CreateOpenGLBuffers();

	

}
Exemple #4
0
void Scene::GenerateTerrain(int _dimensions, int _terrScale, float _terrAmplitude)
{
	int resizeNum = _dimensions * _dimensions;

	vertices.resize(resizeNum);

	for (unsigned int r = 0; r < _dimensions; ++r)
	{
		for (unsigned int c = 0; c < _dimensions; ++c)
		{
			vertices[r * _dimensions + c].position = glm::vec4((float)c, 0, (float)r, 1);

			glm::vec3 colour = glm::vec3(1, 1, 1);

			vertices[r * _dimensions + c].normal = glm::vec3(0, 1, 0);
			vertices[r * _dimensions + c].uv = glm::vec2((float)c / _dimensions, (float)r / _dimensions);
		}
	}

	//defining index count based of quad count (2 tri's = 1 quad)
	indices = new unsigned int[(_dimensions - 1) * (_dimensions - 1) * 6];
	unsigned int index = 0;

	for (unsigned int r = 0; r < (_dimensions - 1); ++r)
	{
		for (unsigned int c = 0; c < (_dimensions - 1); ++c)
		{
			//tri 1
			indices[index++] = r * _dimensions + c;
			indices[index++] = (r + 1) * _dimensions + c;
			indices[index++] = (r + 1) * _dimensions + (c + 1);

			//tri 2
			indices[index++] = r * _dimensions + c;
			indices[index++] = (r + 1) * _dimensions + (c + 1);
			indices[index++] = r * _dimensions + (c + 1);
		}
	}

	//save function parametres for member varibles for external use
	gridRows = _dimensions;
	gridColumns = _dimensions;

	//generating perlin data
	float* perlinData = GeneratePerlinData(_dimensions, _terrScale, _terrAmplitude);

	GenerateNormals();

	CreateOpenGLBuffers(vertices);

	//generating noise texture
	glGenTextures(1, &perlinTexture);
	glBindTexture(GL_TEXTURE_2D, perlinTexture);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, 64, 64, 0, GL_RED, GL_FLOAT, perlinData);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}