void RenderManager::RenderAll() // Iterates through all the items in the render list // translates the render context to the object's base position then // renders the object. // Objects are drawn in order, opaque first then transparent, with transparent objects // further away being drawn first { BuildProjectionMatrix(); PrepareLights(); viewMatrixMade = false; DrawSkyBox(); DrawTerrain(); std::vector<int>::iterator vit; if (opaqueRenderList.size() > 0) { for (vit = opaqueRenderList.begin(); vit != opaqueRenderList.end(); vit++) { if (!DrawMesh(*vit)) { opaqueRenderList.erase(vit); } } } DrawWater(); std::list<int>::iterator lit; if (renderList.size() > 0) { for (lit = renderList.begin(); lit != renderList.end(); lit++) { if (!DrawMesh(*lit)) { renderList.erase(lit); } } } }
void Pipeline::Initialize(float fFOV, float fNear, float fFar) { this->fFOV = fFOV; this->fNear = fNear; this->fFar = fFar; BuildProjectionMatrix(); BuildOrthographicMatrix(); BuildCameraMatrix(); BuildViewProjection(); BuildViewOrthographic(); }
// Configures Ogre's rendering system for rendering Rocket. void RocketApplication::ConfigureRenderSystem() { Ogre::RenderSystem* render_system = Ogre::Root::getSingleton().getRenderSystem(); // Set up the projection and view matrices. Ogre::Matrix4 projection_matrix; BuildProjectionMatrix(projection_matrix); render_system->_setProjectionMatrix(projection_matrix); render_system->_setViewMatrix(Ogre::Matrix4::IDENTITY); // Disable lighting, as all of Rocket's geometry is unlit. render_system->setLightingEnabled(false); // Disable depth-buffering; all of the geometry is already depth-sorted. render_system->_setDepthBufferParams(false, false); // Rocket generates anti-clockwise geometry, so enable clockwise-culling. render_system->_setCullingMode(Ogre::CULL_CLOCKWISE); // Disable fogging. render_system->_setFog(Ogre::FOG_NONE); // Enable writing to all four channels. render_system->_setColourBufferWriteEnabled(true, true, true, true); // Unbind any vertex or fragment programs bound previously by the application. render_system->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM); render_system->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM); // Set texture settings to clamp along both axes. Ogre::TextureUnitState::UVWAddressingMode addressing_mode; addressing_mode.u = Ogre::TextureUnitState::TAM_CLAMP; addressing_mode.v = Ogre::TextureUnitState::TAM_CLAMP; addressing_mode.w = Ogre::TextureUnitState::TAM_CLAMP; render_system->_setTextureAddressingMode(0, addressing_mode); // Set the texture coordinates for unit 0 to be read from unit 0. render_system->_setTextureCoordSet(0, 0); // Disable texture coordinate calculation. render_system->_setTextureCoordCalculation(0, Ogre::TEXCALC_NONE); // Enable linear filtering; images should be rendering 1 texel == 1 pixel, so point filtering could be used // except in the case of scaling tiled decorators. render_system->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT); // Disable texture coordinate transforms. render_system->_setTextureMatrix(0, Ogre::Matrix4::IDENTITY); // Reject pixels with an alpha of 0. render_system->_setAlphaRejectSettings(Ogre::CMPF_GREATER, 0, false); // Disable all texture units but the first. render_system->_disableTextureUnitsFrom(1); // Enable simple alpha blending. render_system->_setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA); // Disable depth bias. render_system->_setDepthBias(0, 0); }
RsCamera::RsCamera( BtFloat width, BtFloat height, BtFloat near_plane, BtFloat far_plane, const RsViewport& viewPort ) { m_isPerspective = BtFalse; m_width = width; m_height = height; m_nearPlane = near_plane; m_farPlane = far_plane; m_viewport = viewPort; m_aspect = width / height; BuildProjectionMatrix(); }
void ShaderProjectiveTextureInterface::PerFrameInit() { // bind the texture GLuint texture_id = mesh->projTexture->texture->Bind(); //set parameters cgGLSetStateMatrixParameter(vertexModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); float zNear = 1.0f; float zFar = 1000.0f; M44 biasMatrix, lightViewMatrix, projectionMatrix; BuildBiasMatrix(biasMatrix); BuildLightViewMatrix(mesh->projTexture->ppc, lightViewMatrix); BuildProjectionMatrix(mesh->projTexture->ppc, zNear, zFar, projectionMatrix); lightViewMatrix = biasMatrix * projectionMatrix * lightViewMatrix; cgSetMatrixParameterfr(vertexTextureMatrix, (float*)lightViewMatrix.rows); cgGLSetTextureParameter(fragmentProjectiveMap, texture_id); }
RsCamera::RsCamera( BtFloat near_plane, BtFloat far_plane, BtFloat aspect_ratio, const RsViewport& viewPort, BtFloat field_of_view ) { m_nearPlane = near_plane; m_farPlane = far_plane; m_fieldOfView = field_of_view; m_width = RsUtil::GetWidth(); m_height = RsUtil::GetHeight(); m_v3Position = MtVector3(0, 0, 0); m_m3Orientation.SetIdentity(); m_aspect = aspect_ratio; m_viewport = viewPort; m_isPerspective = BtTrue; BuildProjectionMatrix(); m_width = 0; m_height = 0; }
void SetupMatrix() { // translate model to origin D3DXMATRIX world ; D3DXMatrixTranslation(&world, 0.0f, 0.0f, 0.0f) ; g_pd3dDevice->SetTransform(D3DTS_WORLD, &world) ; // set view D3DXVECTOR3 eyePt(0.0f, 0.0f, -10.0f) ; D3DXVECTOR3 upVec(0.0f, 1.0f, 0.0f) ; D3DXVECTOR3 lookCenter(0.0f, 0.0f, 0.0f) ; D3DXMATRIX view ; D3DXMatrixLookAtLH(&view, &eyePt, &lookCenter, &upVec) ; g_pd3dDevice->SetTransform(D3DTS_VIEW, &view) ; // set projection, use the matrix build by D3D /*D3DXMATRIX proj; D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4, 1.0f, 1.0f, 1000.0f) ;*/ // Use the matrix build by us D3DXMATRIX proj = BuildProjectionMatrix(D3DX_PI / 4, 1.0f, 1.0f, 1000); g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &proj) ; }
void Pipeline::UpdateProjection() { BuildProjectionMatrix(); BuildViewProjection(); }