这个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();
}
}