#include <osg/PolygonOffset>
#include <osg/PrimitiveSet>
#include <osg/MatrixTransform>
-#include <osg/PositionAttitudeTransform>
#include <osg/ShapeDrawable>
#include <osg/Shape>
#include <osg/Depth>
#include "BVHStaticData.hxx"
#include "BVHStaticNode.hxx"
-#include "BVHStaticLeaf.hxx"
#include "BVHStaticTriangle.hxx"
#include "BVHStaticBinary.hxx"
class BVHDebugCollectVisitor : public BVHVisitor {
public:
- BVHDebugCollectVisitor(unsigned level = ~0u) :
+ BVHDebugCollectVisitor(const double& time, unsigned level = ~0u) :
_group(new osg::Group),
+ _time(time),
_level(level),
_currentLevel(0)
{
{
addNodeSphere(node);
osg::ref_ptr<osg::Group> oldGroup = _group;
- osg::ref_ptr<osg::PositionAttitudeTransform> transform;
- transform = new osg::PositionAttitudeTransform;
- double tt = node.getReferenceTime() - node.getEndTime();
- tt = 100*tt;
- tt += node.getReferenceTime();
-// transform->setPosition(node.getPosition(node.getEndTime()).osg());
- transform->setPosition(node.getPosition().osg());
- transform->setAttitude(inverse(node.getOrientation(tt)).osg());
-// transform->setPosition(node.getPosition().osg());
-// transform->setAttitude(inverse(node.getOrientation()).osg());
+ osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform;
+ transform->setMatrix(osg::Matrix(node.getToWorldTransform(_time).data()));
_group = transform;
++_currentLevel;
node.traverse(*this);
node.traverse(*this, data);
--_currentLevel;
}
- virtual void apply(const BVHStaticLeaf& node, const BVHStaticData& data)
- {
- addNodeBox(node, data);
- }
virtual void apply(const BVHStaticTriangle& node, const BVHStaticData& data)
{
addNodeBox(node, data);
osg::Geometry* geometry = new osg::Geometry;
osg::Vec3Array* vertices = new osg::Vec3Array;
- vertices->push_back(triangle.getVertex(0).osg());
- vertices->push_back(triangle.getVertex(1).osg());
- vertices->push_back(triangle.getVertex(2).osg());
+ vertices->push_back(toOsg(triangle.getVertex(0)));
+ vertices->push_back(toOsg(triangle.getVertex(1)));
+ vertices->push_back(toOsg(triangle.getVertex(2)));
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(color);
return;
SGSphered sphere = node.getBoundingSphere();
osg::Sphere* shape = new osg::Sphere;
- shape->setCenter(SGVec3f(sphere.getCenter()).osg());
+ shape->setCenter(toOsg(sphere.getCenter()));
shape->setRadius(sphere.getRadius());
addShape(shape, osg::Vec4(0.5f, 0.5f, 0.5f, 0.1f));
}
BVHBoundingBoxVisitor bbv;
node.accept(bbv, data);
osg::Box* shape = new osg::Box;
- shape->setCenter(bbv.getBox().getCenter().osg());
- shape->setHalfLengths((0.5*bbv.getBox().getSize()).osg());
+ shape->setCenter(toOsg(bbv.getBox().getCenter()));
+ shape->setHalfLengths(toOsg((0.5*bbv.getBox().getSize())));
addShape(shape, osg::Vec4(0.5f, 0, 0, 0.1f));
}
}
osg::ref_ptr<osg::Group> _group;
+ const double _time;
const unsigned _level;
unsigned _currentLevel;
};