Hi Chase,
I'm afraid I don't have any to the point answers, my time is a bit too
spread thinly right now to do the background investigation.
Overloading billboard apply is appropriate, and but would suggest for
efficiency it would be best pushing and popping stuff off the stack as
you end up thrashing the stack if you have lots of billboards. First
thing though would be to get it working... then optimize afterwards.
Robert.
On 6/7/07, Bradford, Chase <[EMAIL PROTECTED]> wrote:
Hey Everyone,
I have a quad geometry attached to an OSG billboard configured with axial
rotation. I'm using a custom IntersectionVisitor that inherits from the
osgUtil::IntersectionVisitor and implements the getEyePoint,
getDistanceToEyePoint and getDistanceFromEyePoint using the same logic as
the CullVisitor. All other functionality in IntersectionVisitor is the
same.
The normal for the billboard with no rotation is <0, 1, 0>, so the bounding
box for it is min = <-5, -0.01, -5> max = <5, 0.01, 5>. The problem is
that as I rotate around the billboard, the line segment never gets
transformed into the billboard's space. As a result, the intersection is
always incorrect unless the billboard is oriented to its natural position.
I tried extending my IntersectionVisitor to have an apply(osg::Billboard)
that pushes the billboard's computed matrix, using the eye position which is
available to my visitor, but I can't seem to get the code correct. I'm
mostly guessing at how I should handle the pushModelMatrix and pushClone
methods, so maybe someone can tell me what I'm doing wrong (efficiency
aside)?
osg::Vec3 LodIntersectionVisitor::getEyePoint() const
{
// Const member access is not provided for get*Matrix for some insane
// reason, so cast away the const.
LodIntersectionVisitor* _this = const_cast<LodIntersectionVisitor*>(this);
osg::Vec3 eye_point = eye;
if( _this->getViewMatrix() ) eye_point = eye_point *
osg::Matrix::inverse( *_this->getViewMatrix() );
if( _this->getModelMatrix() ) eye_point = eye_point *
osg::Matrix::inverse( *_this->getModelMatrix() );
return eye_point;
}
void LodIntersectionVisitor::apply(osg::Billboard&
billboard)
{
if (!enter(billboard)) return;
for(unsigned int i=0; i<billboard.getNumDrawables(); ++i)
{
osg::ref_ptr<osg::RefMatrix> matrix = _modelStack.empty() ? new
osg::RefMatrix() : new osg::RefMatrix(*_modelStack.back());
billboard.computeMatrix( *matrix, getEyePoint(),
billboard.getPosition(i) );
pushModelMatrix(matrix.get());
// now push an new intersector clone transform to the new local
coordinates
push_clone();
intersect( billboard.getDrawable(i) );
// pop the clone.
pop_clone();
popModelMatrix();
}
leave();
}
Thanks,
Chase
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/