// Renders space station and adjacent city if applicable // For orbital starports: renders as normal // For surface starports: // Lighting: Calculates available light for model and splits light between directly and ambiently lit // Lighting is done by manipulating global lights or setting uniforms in atmospheric models shader void SpaceStation::Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { Body *b = GetFrame()->GetBody(); assert(b); if (!b->IsType(Object::PLANET)) { // orbital spaceport -- don't make city turds or change lighting based on atmosphere RenderModel(r, camera, viewCoords, viewTransform); } else { std::vector<Graphics::Light> oldLights; Color oldAmbient; SetLighting(r, camera, oldLights, oldAmbient); Planet *planet = static_cast<Planet*>(b); /* don't render city if too far away */ if (viewCoords.Length() < 1000000.0){ if (!m_adjacentCity) { m_adjacentCity = new CityOnPlanet(planet, this, m_sbody->seed); } m_adjacentCity->Render(r, camera, this, viewCoords, viewTransform); } RenderModel(r, camera, viewCoords, viewTransform, false); ResetLighting(r, oldLights, oldAmbient); } }
void SpaceStation::Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { Body *b = GetFrame()->GetBody(); assert(b); if (!b->IsType(Object::PLANET)) { // orbital spaceport -- don't make city turds or change lighting based on atmosphere RenderModel(r, camera, viewCoords, viewTransform); r->GetStats().AddToStatCount(Graphics::Stats::STAT_SPACESTATIONS, 1); } else { // don't render city if too far away if (viewCoords.LengthSqr() >= SQRMAXCITYDIST) { return; } std::vector<Graphics::Light> oldLights; Color oldAmbient; SetLighting(r, camera, oldLights, oldAmbient); if (!m_adjacentCity) { m_adjacentCity = new CityOnPlanet(static_cast<Planet*>(b), this, m_sbody->GetSeed()); } m_adjacentCity->Render(r, camera->GetContext()->GetFrustum(), this, viewCoords, viewTransform); RenderModel(r, camera, viewCoords, viewTransform, false); ResetLighting(r, oldLights, oldAmbient); r->GetStats().AddToStatCount(Graphics::Stats::STAT_GROUNDSTATIONS, 1); } }
void Renderer::RenderFrame(float time) { time_ = time; SetupFrame(); // draw scene Setup3DRendering(); glBindBuffer(GL_ARRAY_BUFFER, world.map_->vboId); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, world.map_->iboId); glEnableVertexAttribArray(2); for (unsigned int i = 0; i < renderables_.size(); ++i) { RenderFace(renderables_[i]); } RenderModel(); // draw gui and overlays // Setup2DRendering(); // font.PrintString("<Q3 BSP RENDERER>", glm::vec2(10.0f, 10.0f), // glm::vec4(1.0, 0.0, 0.0, 1.0)); // if (delta == 0) delta = 1; // // std::stringstream fps; // fps << "frametime in ms: " << delta << " fps: " << 1000 / delta; // font.PrintString(fps.str(), glm::vec2(10.0f, // (float)screen_height_-20.0f), glm::vec4(1.0, 1.0, 1.0, 1.0)); }
void Missile::Render(Graphics::Renderer *renderer, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { if (IsDead()) return; Propulsion::Render( renderer, camera, viewCoords, viewTransform ); RenderModel(renderer, camera, viewCoords, viewTransform); }
void RevRenderBaseHelper::RenderInstancedInstances( RevRenderMesh& instanceRendered ) { RevModel* model = instanceRendered.GetModel(); if( model == nullptr ) { return; } RenderModel( model, instanceRendered ); }
void Ship::Render(Graphics::Renderer *renderer, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { if (IsDead()) return; m_shipFlavour.ApplyTo(GetModel()); //angthrust negated, for some reason GetModel()->SetThrust(vector3f(m_thrusters), -vector3f(m_angThrusters)); if (m_landingGearAnimation) m_landingGearAnimation->SetProgress(m_wheelState); //strncpy(params.pText[0], GetLabel().c_str(), sizeof(params.pText)); RenderModel(renderer, viewCoords, viewTransform); // draw shield recharge bubble if (m_stats.shield_mass_left < m_stats.shield_mass) { const float shield = 0.01f*GetPercentShields(); renderer->SetBlendMode(Graphics::BLEND_ADDITIVE); glPushMatrix(); matrix4x4f trans = matrix4x4f::Identity(); trans.Translate(viewCoords.x, viewCoords.y, viewCoords.z); trans.Scale(GetPhysRadius()); renderer->SetTransform(trans); //fade based on strength Sfx::shieldEffect->GetMaterial()->diffuse = Color((1.0f-shield),shield,0.0,0.33f*(1.0f-shield)); Sfx::shieldEffect->Draw(renderer); glPopMatrix(); renderer->SetBlendMode(Graphics::BLEND_SOLID); } if (m_ecmRecharge > 0.0f) { // ECM effect: a cloud of particles for a sparkly effect vector3f v[100]; for (int i=0; i<100; i++) { const double r1 = Pi::rng.Double()-0.5; const double r2 = Pi::rng.Double()-0.5; const double r3 = Pi::rng.Double()-0.5; v[i] = vector3f(viewTransform * ( GetPosition() + GetPhysRadius() * vector3d(r1, r2, r3).Normalized() )); } Color c(0.5,0.5,1.0,1.0); float totalRechargeTime = GetECMRechargeTime(); if (totalRechargeTime >= 0.0f) { c.a = m_ecmRecharge / totalRechargeTime; } Sfx::ecmParticle->diffuse = c; renderer->SetBlendMode(Graphics::BLEND_ALPHA_ONE); renderer->DrawPointSprites(100, v, Sfx::ecmParticle, 50.f); } }
void GraphicsDeviceInterface::VertexPipeline(ID3D11Buffer* vertexBuffer, std::vector<VERTEX>* vertices, D3DXMATRIX* transform, ID3D11ShaderResourceView* texture){ //I want to rename these so they make a little more sense. RenderModel(vertexBuffer); m_VertexShader->initializeShader(m_Device); m_VertexShader->setParameters(m_Context, *transform, m_Camera->GetViewMatrix(), m_projMatrix); m_Context->PSSetShaderResources(0, 1, &texture); Update(vertexBuffer, vertices); //RenderShader(); }
void SkyRender() { GLfloat mat_emission[] = {1.0, 1.0, 1.0, 0.0}; glEnable(GL_CULL_FACE); glPushMatrix(); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); glTranslatef (512, -100, 512); RenderModel(skydome); glPopMatrix(); RenderSun(); glDisable(GL_CULL_FACE); }
void Ship::Render(Graphics::Renderer *renderer, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { if (IsDead()) return; //angthrust negated, for some reason GetModel()->SetThrust(vector3f(m_thrusters), -vector3f(m_angThrusters)); matrix3x3f mt; matrix3x3dtof(viewTransform.Inverse().GetOrient(), mt); s_heatGradientParams.heatingMatrix = mt; s_heatGradientParams.heatingNormal = vector3f(GetVelocity().Normalized()); s_heatGradientParams.heatingAmount = Clamp(GetHullTemperature(),0.0,1.0); // This has to be done per-model with a shield and just before it's rendered const bool shieldsVisible = m_shieldCooldown > 0.01f && m_stats.shield_mass_left > (m_stats.shield_mass / 100.0f); GetShields()->SetEnabled(shieldsVisible); GetShields()->Update(m_shieldCooldown, 0.01f*GetPercentShields()); //strncpy(params.pText[0], GetLabel().c_str(), sizeof(params.pText)); RenderModel(renderer, camera, viewCoords, viewTransform); m_navLights->Render(renderer); renderer->GetStats().AddToStatCount(Graphics::Stats::STAT_SHIPS, 1); if (m_ecmRecharge > 0.0f) { // ECM effect: a cloud of particles for a sparkly effect vector3f v[100]; for (int i=0; i<100; i++) { const double r1 = Pi::rng.Double()-0.5; const double r2 = Pi::rng.Double()-0.5; const double r3 = Pi::rng.Double()-0.5; v[i] = vector3f(GetPhysRadius()*vector3d(r1, r2, r3).NormalizedSafe()); } Color c(128,128,255,255); float totalRechargeTime = GetECMRechargeTime(); if (totalRechargeTime >= 0.0f) { c.a = (m_ecmRecharge / totalRechargeTime) * 255; } SfxManager::ecmParticle->diffuse = c; matrix4x4f t; for (int i=0; i<12; i++) t[i] = float(viewTransform[i]); t[12] = viewCoords.x; t[13] = viewCoords.y; t[14] = viewCoords.z; t[15] = 1.0f; renderer->SetTransform(t); renderer->DrawPointSprites(100, v, SfxManager::additiveAlphaState, SfxManager::ecmParticle.get(), 50.f); } }
void Display(){ // main drawing routine - called every frame glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glLoadIdentity(); // camera at default (zero) position and orientation RenderModel(); PrintStats(); glLoadIdentity(); RenderStrings(); glPopMatrix(); glFlush(); SwapBuffers(hDC); /* nop if singlebuffered */ }
void CModelGTF::DrawModel() { //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Before we render the model we need to update the animation frames UpdateModel(); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Render the model and all it's objects RenderModel(); }
DX11SceneManager::DX11SceneManager(ID3D11Device* pd3dDevice, DX11ShaderSystem* pShaderSystem) { //Sets the member references m_pd3dDevice = pd3dDevice; m_pShaderSystem = pShaderSystem; //Number one should be an invalid empty rendermodel m_pModelArray.push_back(RenderModel(0, NULL, NULL)); //Loads the default texture to display when a texture is not found if (FAILED(loadTexture(defaultTexture, "default.dds"))) { return E_FAIL; } m_mainNode = SceneNode(this, NULL, "Scene01"); m_pCamera = new CameraNode(0, 0, 0.0f); }
void Render() { g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); if (SUCCEEDED(g_pd3dDevice->BeginScene())) { g_pd3dDevice->SetRenderState(D3DRS_AMBIENT, 0xffffffff); SetMatrices(); D3DXMATRIXA16 matWorld1, matWorld2; D3DXMatrixTranslation(&matWorld1, 0.0f, 0.0f, 1.0f); D3DXMatrixRotationY(&matWorld2, D3DX_PI); matWorld2 *= matWorld1; g_pd3dDevice->GetTransform(D3DTS_WORLD, &matWorld2); RenderModel(modelindex); g_pd3dDevice->EndScene(); } g_pd3dDevice->Present(NULL, NULL, NULL, NULL); }
void CModelMD3::DrawLink(t3DModel *pModel) { RenderModel(pModel); CQuaternion qQuat, qNextQuat, qInterpolatedQuat; float *pMatrix, *pNextMatrix; float finalMatrix[16] = {0}; for(int i = 0; i < pModel->numOfTags; i++) { t3DModel *pLink = pModel->pLinks[i]; if(pLink) { CVector3 vPosition = pModel->pTags[pModel->currentFrame * pModel->numOfTags + i].vPosition; CVector3 vNextPosition = pModel->pTags[pModel->nextFrame * pModel->numOfTags + i].vPosition; vPosition.x = vPosition.x + pModel->t * (vNextPosition.x - vPosition.x), vPosition.y = vPosition.y + pModel->t * (vNextPosition.y - vPosition.y), vPosition.z = vPosition.z + pModel->t * (vNextPosition.z - vPosition.z); pMatrix = &pModel->pTags[pModel->currentFrame * pModel->numOfTags + i].rotation[0][0]; pNextMatrix = &pModel->pTags[pModel->nextFrame * pModel->numOfTags + i].rotation[0][0]; qQuat.CreateFromMatrix( pMatrix, 3); qNextQuat.CreateFromMatrix( pNextMatrix, 3 ); qInterpolatedQuat = qQuat.Slerp(qQuat, qNextQuat, pModel->t); qInterpolatedQuat.CreateMatrix( finalMatrix ); finalMatrix[12] = vPosition.x; finalMatrix[13] = vPosition.y; finalMatrix[14] = vPosition.z; glPushMatrix(); glMultMatrixf( finalMatrix ); DrawLink(pLink); glPopMatrix(); } } }
void DefaultRenderer::EndFrame() { Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::InstancedPass); Resources::Gather::InstancedData.Apply(1); for(auto i = Render::Resources::RenderData.begin(); i != Render::Resources::RenderData.end(); i++ ) { RenderModel((*i).first,(*i).second->rid, (*i).second->Models); } Core::PipelineManager::SetRenderPass(Resources::Light::Pass); Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); BlurGlow(); BlurSSAO(); Core::PipelineManager::SetRenderPass(Resources::Post::Pass); Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); Core::swapChain->Present(0,0); }
void ShipCockpit::Render(Graphics::Renderer *renderer, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { PROFILE_SCOPED() RenderModel(renderer, camera, viewCoords, viewTransform); }
void CModelMD3::Draw() { glRotatef(-90, 1, 0, 0); RenderModel(&m_Weapon); }
RenderModel* DX11SceneManager::createModel() { m_pModelArray.push_back(RenderModel(m_pModelArray.size(), this, m_pShaderSystem)); return &m_pModelArray.back(); }
void Renderer::Render(const Camera& cam, IContext& c){ #if ZEUS_SAFE if (c.GetType() != IContext::OpenGL21) throw Exception("Context not supported by renderer: " + Utils::ToString<IContext::Type>(c.GetType())); #endif Context& glContext = (Context&)c; // Draw scene ApplyCamera(cam, c); glEnable(GL_CULL_FACE); // @TODO Setup light. Lightmaps 'n shit glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); Vector3 dir = Vector3(1,3,2); Normalize(dir); float hat[4]; dir.GetData(hat); hat[3] = 1.0f; glLightfv(GL_LIGHT0, GL_POSITION, hat); SceneObjectList::iterator itr = SceneObjectList::Begin(); while (itr != SceneObjectList::End()){ //Debug::Log("Rendering " + (*itr)->GetName()); const ModelComponent* m = (*itr)->GetComponent<ModelComponent>(); if (m){ //Debug::Log((*itr)->GetName() + " has mesh"); const ModelPropertiesPtr props = m->GetModelProperties(); if (props) { ModelProperties::Texture2DIterator itr = props->Texture2DBegin(); while (itr != props->Texture2DEnd()) { const GLTexture2D* tex = glContext.AddTexture(itr->second); glBindTexture(GL_TEXTURE_2D, tex->GetID()); glEnable(GL_TEXTURE_2D); ++itr; } } else { glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); } const MeshPtr mesh = m->GetMesh(); if (mesh) { const Transformation* t = (*itr)->GetComponent<Transformation>(); glPushMatrix(); Matrix4x4 m = t->GetAccumulatedMatrix(); glMultMatrixf(m.GetData()); // @TODO Apply material const GLMesh* mInfo = glContext.AddMesh(mesh); RenderModel(*mInfo, glContext); glPopMatrix(); } } ++itr; } glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); glDisable(GL_CULL_FACE); }
void CargoBody::Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { GetModel()->SetLabel(Equip::types[m_type].name); RenderModel(r, viewCoords, viewTransform); }
void App::Draw() { //FrameBufferBind //glBindFramebuffer(GL_FRAMEBUFFER, frameOBJ.FBO); //glViewport(0, 0, 512, 512); //glClearColor(0.75f, 0.75f, 0.75f, 1); //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //// hottodoggu // //RenderModel(renderOBJ); // ////Standard grid draw //for (int i = 0; i < 21; i++) { // Gizmos::addLine(glm::vec3(-10 + i, 0, 10), // glm::vec3(-10 + i, 0, -10), // i == 10 ? glm::vec4(1, 1, 1, 1) : glm::vec4(0, 0, 0, 1)); // Gizmos::addLine(glm::vec3(10, 0, -10 + i), // glm::vec3(-10, 0, -10 + i), // i == 10 ? glm::vec4(1, 1, 1, 1) : glm::vec4(0, 0, 0, 1)); //} //Gizmos::draw((camera->camera_view_transform1())); //Post Process Quad Buffer glBindFramebuffer(GL_FRAMEBUFFER, quadBuffer.FBO); glViewport(0, 0, 1280, 720); //Clear Target glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); RenderModel(renderOBJ); Gizmos::draw(camera->camera_view_transform1()); //Draw Shit for (int i = 0; i < 21; i++) { Gizmos::addLine(glm::vec3(-10 + i, 0, 10), glm::vec3(-10 + i, 0, -10), i == 10 ? glm::vec4(1, 1, 1, 1) : glm::vec4(0, 0, 0, 1)); Gizmos::addLine(glm::vec3(10, 0, -10 + i), glm::vec3(-10, 0, -10 + i), i == 10 ? glm::vec4(1, 1, 1, 1) : glm::vec4(0, 0, 0, 1)); } //RenderModel(renderOBJ); //Gizmos::draw(camera->camera_view_transform1()); //return to back buffer glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, 1280, 720); //Clear //glClearColor(0.5f, 0.5f, 0.5f, 1); //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.5f, 0.5f, 0.5f, 1); glClear(GL_DEPTH_BUFFER_BIT); //Draw out quad DrawQuad(); //RenderModel(renderOBJ); //Gizmos::clear(); //Gizmos::addTransform(mat4(1)); //Standard grid draw /*for (int i = 0; i < 21; i++) { Gizmos::addLine(glm::vec3(-10 + i, 0, 10), glm::vec3(-10 + i, 0, -10), i == 10 ? glm::vec4(1, 1, 1, 1) : glm::vec4(0, 0, 0, 1)); Gizmos::addLine(glm::vec3(10, 0, -10 + i), glm::vec3(-10, 0, -10 + i), i == 10 ? glm::vec4(1, 1, 1, 1) : glm::vec4(0, 0, 0, 1)); }*/ //DrawPlane(); //Camera Draw camera->UpdateProjectionViewTransform(); }
// Renders space station and adjacent city if applicable // For orbital starports: renders as normal // For surface starports: // Lighting: Calculates available light for model and splits light between directly and ambiently lit // Lighting is done by manipulating global lights or setting uniforms in atmospheric models shader void SpaceStation::Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { Body *b = GetFrame()->GetBody(); assert(b); if (!b->IsType(Object::PLANET)) { // orbital spaceport -- don't make city turds or change lighting based on atmosphere RenderModel(r, viewCoords, viewTransform); } else { Planet *planet = static_cast<Planet*>(b); // calculate lighting // available light is calculated and split between directly (diffusely/specularly) lit and ambiently lit const std::vector<Camera::LightSource> &lightSources = camera->GetLightSources(); double ambient, intensity; CalcLighting(planet, ambient, intensity, lightSources); ambient = std::max(0.05, ambient); std::vector<Graphics::Light> origLights, newLights; for(size_t i = 0; i < lightSources.size(); i++) { Graphics::Light light(lightSources[i].GetLight()); origLights.push_back(light); Color c = light.GetDiffuse(); Color cs = light.GetSpecular(); c.r*=float(intensity); c.g*=float(intensity); c.b*=float(intensity); cs.r*=float(intensity); cs.g*=float(intensity); cs.b*=float(intensity); light.SetDiffuse(c); light.SetSpecular(cs); newLights.push_back(light); } const Color oldAmbient = r->GetAmbientColor(); r->SetAmbientColor(Color(ambient)); r->SetLights(newLights.size(), &newLights[0]); /* don't render city if too far away */ if (viewCoords.Length() < 1000000.0){ if (!m_adjacentCity) { m_adjacentCity = new CityOnPlanet(planet, this, m_sbody->seed); } m_adjacentCity->Render(r, camera, this, viewCoords, viewTransform); } RenderModel(r, viewCoords, viewTransform); // restore old lights & ambient r->SetLights(origLights.size(), &origLights[0]); r->SetAmbientColor(oldAmbient); } }
void CargoBody::Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { RenderModel(r, camera, viewCoords, viewTransform); }