我正在试图让我绘制的多维数据集每隔几秒就会“跳”出来。这里是我的代码:OpenGl让对象每隔N秒“跳”
for (int i=0; i<25; i++)
{
if(j<rows)
{
//Timer used in vibration calculation when drawing cubes
float time = (std::clock() - timer);
//Calculate the amount of simulated vibration based on amount of distortion (intensity)
float offset = sin(1.0f * 3.14159265359f * time) * shake;
//Draw cubes right and left of centre point
drawCube((x+xShift), y, (-300 +depth), 1.0f, cubeColour, offset);
drawCube((x-xShift), y, (-300 +depth), 1.0f, cubeColour, offset);
xShift -= gap;
}
}
而且drawCube代码:
void drawCube(float x, float y, float z, float opacity, float col[], float offset)
{
//Draw cube taking into account any offset caused by simulated vibration
glTranslatef((-x+offset), (-y+offset), -z);
glColor4f(col[0], col[1], col[2], opacity);
glutWireCube(20);
glTranslatef((x-offset), (y-offset), z);
}
我假设我需要这么立方体出现跳转到使用提高了Y值每N秒计时器但我不确定如何做到这一点?
我不知道如何使它“跳”不是。 “跳”是什么意思?你究竟想看到什么? – 2013-04-22 13:41:59
基本上每隔N秒钟我就要一排立方体以快速的顺序上升和下降,所以它看起来像是在反弹。所以我想我想让他们在Y轴上升到10.0f左右,然后回落到原来的位置。我希望每N秒触发一次该动作。 – user1356791 2013-04-22 15:16:42