Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 作业1 高阶任务 绕X、Y轴旋转效果图 是否正确?

Tagged: 

Viewing 1 reply thread
  • Author
    Posts
    • #9118 Score: 0
      huhuhuhu
      Participant

      按照接口定义Eigen::Matrix4f get_rotation(Vector3f axis, float angle) 用XYZ轴简单验证下
      Vector3f axisX(1.0f, 0.0f, 0.0f);
      Vector3f axisY(0.0f, 1.0f, 0.0f);
      Vector3f axisZ(0.0f, 0.0f, 1.0f);

      贴下动图,想请教下对不对

      Attachments:
      You must be logged in to view attached files.
    • #10512 Score: 0
      DT
      Participant

      我也是这样的,但是我的沿 X 轴旋转如果离屏幕过近程序就会崩溃退出,不知道你有没有碰到这个问题呢?

      • This reply was modified 3 months, 2 weeks ago by DT.
      • #10803 Score: 0
        whiteandbright
        Participant

        我也遇到闪退的问题了,请问您解决了吗

        • #10810 Score: 1
          炎炎夏日丽丽在目
          Participant
          1 pt

          void rst::rasterizer::set_pixel(const Eigen::Vector3f& point, const Eigen::Vector3f& color)
          {
          //old index: auto ind = point.y() + point.x() * width;
          if (point.x() < 0 || point.x() >= width ||
          point.y() < 0 || point.y() >= height) return;
          auto ind = (height-point.y())*width + point.x();
          // if out of range, return
          if (ind >= width * height) return;
          frame_buf[ind] = color;
          }
          闪退是因为在set_pixel计算ind的时候,超出屏幕外的三角形边上的点对应的ind会大于或者等于width * weight,而frame_buf的大小为width * weight,所以会发生数组访问越界错误,加上这个判断即可

          This post has received 1 vote up.
          • #10814 Score: 0
            DT
            Participant

            感谢!想到了但还没时间改,看来没想错

Viewing 1 reply thread
  • You must be logged in to reply to this topic.