本文整理汇总了C++中osg::Matrix::setRotate方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::setRotate方法的具体用法?C++ Matrix::setRotate怎么用?C++ Matrix::setRotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Matrix
的用法示例。
在下文中一共展示了Matrix::setRotate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vehiclePoseCallback
void vehiclePoseCallback(const nav_msgs::Odometry& odom) {
if (!firstpass) {
initialT.set(odom.pose.pose.position.x,odom.pose.pose.position.y,odom.pose.pose.position.z);
initialQ.set(odom.pose.pose.orientation.x, odom.pose.pose.orientation.y, odom.pose.pose.orientation.z, odom.pose.pose.orientation.w);
wMv_initial.setTrans(initialT);
wMv_initial.setRotate(initialQ);
firstpass=true;
}
}
示例2: createScene
OSG::NodeTransitPtr createScene(OSG::Window *win)
{
OSG::NodeRecPtr rootN = OSG::makeNodeFor(OSG::Group::create());
// Create ground:
OSG::NodeUnrecPtr groundN = OSG::makePlane(25,25,1,1);
OSG::Matrix m;
OSG::Quaternion q;
q.setValueAsAxisDeg(OSG::Vec3f(1,0,0), -90);
m.setRotate(q);
OSG::TransformUnrecPtr groundTransC = OSG::Transform::create();
groundTransC->setMatrix(m);
OSG::NodeUnrecPtr groundTransN = OSG::makeNodeFor(groundTransC);
groundTransN->addChild(groundN);
rootN->addChild(groundTransN);
// Set ground material:
OSG::SimpleMaterialUnrecPtr mat = OSG::SimpleMaterial::create();
mat->setDiffuse(OSG::Color3f(0.8,0.8,0.8));
dynamic_cast<OSG::Geometry*>(groundN->getCore())->setMaterial(mat);
// // Create figure:
// OSG::NodeUnrecPtr figure1N =
// OSG::SceneFileHandler::the()->read("../Models/Figure.obj");
// G.figure1TransC = OSG::Transform::create();
// OSG::NodeUnrecPtr trans1N = OSG::makeNodeFor(G.figure1TransC);
// trans1N->addChild(figure1N);
// rootN->addChild(trans1N);
OSG::NodeUnrecPtr figureModelA =
OSG::SceneFileHandler::the()->read("../assets/Figure.obj");
BoardGame::Figure* figureA = new BoardGame::Figure();
figureA->setModel(figureModelA);
rootN->addChild(figureA->getRoot());
OSG::NodeUnrecPtr figureModelB =
OSG::SceneFileHandler::the()->read("../assets/Figure.obj");
BoardGame::Figure* figureB = new BoardGame::Figure();
figureB->setModel(figureModelB);
rootN->addChild(figureB->getRoot());
G.selectedNode = figureModelA;
return(OSG::NodeTransitPtr(rootN));
}
示例3: attachApplication
void ApplicationStartScreen::attachApplication(void)
{
Inherited::attachApplication();
//Camera Transformation Node
Matrix CameraTransformMatrix;
CameraTransformMatrix.setTranslate(0.0f,0.0f, 5.0f);
TransformRefPtr CameraBeaconTransform = Transform::create();
CameraBeaconTransform->setMatrix(CameraTransformMatrix);
NodeRefPtr CameraBeaconNode = Node::create();
CameraBeaconNode->setCore(CameraBeaconTransform);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = NULL;
//BoostPath TorusKnotFile(MainApplication::the()->getSettings()->getDataDirectory() / std::string("Models") / std::string("TorusKnot.osb"));
//SLOG << "Loading Torus Knot from: " << TorusKnotFile.string() << std::endl;
//if(boost::filesystem::exists(TorusKnotFile))
//{
//TorusGeometryNode = SceneFileHandler::the()->read(TorusKnotFile.native_file_string().c_str());
//}
//if(TorusGeometryNode == NULL)
//{
//SWARNING << "Could not load Torus Knot from: "
//<< TorusKnotFile.string() << " because this file doesn't exist." << std::endl;
TorusGeometryNode = makeTorus(.5, 2, 64, 64);
//}
//Scene Transformation
TransformRefPtr SceneTransformCore = Transform::create();
NodeRefPtr SceneTransformNode = Node::create();
SceneTransformNode->setCore(SceneTransformCore);
SceneTransformNode->addChild(TorusGeometryNode);
//Light
NodeRefPtr LightBeaconNode = Node::create();
LightBeaconNode->setCore(Transform::create());
DirectionalLightRefPtr SceneLightCore = DirectionalLight::create();
SceneLightCore->setDirection(1.0,0.0,0.0);
SceneLightCore->setBeacon(LightBeaconNode);
NodeRefPtr SceneLightNode = Node::create();
SceneLightNode->setCore(SceneLightCore);
SceneLightNode->addChild(SceneTransformNode);
// Make Main Scene Node and add the Torus
NodeRefPtr DefaultRootNode = OSG::Node::create();
DefaultRootNode->setCore(OSG::Group::create());
DefaultRootNode->addChild(CameraBeaconNode);
DefaultRootNode->addChild(SceneLightNode);
DefaultRootNode->addChild(LightBeaconNode);
//Camera
PerspectiveCameraRefPtr DefaultCamera = PerspectiveCamera::create();
DefaultCamera->setBeacon(CameraBeaconNode);
DefaultCamera->setFov (osgDegree2Rad(60.f));
DefaultCamera->setNear (0.1f);
DefaultCamera->setFar (10000.f);
//Background
GradientBackgroundRefPtr DefaultBackground = GradientBackground::create();
DefaultBackground->addLine(Color3f(0.0f,0.0f,0.0f), 0.0f);
DefaultBackground->addLine(Color3f(0.0f,0.0f,0.5f), 1.0f);
//Animation
//KeyFrames
KeyframeTransformationSequenceRefPtr TransformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();
OSG::Matrix TempMat;
TransformationKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*0.5));
TransformationKeyframes->addKeyframe(TempMat,4.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.0));
TransformationKeyframes->addKeyframe(TempMat,8.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.5));
TransformationKeyframes->addKeyframe(TempMat,12.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 0.0f));
TransformationKeyframes->addKeyframe(TempMat,16.0f);
//Animator
KeyframeAnimatorRefPtr TorusAnimator = OSG::KeyframeAnimator::create();
TorusAnimator->setKeyframeSequence(TransformationKeyframes);
//Animation
_TorusAnimation = FieldAnimation::create();
_TorusAnimation->setAnimator(TorusAnimator);
_TorusAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
_TorusAnimation->setCycling(-1);
_TorusAnimation->setAnimatedField(SceneTransformCore, std::string("matrix"));
_TorusAnimation->attachUpdateProducer(MainApplication::the()->getMainWindow()->editEventProducer());
_TorusAnimation->start();
//Foreground
//ImageForegroundRefPtr LogoForeground = ImageForeground::create();
//BoostPath LogoPath(MainApplication::the()->getSettings()->getDataDirectory() / "Images/Logo.png");
//ImageRefPtr LoadedImage = ImageFileHandler::the().read(LogoPath.string().c_str());
//.........这里部分代码省略.........