void CameraInfo::createPerspectiveMatrix(float p_aspectRatio , 
										 float p_fieldOfViewAsRadians)
{
	m_aspectRatio = p_aspectRatio;
	m_fieldOfViewAsRadians = p_fieldOfViewAsRadians;
	createPerspectiveMatrix();
}
void CameraInfo::createPerspectiveMatrix(float p_aspectRatio , 
										 float p_fieldOfViewAsRadians, 
										 float p_nearClip, 
										 float p_farClip)
{
	m_aspectRatio = p_aspectRatio;
	m_fieldOfViewAsRadians = p_fieldOfViewAsRadians;
	m_nearPlane = p_nearClip;
	m_farPlane	= p_farClip;
	createPerspectiveMatrix();
}
Exemple #3
0
    /**
     * @brief Sets the projection matrix as a perspective matrix.
     *
     * Creates a perspective matrix with the given parameters and sets as the projection matrix.
     * @param fy Vertical field of view angle
     * @param in_aspect_ratio Ratio of width to the height of the viewport
     * @param in_near_plane Near plane
     * @param in_far_plane Far plane
     * @return The created perspective matrix.
     */
    Eigen::Matrix4f setPerspectiveMatrix (float fy, float in_aspect_ratio, float in_near_plane,float in_far_plane)
    {
        fovy = fy;
        aspect_ratio = in_aspect_ratio;
        near_plane = in_near_plane;
        far_plane = in_far_plane;

        Eigen::Matrix4f proj = createPerspectiveMatrix(fovy, aspect_ratio, near_plane, far_plane);
        setProjectionMatrix(proj);
        use_perspective = true;
        return proj;
    }
CameraInfo::CameraInfo(float p_aspectRatio, 
					   float p_fieldOfViewAsRadians/* =0.785398163f */, 
					   float p_nearPlane/* =0.1f */, 
					   float p_farPlane/* =10000.0f */)
	: Component( ComponentType::CameraInfo )
{
	m_projMat		= AglMatrix::identityMatrix();
	m_aspectRatio	= p_aspectRatio;
	m_fieldOfViewAsRadians	= p_fieldOfViewAsRadians;
	m_nearPlane		= p_nearPlane;
	m_farPlane		= p_farPlane;
	m_shadowMapIdx	= -1;
	m_ambientColor	= AglVector3(0.0f,0.0f,0.0f);
	m_fogColor		= AglVector3(0.0f,0.0f,0.0f);
	m_fogNearPlaneClosenessPercentage	= 1.0f;
	m_fogFarPlaneClosenessPercentage	= 1.0f;
	createPerspectiveMatrix();
}
void CameraInfo::createPerspectiveMatrix(float p_aspectRatio)
{
	m_aspectRatio = p_aspectRatio;
	createPerspectiveMatrix();
}
		inline matrix<4, 4, T> create_perspective_projection_matrix_fov(T fov, T aspect, T n, T f)
		{
			T hh = fov * T(0.5) * n;
			T hw = hh * aspect;
			return createPerspectiveMatrix(-hw, hw, hh, -hh, n, f);
		}
Exemple #7
0
int main(int argc, char *argv[])
{
	chdir("/Users/tjgreen/Documents/OpenGL/Sol");
	
	GLFWwindow *window = setupGLFW();
	GLuint skyboxTexture = initCubemap();
	
	//GLFWwindow* window2 = glfwCreateWindow(500, 500, "SolarSystem", NULL, NULL);
	//glfwMakeContextCurrent(window2);
	
	/*Cross platform compatibility stuff uncomment if not on mac
	GLenum err = glewInit();
	if (GLEW_OK != err)
	{
  		printf(stderr, "Error: %s\n", glewGetErrorString(err));
	}*/
	
	sunTexture = loadTexture("include/textures/Planets/sun2.jpg");
	sunNormal = loadTexture("include/textures/Planets/sunNormal.png");
	planetBuilder();
	init();
	createPerspectiveMatrix();
	
	initializePlanetButtons();
	
	glEnable(GL_CULL_FACE);
	glEnable(GL_MULTISAMPLE);
	glCullFace(GL_BACK);
	attachGUIShaders();
	
	float fpsFrames= 0;
	float lastTime = 0;
	while(!glfwWindowShouldClose(window))
	{
		GLfloat currentFrame = glfwGetTime();
        deltaTime = currentFrame - lastFrame;
        lastFrame = currentFrame;
        
        fpsFrames++;
		if(currentFrame - lastTime >= 1.0)
		{
			//printf("%f\n", 1000/fpsFrames);
			fpsFrames = 0;
			lastTime += 1.0;
		}
        
		glfwPollEvents();
		doMovement();
		
		glfwPollEvents();
		glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glViewport(0, 0, WIDTH, HEIGHT);

		drawSkybox(skyboxTexture);
		drawSun();
		drawPlanet();
		//glFrontFace(GL_CW);
		glEnable(GL_BLEND);
		glBlendFunc(GL_ONE, GL_ONE);
		drawAtmosphere();
		glDisable(GL_BLEND);
		//glFrontFace(GL_CCW);
		drawObj();
		drawMoon();
		
		//drawButton(button1);
		//drawPlanetButtons();
		
		if(stopRotation == 0){
			for(int i = 0; i < 11; i++)
			{
				orbitSpeedArray[i] += 0.1/planetInstanceArray[i].orbit;
			}
			for(int i = 0; i < 11; i++)
			{
				rotationSpeedArray[i] += 0.1/planetInstanceArray[i].day;
			}
			thetaY += 0.1;
		}
		
		glfwSwapBuffers(window);
	}
	
	glDeleteVertexArrays(1, &planetVAO);
    glDeleteBuffers(1, &planetVBO);
	
	glfwTerminate();
	return 0;
}
Exemple #8
0
 /**
  * @brief Sets the trackball projection matrix as perspective.
  * @param fy Vertical field of view angle.
  * @param aspect_ratio Ratio of width to the height of the viewport.
  * @param near_plane Near plane.
  * @param far_plane Far plane.
  * @return Return the created perspective matrix.
  */
 Eigen::Matrix4f setTrackballPerspectiveMatrix (float fy, float aspect_ratio, float near_plane, float far_plane)
 {
     Eigen::Matrix4f proj = createPerspectiveMatrix(fy, aspect_ratio, near_plane, far_plane);
     setTrackballProjectionMatrix(proj);
     return proj;
 }