|
在书中的第3章第8节的例子中,您是画了一个6面体实现的点选。采用的是GL_QUADS的绘制方式。但是,如果我把他改成GL_LINES或者是GL_POINTS的绘制方式。
osg::ref_ptr<osg:rawElementsUInt> indices0 = new osg::DrawElementsUInt(GL_POINTS, 4);
osg::ref_ptr<osg::DrawElementsUInt> indices1 = new osg::DrawElementsUInt(GL_POINTS, 4);
osg::ref_ptr<osg::DrawElementsUInt> indices2 = new osg::DrawElementsUInt(GL_POINTS, 4);
osg::ref_ptr<osg::DrawElementsUInt> indices3 = new osg::DrawElementsUInt(GL_POINTS, 4);
osg::ref_ptr<osg::DrawElementsUInt> indices4 = new osg::DrawElementsUInt(GL_POINTS, 4);
osg::ref_ptr<osg::DrawElementsUInt> indices5 = new osg::DrawElementsUInt(GL_POINTS, 4);
(*indices0)[0] = 0; (*indices0)[1] = 1; (*indices0)[2] = 2; (*indices0)[3] = 3;
(*indices1)[0] = 4; (*indices1)[1] = 5; (*indices1)[2] = 6; (*indices1)[3] = 7;
(*indices2)[0] = 0; (*indices2)[1] = 1; (*indices2)[2]= 5; (*indices2)[3]= 4;
(*indices3)[0]= 1; (*indices3)[1]= 2; (*indices3)[2]= 6; (*indices3)[3]= 5;
(*indices4)[0]= 2; (*indices4)[1]= 3; (*indices4)[2]= 7; (*indices4)[3]= 6;
(*indices5)[0]= 3; (*indices5)[1]= 0; (*indices5)[2]= 4; (*indices5)[3]= 7;
geom->addPrimitiveSet( indices0.get() );
geom->addPrimitiveSet(indices1.get());
geom->addPrimitiveSet( indices2.get() );
geom->addPrimitiveSet(indices3.get());
geom->addPrimitiveSet( indices4.get() );
geom->addPrimitiveSet(indices5.get());
其他代码没有变。我的理解是GL_QUADS,GL_LINES,GL_POINTS都是基本的图元,CTRL+鼠标左键时,应该都能够检测有交点,可是在GL_LINES,GL_POINTS模式下,if ( intersector->containsIntersections() )这句返回的是false,这是为什么????
|
|