Hi guys,
Im going through the ‘beginner’ level sample called ‘Media Player’ and trying to understand it. While Ive a lot of it, I have quite a few questions. I have not yet fully understood the system of inheritance in Panda3d and I might understand it better if I can clear up these doubts. This may be a lot of questions in one post and I hope I dont annoy people… If you wish I can compile your answers together and create an FAQ for this example in order to make a return contribution to the project …
- I notice that the mediafile is read twice.
First time using:
assert self.tex.read(MEDIAFILE), “Failed to load video!”
and second time using
self.sound=loader.loadSfx(MEDIAFILE)
My understanding is that self.tex.read(MEDIAFILE) reads only the video, whereas loader.loadSfx(MEDIAFILE) reads only the audio… Am I correct here? It appears videos are considered textures by Panda3d?
-
In the statement
self.sound = loader.loadSfx(MEDIAFILE)
does self.sound automatically become an AudioSound object? I see the AudioSound object is used to test if the sound is playing later in the code using the condition
if (self.sound.status() == AudioSound.PLAYING): -
I am quite confused by this block of code :
Set up a fullscreen card to set the video texture on.
cm = CardMaker(“My Fullscreen Card”);
cm.setFrameFullscreenQuad()
cm.setUvRange(self.tex)
card = NodePath(cm.generate())
card.reparentTo(render2d)
card.setTexture(self.tex)
card.setTexScale(TextureStage.getDefault(), self.tex.getTexScale())
self.sound=loader.loadSfx(MEDIAFILE)
(a) At first glance I thought the command setFrameFullScreenQuad() would have something to do with making the video fullscreen. But it does not play as a full screen but rather in a window. So I looked up the documentation, which says: “Sets the card to (-1,1,-1,1), which is appropriate if you plan to parent it to render2d and use it as a fullscreen quad.”
What is a fullscreen quad? This video is not appearing as full screen to me…
(b) I then looked up setUvRange(Texture const tex) in the documentation.
It says “Sets the range of UV’s that will be applied to the vertices appropriately to show the non-pad region of the texture.”
What is a UV ? Is it a coordinate system like X and Y coord? Does passing the texture as the argument give me the X and Y coordinates of the video?
© In the statement
card = NodePath(cm.generate())
I understand that cm.generate() makes a node out of the cardmaker object cm. We do this because everything in Panda3d needs to be made a node to render it?
We then use NodePath() function and pass our node to it. What is the NodePath that is created? I assumed by default the node would become a child of ‘render2d’. But in the next statement we explicitly say
card.reparentTo(render2d)
So what was the parent in the first place?
(d) Why do we reparentTo(render2d) ? I thought everything in Panda3d had to be reparentTo(render) ? Is render2d a child of render?
(e) card.setTexture(self.tex)
Here card is a nodepath… why do we sassign the texture to the nodepath? I though conceptually we would assign the texture to the cardmaker cm, or to its node cm.generate(). Assigning texture to a nodepath seems unintuitive to me at first sight… In Panda3d do you assign textures to nodepaths rather than to nodes. Or have I misunderstood this?
(f) In the carousel sample the attachNewNode() function was used to create new nodes rather than the generate() method. So I thoguht to myself why not use that method. I tried to reparent cm to render2d using the following lines instead
self.new_cm_node = render2d.attachNewNode(“cmnode”)
cm.reparentTo(self.new_cm_node)
However this failed saying “Cardmaker object has no attribute reparentTo”
While I understand that you cannot use reparentTo if the method does not exist for the object and therefore this will not work, was my basic logic correct here? As in attaching a node to render2d and then trying to assign cm to it? Or is my understanding of the inheritence structure completely wrong?
Id appreciate any help here from you folks. And I hope I don’t come across as a complete idiot asking so many questions