自上次检查变量以来,我用 Java 编写了一些代码来计算虚拟相机中的运动。更具体地说,下面的代码:
float movementX, movementY, movementZ;
movementX = (int) (camX - sectorSize[1]);
movementY = (int) (camY - sectorSize[2]);
movementZ = (int) (camZ - sectorSize[3]);
/*
* If the variable is below 0
* then get the absolute value
* of the movement since the
* last camera position.
*/
if (movementX < 0) movementX *= -1;
if (movementY < 0) movementY *= -1;
if (movementZ < 0) movementZ *= -1;
if (movementX > 60 || movementY > 60 || movementZ > 60)
{
//Reset the sector size to allow for new points,
//don't store to save memory (may be changed later).
sectorSize[0] = 0;
}
如果您需要更多代码,请告诉我。扇区大小变量在其 [0] 值中存储 0-500,在其 [1] 值中存储前 camX,在其 [2] 值中存储前 camY,最后在其 [3] 值中存储前 camZ。camX、camY 和 camZ 由其他代码处理(未显示)。删除了除有问题的代码以外的所有内容以保持整洁。
此代码按原样工作,但每次键入“if (a_int_value > an_other_value || etc)”有点乏味。