model rotate

classic Classic list List threaded Threaded
4 messages Options
zhutaiyong520 zhutaiyong520
Reply | Threaded
Open this post in threaded view
|

model rotate

I want to set the position of the cow  ,   the cow stand on the ground,  there is front vector that facing a certain parallel ground,how to set the cow rotating.

there is a part of code:

osg::Vec3d up;
osg::Vec3d right;
osg::Vec3d front;
osg::Vec3d pos;
osg::Vec3d tempz(0,0,1);
cowNode->setMatrix(osg::Matrix::rotate(tempz, up) * osg::Matrix::translate(pos));
Nikkitta Nikkitta
Reply | Threaded
Open this post in threaded view
|

Re: model rotate

Here is how I position aircraft model on Earth:

osg::ref_ptr<osgEarth::Annotation::GeoPositionNode> modelOnEarth = new osgEarth::Annotation::GeoPositionNode(mapNode); 

QString modelPath = QCoreApplication::applicationDirPath() +
                        "/data_osg/models/aircraft.osgb";
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(modelPath.toStdString());
modelOnEarth->getPositionAttitudeTransform()->addChild(model.get());
osgEarth::Registry::shaderGenerator().run(modelOnEarth);

osgEarth::GeoPoint position; // set to smth
double yaw; // set to smth
double pitch; // set to smth
double roll; // set to smth

modelOnEarth->setPosition(position);

modelOnEarth->getPositionAttitudeTransform()->setAttitude(
        osg::Quat(osg::DegreesToRadians(roll), osg::Vec3(0, 1, 0)) *
        osg::Quat(osg::DegreesToRadians(pitch), osg::Vec3(1, 0, 0)) *
        osg::Quat(osg::DegreesToRadians(yaw), osg::Vec3(0, 0, -1)));

Also read the docs: http://docs.osgearth.org/en/latest/faq.html#how-do-i-place-a-3d-model-on-the-map
Best regards,
Nikita Petrov
zhutaiyong520 zhutaiyong520
Reply | Threaded
Open this post in threaded view
|

Re: model rotate

thank you,  I already know the answer
zhutaiyong520 zhutaiyong520
Reply | Threaded
Open this post in threaded view
|

Re: model rotate

In reply to this post by Nikkitta
do you know the question ?

Two views to show  a node ,but I want to hide the node in one of the views