4D星宇

c++

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  57 随笔 :: 0 文章 :: 39 评论 :: 0 Trackbacks

这个KEY移动是最傻的,像螃蟹一样!

if (isKeyDown(KEY_KEY_W) || isKeyDown(KEY_UP) && !zooming)
   {
      if (!translating)
         translating = true;
      else
      {
         vector3df movevector = getPosition() - getTarget();
         movevector.Y = 0;
         movevector.normalize();

         setPosition(getPosition() - movevector * translateSpeed);
         setTarget(getTarget() - movevector * translateSpeed);
         updateAbsolutePosition();
      }
   }
   else if (isKeyDown(KEY_KEY_S) || isKeyDown(KEY_DOWN) && !zooming)
   {
      if (!translating)
         translating = true;
      else
      {
         vector3df movevector = getPosition() - getTarget();
         movevector.Y = 0;
         movevector.normalize();

         setPosition(getPosition() + movevector * translateSpeed);
         setTarget(getTarget() + movevector * translateSpeed);
         updateAbsolutePosition();
      }
   }
   else if (isKeyDown(KEY_KEY_A) || isKeyDown(KEY_LEFT) && !zooming)
   {
      if (!translating)
         translating = true;
      else
      {
         vector3df totargetvector = getPosition() - getTarget();
         totargetvector.normalize();
         vector3df crossvector = totargetvector.crossProduct(getUpVector());
         vector3df strafevector = crossvector.normalize();

         setPosition(getPosition() - strafevector * translateSpeed);
         setTarget(getTarget() - strafevector * translateSpeed);
         updateAbsolutePosition();
      }
   }
   else if (isKeyDown(KEY_KEY_D) || isKeyDown(KEY_RIGHT) && !zooming)
   {
      if (!translating)
         translating = true;
      else
      {
         vector3df totargetvector = getPosition() - getTarget();
         totargetvector.normalize();
         vector3df crossvector = totargetvector.crossProduct(getUpVector());
         vector3df strafevector = crossvector.normalize();

         setPosition(getPosition() + strafevector * translateSpeed);
         setTarget(getTarget() + strafevector * translateSpeed);
         updateAbsolutePosition();
      }
   }

posted on 2008-04-24 15:59 bloodbao 阅读(182) 评论(0)  编辑 收藏 引用 所属分类: c++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理