Water Reflection camera placement

I’m trying to put water into my game, and I’m stuck right now. I’m trying to get the correct placement for the water camera, but nothing I’ve tried works. I’m thinking It may have something to do with my nesting/parenting. (Main camera is parented to a dummy node that’s in turn parented to a physics controller, however the dummy done does pitch independently) I’ve tried using getNetTransform, and I’ve also tried adding a parameter to getMat. None of these produce the desired effect. Here’s the important snippets.

This is the water creation code

self.waterReflectionBuffer=base.win.makeTextureBuffer("waterreflectionbuffer", 1024, 1024)
		self.waterReflectionBuffer.setClearColor( Vec4( 0, 0, 0, 1 ) )
		self.waterReflectionCam.node().getLens().setFov(75)  //the same as my main camera, should I be setting this?
		self.waterPlane = Plane(Vec3(0, 0, 4.0), Point3(0, 0, 3.0)) 
		self.PlaneNP = NodePath(PlaneNode("waterPlane", self.waterPlane))
		np = NodePath('np') 
		maker = CardMaker( 'waterMaker' )
		maker.setFrame( -50, 50, -50, 50 )
		self.waterNP = render.attachNewNode( maker.generate( ) )
		self.waterNP.setPos( 0, 0, 3 )
		self.waterNP.setP( -90 )
		tex0 = self.waterReflectionBuffer.getTexture( )
		ts0 = TextureStage( 'reflection' )
		self.waterNP.setTexture( ts0, tex0 )

This goes in my update task.

		# Water reflections
		mc = base.camera.getMat()
		mf = self.waterPlane.getReflectionMat()
		self.waterReflectionCam.setMat(mc * mf)

The transform is relative to main camera’s parent, so to transfer it correctly, get the transform relative to reflection camera’s parent.

Sorry, I don’t quite get what you mean. Could you explain that in more detail?

This :

      mc = base.camera.getMat()

only works correctly if both main camera and reflection camera are directly parented to the same node, say render.
But, in your case they are not.

So, you have to get the transform matrix relative to reflection camera’s parent, as if they are parented to the same node (reflection camera’s parent) :

      mc = base.camera.getMat(self.waterReflectionCam.getParent())