// *************************************************************************** void CScene::renderOcclusionTestMeshs() { nlassert(RenderTrav.getDriver()); RenderTrav.getDriver()->setupViewport(RenderTrav.getViewport()); RenderTrav.getDriver()->activeVertexProgram(NULL); RenderTrav.getDriver()->activePixelProgram(NULL); RenderTrav.getDriver()->activeGeometryProgram(NULL); IDriver::TPolygonMode oldPolygonMode = RenderTrav.getDriver()->getPolygonMode(); CMaterial m; m.initUnlit(); m.setColor(CRGBA(255, 255, 255, 127)); m.setBlend(true); m.setDstBlend(CMaterial::invsrcalpha); m.setSrcBlend(CMaterial::srcalpha); m.setZWrite(false); RenderTrav.getDriver()->setupMaterial(m); getDriver()->setPolygonMode(IDriver::Filled); renderOcclusionTestMeshsWithCurrMaterial(); m.setColor(CRGBA::Black); RenderTrav.getDriver()->setupMaterial(m); getDriver()->setPolygonMode(IDriver::Line); renderOcclusionTestMeshsWithCurrMaterial(); getDriver()->setPolygonMode(oldPolygonMode); }
/*********************************************************\ displayOrientation() \*********************************************************/ void displayOrientation() { float x = 0.9f*4.f/3.f; float y = 0.1f; float radius = 0.015f; // Triangle CMaterial mat; mat.initUnlit(); mat.setSrcBlend(CMaterial::srcalpha); mat.setDstBlend(CMaterial::invsrcalpha); mat.setBlend(true); CVertexBuffer vb; vb.setVertexFormat (CVertexBuffer::PositionFlag); vb.setNumVertices (7); { CVertexBufferReadWrite vba; vb.lock(vba); // tri vba.setVertexCoord (0, CVector (-radius, 0, 0)); vba.setVertexCoord (1, CVector (radius, 0, 0)); vba.setVertexCoord (2, CVector (0, 0, 3*radius)); // quad vba.setVertexCoord (3, CVector (-radius, 0, -radius)); vba.setVertexCoord (4, CVector (radius, 0, -radius)); vba.setVertexCoord (5, CVector (radius, 0, radius)); vba.setVertexCoord (6, CVector (-radius, 0, radius)); } CNELU::Driver->activeVertexBuffer(vb); CIndexBuffer pbTri; pbTri.setNumIndexes (3); { CIndexBufferReadWrite iba; pbTri.lock (iba); iba.setTri (0, 0, 1, 2); } CIndexBuffer pbQuad; pbQuad.setNumIndexes (6); { CIndexBufferReadWrite iba; pbQuad.lock(iba); iba.setTri (0, 3, 4, 5); iba.setTri (3, 5, 6, 3); } CNELU::Driver->setFrustum (0.f, 4.f/3.f, 0.f, 1.f, -1.f, 1.f, false); CMatrix mtx; mtx.identity(); CNELU::Driver->setupViewMatrix (mtx); mat.setColor(CRGBA(50,255,255,150)); // up mtx.identity(); mtx.translate(CVector(x,0,y)); mtx.rotateY(MoveListener.getRotZ() ); mtx.translate(CVector(0,0,radius)); CNELU::Driver->setupModelMatrix (mtx); CNELU::Driver->activeVertexBuffer(vb); CNELU::Driver->activeIndexBuffer(pbTri); CNELU::Driver->renderTriangles(mat, 0, pbTri.getNumIndexes()/3); mat.setColor(CRGBA(50,50,255,150)); // down mtx.identity(); mtx.translate(CVector(x,0,y)); mtx.rotateY(MoveListener.getRotZ() + (float)Pi); mtx.translate(CVector(0,0,radius)); CNELU::Driver->setupModelMatrix (mtx); CNELU::Driver->renderTriangles(mat, 0, pbTri.getNumIndexes()/3); // left mtx.identity(); mtx.translate(CVector(x,0,y)); mtx.rotateY(MoveListener.getRotZ() - (float)Pi/2); mtx.translate(CVector(0,0,radius)); CNELU::Driver->setupModelMatrix (mtx); CNELU::Driver->renderTriangles(mat, 0, pbTri.getNumIndexes()/3); // right mtx.identity(); mtx.translate(CVector(x,0,y)); mtx.rotateY(MoveListener.getRotZ() + (float)Pi/2); mtx.translate(CVector(0,0,radius)); CNELU::Driver->setupModelMatrix (mtx); CNELU::Driver->renderTriangles(mat, 0, pbTri.getNumIndexes()/3); // center mtx.identity(); mtx.translate(CVector(x,0,y)); mtx.rotateY(MoveListener.getRotZ()); CNELU::Driver->setupModelMatrix (mtx); CNELU::Driver->activeIndexBuffer(pbQuad); CNELU::Driver->renderTriangles(mat, 0, pbQuad.getNumIndexes()/3); }