46 Ogre::Radian coneRadiusAngle = std::min<Ogre::Radian>(
ogreParentLight->getSpotlightOuterAngle(), Ogre::Degree(179.0f)) / 2;
47 Ogre::Real newRadius = Ogre::Math::Tan(coneRadiusAngle) * height;
49 delete mRenderOp.vertexData;
50 delete mRenderOp.indexData;
51 mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
52 mRenderOp.indexData =
new Ogre::IndexData();
53 mRenderOp.vertexData =
new Ogre::VertexData();
54 mRenderOp.useIndexes =
true;
60 setBoundingBox(Ogre::AxisAlignedBox(Ogre::Vector3(-newRadius, 0, -newRadius), Ogre::Vector3(newRadius, height, newRadius)));
87 Ogre::Radian attAngle = std::min<Ogre::Radian>(
ogreParentLight->getSpotlightOuterAngle(), Ogre::Degree(179.0f));
90 Ogre::Vector3 lightToCamDir = camera->getDerivedPosition() - lightPos;
92 Ogre::Vector3 clipRangeFix = -lightToCamDir * Ogre::Math::Tan(attAngle/2);
93 Ogre::Real distanceFromLight = lightToCamDir.normalise() + camera->getNearClipDistance();
95 Ogre::Real cosAngle = lightToCamDir.dotProduct(lightDir);
96 Ogre::Radian angle = Ogre::Math::ACos(cosAngle);
99 if ((distanceFromLight < (
ogreParentLight->getAttenuationRange() + clipRangeFix.length())) && (angle <= attAngle))
101 pass->setCullingMode(Ogre::CULL_ANTICLOCKWISE);
106 pass->setCullingMode(Ogre::CULL_CLOCKWISE);
109 pass->setDepthCheckEnabled(
true);
110 pass->setDepthFunction(Ogre::CMPF_ALWAYS_PASS);