Hi! I’m trying to make waves on an ocean by manipulating the vertices of a plane from frame to frame. I’ve taken some code from the manual and it seems to be working, because the plane is distorted to a wavy pattern when the game is startet. However nothing more happens and the waves are frozen instead of moving. The code for the vertice is in the main game loop, and i know the code is run each frame, but it doesn’t seem to do anythin. The code is:
#change z component of vertices in water plane geomNodeCollection = self.waves.findAllMatches('**/+GeomNode') for nodePath in geomNodeCollection.asList(): geomNode = nodePath.node() for i in range(geomNode.getNumGeoms()): geom = geomNode.getGeom(i) vdata = geom.getVertexData() vertex = GeomVertexRewriter(vdata, 'vertex') while not vertex.isAtEnd(): v = vertex.getData3f() #print v, self.waveFunction(v,v,task.time) vertex.setData3f(v, v,self.waveFunction(v,v,task.time))
And the wave function is:
#waveFunction def waveFunction(self,x,y,time): z=(math.sin(time+x/WAVE_LENGTH)+math.sin(y+x)/WAVE_LENGTH)*WAVE_HEIGHT/2 return z
The wave is time dependent, so there should be differences from frame to frame. But there’s not! Help me!!