Hello Robert,
Sorry for catching this so late:
Seems like your re-factoring didn't really produces the correct results.
You can check with the tester2.flt provided earlier and check with the
result image.
I double checked this with OpenFlight creator, and it seems the yaw is
broken.
With my initial quaternion version is seems correct and if I change the
float cos_yaw = cosf(osg::inDegrees(yaw));
float sin_yaw = sinf(osg::inDegrees(yaw));
to be
float cos_yaw = cosf(osg::inDegrees(-yaw));
float sin_yaw = sinf(osg::inDegrees(-yaw));
it seems to work as well.
So could you please change this, or do you need the complete diff
against the trunk?
cheers
Sebastian
Hi Sebastian,
Thanks for the simplified model and screenshots, this pinpoints the
issue really well. I've reviewed your changes and applied them and
found they work, but felt the code might be a bit clearer if it didn't
use Quat's so wrote the direction definitions uses old fashioned
sin/cos thus:
$ svn diff
Index: PrimaryRecords.cpp
===================================================================
--- PrimaryRecords.cpp (revision 13440)
+++ PrimaryRecords.cpp (working copy)
@@ -1029,10 +1029,13 @@
// Apply yaw and pitch for infinite and spot light.
if ((w==0.0) || (light->getSpotCutoff()<180.0))
{
- // TODO: What direction is zero yaw and pitch?
- osg::Quat rotation = (
osg::Quat(osg::inDegrees(double(yaw)),osg::Vec3(0.0,0.0,1.0)) *
-
osg::Quat(osg::inDegrees(double(pitch)),osg::Vec3(1.0,0.0,0.0)) );
- light->setDirection(rotation*osg::Vec3(0.0,1.0,0.0));
+ // assume yaw is zero along y axis, increase positive clockwise
+ // assume patch is zero along xy plane, increase
positive upwards
+ float cos_yaw = cosf(osg::inDegrees(yaw));
+ float sin_yaw = sinf(osg::inDegrees(yaw));
+ float cos_pitch = cosf(osg::inDegrees(pitch));
+ float sin_pitch = sinf(osg::inDegrees(pitch));
+ light->setDirection(osg::Vec3(sin_yaw*cos_pitch,
cos_yaw*cos_pitch, sin_pitch));
}
I get the same results as your code and the .flt file now loads and
light source is in the same direction as you are getting in Creator.
Could you do an svn update and let me know whether it now works for
all your models.
Cheers,
Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org