Stretching Video Texture

I want to render the video from my webcam on an object from my egg file. Here is the code:

videoTexture = OpenCVTexture() 
videoTexture.fromCamera() 
 
mymodel = loader.loadModel('device.egg') 
mymodel.reparentTo(render) 
deviceScreen = self.base.find("**/screen") 
deviceScreen.setTexture(videoTexture)

This works but the video is stretched proportionally and I want the video fills all the object face. So I have a second thought is to render the video on a card, this is the code:

 
videoTextureScale = videoTexture.getTexScale() 
 
card = CardMaker('videoFace') 
card.setFrame(-videoTextureScale[1],videoTextureScale[1],-videoTextureScale[0],videoTextureScale[0]) 
card.setUvRange(Point2(videoTextureScale[0],0), Point2(0,videoTextureScale[1])) 
card = render.attachNewNode(card.generate()) 
card.reparentTo(deviceScreen.getParent()) 
card.setTexture(videoTexture) 
 

And a new doubt comes to me, how do I size and locate the card as the screen object?

You can use setPos and setScale for that.

I was wondering how I would be able to set one object’s size and position with another one’s values.

These sorts of things are illustrated in the manual and in the sample programs.

David

This is very useful for determining the right values:

model.place()