已知空间平面上三点 (x1,y1,z1), (x2,y2,z2), (x3,y3,z3)
//空间三维平面方程ax+by+cz+d=0; 计算 a, b, c, d四个参数值
a = y1*(z2-z3)+y2*(z3-z1)+y3*(z1-z2);
b = z1*(x2-x3)+z2*(x3-x1)+z3*(x1-x2);
c = x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);
d = - (a*x1 + b*y1 + c*z1);//利用ax+by+cz+d=0;解算 或 //d = - x1*(y2*z3-y3*z2)-x2*(y3*z1-y1*z3)-x3*(y1*z2-y2*z1);
osg::ClipPlane* cp = new osg::ClipPlane () ;
cp->setClipPlane(a,b,c,d);//设置裁剪平面
osg::node* pModel;//模型节点
pModel->->getOrCreateStateSet()->setAttributeAndModes (cp.get(), osg::StateAttribute ::ON );
判断点(x,y,z)是否落在裁切区域
double dvalue = a * x + b * y + c * z + d;
if (dvalue < 0)//落在裁剪范围内