Frame Texture


When I set the image or texture parameter in a DirectFrame the image is stretched.
There is a approach to reduce the scale of the texture and fill the frame?


Doesn’t image_pos and image_scale help?

if it appears streched its most likely due to the aspect-ratio of your frame, and the one of your texture differ too much. esiest way is to create textures with aproximately the same aspect ratio.

the problem is that I have several frames in different sizes, and I would like to use the same texture in all, with the mode WMRepeat

in my terrain I used:
nodePath.setTexScale(TextureStage, uScale, vScale)
but gui components dont accept it

Hmm, you can try creating a card using the CardMaker, and applying your texture to it? You can also set the uv range in the card maker, just look it up in the API ref.

I don’t have any problem with label.setTexScale():

from direct.directbase.DirectStart import *
from direct.gui.DirectGui import *
from pandac.PandaModules import *

tex = loader.loadTexture('maps/color-grid.rgb')

left = DirectLabel(frameSize = (-1, -0.5, -0.25, 0.25),
                   frameTexture = tex,
                   frameColor = (1, 1, 1, 1))
right = DirectLabel(frameSize = (0.5, 1.0, -0.95, 0.95),
                    frameTexture = tex,
                    frameColor = (1, 1, 1, 1))

right.setTexScale(TextureStage.getDefault(), 1, 0.95/0.25)


frame.setTexScale(TextureStage.getDefault(), u, v) 

this works fine, but using the default TextureStage affect all the other textures, including OnscreenImage. I can create another TextureStage, but I dont know how to set it to the frame

the CardMaker also worked fine.

Ah, an excellent point. Right, the DirectGui items don’t make it easy for you to specify a particular TextureStage. It’s probably possible, since the DirectGui just creates a bunch of nodes internally, and you can always go in there and modify the nodes as you see fit afterwards–but this is messy.

If the CardMaker solution works for you, that’s probably better.


this is my code using CardMaker with DirectFrame:

import direct.directbase.DirectStart
from direct.gui.DirectGui import DirectFrame
from pandac.PandaModules import *
import math

scale = 8
texture = loader.loadTexture('marble2.png')

def setTexCard(frame):
   r = frame['frameSize']
   w = abs(r[0]) + abs(r[1])
   h = abs(r[2]) + abs(r[3])   
   cm = CardMaker('bg')
   cm.setUvRange(Point2(w*scale,h*scale), Point2(0,0))
f1 = DirectFrame(frameSize=[.2,-.2,.4,-.4], pos=(.5,0,0))
f2 = DirectFrame(frameSize=[.2,-.2,.2,-.2], pos=(-.5,0,0))
f3 = DirectFrame(frameSize=[.1,-.1,1,-1], pos=(0,0,0))


thank you guys for the help