void RenderPolyPlane::Render(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals) { FSectorPortal *portal = fakeflat.FrontSector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); if (!portal || (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into { RenderNormal(thread, worldToClip, clipPlane, fakeflat, stencilValue, ceiling, skyHeight); } else { RenderPortal(thread, worldToClip, clipPlane, fakeflat, stencilValue, ceiling, skyHeight, portal, sectorPortals); } }
void Mesh::RenderVertexNormals() const { glPushMatrix(); for (int t = 0; t < faces.size(); ++t) { const vector<int>& vertexIndices = faces.at(t); for (int v = 0; v < vertexIndices.size(); ++v) { const int vInd = vertexIndices.at(v); const Vec3f& vertex = vertices.at(vInd); const Vec3f& normal = vertexNormals.at(vInd); RenderNormal(vertex, normal / 5.0f); } } glPopMatrix(); }
void Mesh::RenderFaceNormals() const { glPushMatrix(); for (int t = 0; t < faces.size(); ++t) { const vector<int>& vertexIndices = faces.at(t); const Vec3f& normal = faceNormals.at(t); Vec3f faceCenter(0.0f, 0.0f, 0.0f); for (int v = 0; v < vertexIndices.size(); ++v) { faceCenter += vertices.at(vertexIndices.at(v)); } faceCenter /= vertexIndices.size(); RenderNormal(faceCenter, normal / 5.0f); } glPopMatrix(); }
bool Display( float timeDelta ) { if( !g_pDevice ) return false; D3DXMATRIX mRot; D3DXMatrixRotationAxis( &mRot, &g_vAxis, g_fAngle ); D3DXMATRIX mView; D3DXMatrixMultiply( &mView, &mRot, &g_mCamera ); // g_pDevice->SetTransform( D3DTS_VIEW, &mView ); g_pDevice->SetTransform( D3DTS_WORLD, &mView ); D3DLIGHT9 light; D3DXCOLOR c = d3d::WHITE; //D3DXVECTOR3 position( 10 * cosf(g_fLightAngle), 10 * sinf(g_fLightAngle), -.5f ); //position.x -= 1.f; //light.Position = D3DXVECTOR3(0, 0, -10.f); //D3DXVECTOR3 directioon( 0.0f, 1.0f, 0.f ); //light = d3d::InitPointLight(&position, &c); D3DXVECTOR3 directioon( cosf(g_fLightAngle), sinf(g_fLightAngle), 0.f ); light = d3d::InitDirectionalLight(&directioon, &c); g_pDevice->SetLight( 0, &light ); g_pDevice->LightEnable( 0, true ); InitMaterial(); UpdateAlphaTexture(); g_pDevice->Clear( 0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(200,200,200), 1.0f, 0 ); g_pDevice->BeginScene(); g_pDevice->SetRenderState( D3DRS_LIGHTING, TRUE); g_pDevice->SetRenderState( D3DRS_AMBIENT, 0x00202020 ); g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); g_pDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE ); g_pDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE ); //g_pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); //g_pDevice->SetRenderState( D3DRS_ZENABLE, TRUE ); //g_pDevice->SetRenderState( D3DRS_FOGENABLE, FALSE ); //g_pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); //g_pDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE ); // g_pDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); // g_pDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); g_pDevice->SetMaterial( &g_Mtrl1 ); //NormalRendering(g_pTex1); AlphaBlending(g_pAlphaTex1, g_pTex1); //AlphaBlending(g_pAlphaTex2, g_pTex2); //g_pDevice->SetMaterial( &g_Mtrl2 ); //g_pMesh->DrawSubset( 0 ); g_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE); g_pDevice->SetTexture( 0, NULL); g_pDevice->SetTexture( 1, NULL); RenderNormal(g_pvtxBuff1); g_pDevice->EndScene(); g_pDevice->Present( 0, 0, 0, 0 ); return true; }