my culling function
Posted: Sat Nov 13, 2010 12:26 pm
hello, Iam integrating my own culling function to my AI class.
It avoiding to draw AIs that are behind wall.
first version was:
it work fine but there is blink, because AI is invisible till position(center of BBox) was seen...
then I make antoher version that test all edges of BBox
but I don't know why I can't see anything... there's some bug that I pass over?
It avoiding to draw AIs that are behind wall.
first version was:
Code: Select all
void CAI::cull()
{
line3d<f32> line(m_pCamera->getPosition(), m_pNode->getPosition());
if(m_pDevice->getSceneManager()->getSceneCollisionManager()->getCollisionPoint(line, m_pMetaSelector,intersection,tri))
{
m_pNode->setVisible(false);
}
else
{
m_pNode->setVisible(true);
}
}
then I make antoher version that test all edges of BBox
Code: Select all
bool CAI::canCull()
{
vector3df *edges = new vector3df[8];
m_pNode->getTransformedBoundingBox().getEdges(edges);
line3d<f32> line(m_pCamera->getPosition(), vector3df(0,0,0));
for(int i=0; i<8; i++)
{
line.end = edges[i];
if(!m_pDevice->getSceneManager()->getSceneCollisionManager()->getCollisionPoint(line, m_pMetaSelector,intersection,tri))
return false;
}
return true;
}
void CAI::cull()
{
if(canCull())
{
m_pNode->setVisible(false);
}
else
{
m_pNode->setVisible(true);
}
}