【DX9】实现让绘制的物体旋转

下面这段代码利用了变形矩阵:

  //
  // spin the object:
  //
  D3DXMATRIX Rx, Ry;

  // rotate 45 degrees on x-axis
  D3DXMatrixRotationX(&Rx, 3.14f / 4.0f);

  // incremement y-rotation angle each frame
  static float y = 0.0f;
  D3DXMatrixRotationY(&Ry, y);
  y += timeDelta;

  // reset angle to zero when angle reaches 2*PI
  if( y >= 6.28f )
   y = 0.0f;

  // combine x- and y-axis rotation transformations.
  D3DXMATRIX p = Rx * Ry;

  Device->SetTransform(D3DTS_WORLD, &p);

记下了~

你可能感兴趣的:(【DX9】实现让绘制的物体旋转)