gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.48k stars 774 forks source link

osgParticle ExplosionEffect unvisible use MatrixTransform #648

Closed kinsung closed 9 years ago

kinsung commented 9 years ago

osgParticle ExplosionEffect unvisible use MatrixTransform, but fine when useing convertLatLongHeightToXYZ to convert coordinate.

// this is fine:
    osg::Vec3 position;

    double x, y, z;
    srs->getEllipsoid()->convertLatLongHeightToXYZ(
        osg::DegreesToRadians(pt.latitude),
        osg::DegreesToRadians(pt.longitude),
        pt.altitude,
        x, y, z);
    position = osg::Vec3(x, y, z);

    osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, scale, intensity);
    explosion->setTextureFileName(get_app_dir()+"/data3d/images/smoke.rgb");

    osg::Vec3 wind(1.0, 1.0, 1.0);
    explosion->setWind(wind);

    osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
    mt->addChild( explosion );
    this->addChild( mt );

// this is not fine:
    osg::Vec3 position;
    osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, scale, intensity);
    explosion->setTextureFileName(get_app_dir()+"/data3d/images/smoke.rgb");

    osg::Vec3 wind(1.0, 1.0, 1.0);
    explosion->setWind(wind);

    osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
    mt->addChild( explosion );

    osgEarth::GeoPoint gpt(srs, pt.longitude, pt.latitude, pt.altitude, ALTMODE_ABSOLUTE); 
    osg::Matrix matrixLocalToWorld;
    gpt.createLocalToWorld( matrixLocalToWorld );
    osg::Matrix matrix = osg::Matrix::scale(2, 2, 2)*matrixLocalToWorld;
    mt->setMatrix( matrix );

    this->addChild( mt );
'''
gwaldron commented 9 years ago

Does it work without the osg::Marix::scale(2,2,2)? You can also try GeoTransform instead of MatrixTransform.

kinsung commented 9 years ago

Not work: mt->setMatrix( matrixLocalToWorld );

gwaldron commented 9 years ago

No idea. Maybe something in the way that the particle system uses the position data. Perhaps it is ignoring the MT and placing it at position absolutely. You will need to delve into the code to find out.

kinsung commented 9 years ago

Thank you. I close this issue.