zoukankan      html  css  js  c++  java
  • osg模型操作之矩阵变换(直接对矩阵操作,从而达到效果)

    矩阵变换节点:

      由osg::MatrixTransform : osg::Transform : osg::Group : osg::Node : osg::Object : osg::Referenced的继承。

      主要作用是负责场景的矩阵变换、矩阵的运算及坐标系的变换。实现对场景的模型进行旋转、平移等操作。

    常用主要成员函数:

      void setMatrix(const Matrix &mat)//设置矩阵。

      const Matrix & getMatrix() const //得到矩阵。

      void preMult(const Matrix &mat)//递乘,比较类似于++a。

      void postMult(const Matrix &mat)//递乘,比较类似于a++。

      const Matrix & getInverseMatrix() const //得到逆矩阵。

    例如:

      osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;

      mt->setMatrix( osg::Matrix::scale(scaleX,0.0,0.0) * osg::Matrix::rotate(rotateZ,osg::Z_AXIS) * osg::Matrix::translate(posX,0.0,0.0)  );

      上面这两行的代码执行的效果是:对模型x轴缩放scaleX,沿z轴旋转rotateZ度,沿x轴移动posX长度。

    相关示例:

      

      

      运行效果:

      

        对牛的位置做了平移和旋转。

  • 相关阅读:
    c++ isdigit函数
    c++ swap函数
    1.2Hello, World!的大小
    1.2整型与布尔型的转换
    1.2打印ASCII码
    leetcode[170]Two Sum III
    leetcode[167]Two Sum II
    leetcode[1]Two Sum
    leetcode[2]Add Two Numbers
    leetcode[3]Longest Substring Without Repeating Characters
  • 原文地址:https://www.cnblogs.com/airduce/p/9620284.html
Copyright © 2011-2022 走看看