void STKMeshSceneNode::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type) { assert(irr_driver->getPhase() == TRANSPARENT_PASS); computeMVP(ModelViewProjectionMatrix); if (type == irr_driver->getShader(ES_BUBBLES)) drawBubble(mesh, ModelViewProjectionMatrix); // else if (World::getWorld()->getTrack()->isFogEnabled()) // drawTransparentFogObject(mesh, ModelViewProjectionMatrix, TextureMatrix); else drawTransparentObject(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix); return; }
void STKMeshSceneNode::render() { irr::video::IVideoDriver* driver = irr_driver->getVideoDriver(); if (!Mesh || !driver) return; if (reload_each_frame) updatevbo(); bool isTransparentPass = SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; ++PassCount; driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); Box = Mesh->getBoundingBox(); setFirstTimeMaterial(); for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) { scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); if (!mb) continue; GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0); } if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS) { if (reload_each_frame) glDisable(GL_CULL_FACE); computeMVP(ModelViewProjectionMatrix); computeTIMV(TransposeInverseModelView); if (!GeometricMesh[FPSM_DEFAULT].empty()) glUseProgram(MeshShader::ObjectPass1Shader::Program); for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++) drawSolidPass1(*GeometricMesh[FPSM_DEFAULT][i], FPSM_DEFAULT); if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty()) glUseProgram(MeshShader::ObjectRefPass1Shader::Program); for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++) drawSolidPass1(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i], FPSM_ALPHA_REF_TEXTURE); if (!GeometricMesh[FPSM_NORMAL_MAP].empty()) glUseProgram(MeshShader::NormalMapShader::Program); for (unsigned i = 0; i < GeometricMesh[FPSM_NORMAL_MAP].size(); i++) drawSolidPass1(*GeometricMesh[FPSM_NORMAL_MAP][i], FPSM_NORMAL_MAP); if (!GeometricMesh[FPSM_GRASS].empty()) glUseProgram(MeshShader::GrassPass1Shader::Program); for (unsigned i = 0; i < GeometricMesh[FPSM_GRASS].size(); i++) drawSolidPass1(*GeometricMesh[FPSM_GRASS][i], FPSM_GRASS); if (reload_each_frame) glEnable(GL_CULL_FACE); return; } if (irr_driver->getPhase() == SOLID_LIT_PASS) { if (reload_each_frame) glDisable(GL_CULL_FACE); if (!ShadedMesh[SM_DEFAULT].empty()) glUseProgram(MeshShader::ObjectPass2Shader::Program); for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++) drawSolidPass2(*ShadedMesh[SM_DEFAULT][i], SM_DEFAULT); if (!ShadedMesh[SM_ALPHA_REF_TEXTURE].empty()) glUseProgram(MeshShader::ObjectRefPass2Shader::Program); for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++) drawSolidPass2(*ShadedMesh[SM_ALPHA_REF_TEXTURE][i], SM_ALPHA_REF_TEXTURE); if (!ShadedMesh[SM_RIMLIT].empty()) glUseProgram(MeshShader::ObjectRimLimitShader::Program); for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++) drawSolidPass2(*ShadedMesh[SM_RIMLIT][i], SM_RIMLIT); if (!ShadedMesh[SM_SPHEREMAP].empty()) glUseProgram(MeshShader::SphereMapShader::Program); for (unsigned i = 0; i < ShadedMesh[SM_SPHEREMAP].size(); i++) drawSolidPass2(*ShadedMesh[SM_SPHEREMAP][i], SM_SPHEREMAP); if (!ShadedMesh[SM_SPLATTING].empty()) glUseProgram(MeshShader::SplattingShader::Program); for (unsigned i = 0; i < ShadedMesh[SM_SPLATTING].size(); i++) drawSolidPass2(*ShadedMesh[SM_SPLATTING][i], SM_SPLATTING); if (!ShadedMesh[SM_GRASS].empty()) glUseProgram(MeshShader::GrassPass2Shader::Program); for (unsigned i = 0; i < ShadedMesh[SM_GRASS].size(); i++) drawSolidPass2(*ShadedMesh[SM_GRASS][i], SM_GRASS); if (!ShadedMesh[SM_UNLIT].empty()) glUseProgram(MeshShader::ObjectUnlitShader::Program); for (unsigned i = 0; i < ShadedMesh[SM_UNLIT].size(); i++) drawSolidPass2(*ShadedMesh[SM_UNLIT][i], SM_UNLIT); if (!ShadedMesh[SM_CAUSTICS].empty()) glUseProgram(MeshShader::CausticsShader::Program); for (unsigned i = 0; i < ShadedMesh[SM_CAUSTICS].size(); i++) drawSolidPass2(*ShadedMesh[SM_CAUSTICS][i], SM_CAUSTICS); if (!ShadedMesh[SM_DETAILS].empty()) glUseProgram(MeshShader::DetailledObjectPass2Shader::Program); for (unsigned i = 0; i < ShadedMesh[SM_DETAILS].size(); i++) drawSolidPass2(*ShadedMesh[SM_DETAILS][i], SM_DETAILS); if (!ShadedMesh[SM_UNTEXTURED].empty()) glUseProgram(MeshShader::UntexturedObjectShader::Program); for (unsigned i = 0; i < ShadedMesh[SM_UNTEXTURED].size(); i++) drawSolidPass2(*ShadedMesh[SM_UNTEXTURED][i], SM_UNTEXTURED); if (reload_each_frame) glEnable(GL_CULL_FACE); return; } if (irr_driver->getPhase() == SHADOW_PASS) { if (reload_each_frame) glDisable(GL_CULL_FACE); if (!GeometricMesh[FPSM_DEFAULT].empty()) glUseProgram(MeshShader::ShadowShader::Program); for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++) drawShadow(*GeometricMesh[FPSM_DEFAULT][i]); if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty()) glUseProgram(MeshShader::RefShadowShader::Program); for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++) drawShadowRef(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]); if (reload_each_frame) glEnable(GL_CULL_FACE); return; } if (irr_driver->getPhase() == GLOW_PASS) { glUseProgram(MeshShader::ColorizeShader::Program); for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) { scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); if (!mb) continue; drawGlow(GLmeshes[i]); } } if (irr_driver->getPhase() == TRANSPARENT_PASS) { computeMVP(ModelViewProjectionMatrix); if (!TransparentMesh[TM_BUBBLE].empty()) glUseProgram(MeshShader::BubbleShader::Program); for (unsigned i = 0; i < TransparentMesh[TM_BUBBLE].size(); i++) drawBubble(*TransparentMesh[TM_BUBBLE][i], ModelViewProjectionMatrix); if (World::getWorld()->getTrack()->isFogEnabled()) { if (!TransparentMesh[TM_DEFAULT].empty()) glUseProgram(MeshShader::TransparentFogShader::Program); for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++) drawTransparentFogObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix); } else { if (!TransparentMesh[TM_DEFAULT].empty()) glUseProgram(MeshShader::TransparentShader::Program); for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++) drawTransparentObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix); } return; } if (irr_driver->getPhase() == DISPLACEMENT_PASS) { for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) { scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); if (!mb) continue; drawDisplace(GLmeshes[i]); } } }
void MyGLWidget::paintGL() { QPainter painter(this); drawBubble(&painter); }