Texture Card for HUD?

Hi,

I search the forum for discussion on HUD but did not find what I was searching for so here it is:

I want to know what is the best way to do my hud. In my game, I have picture of the energy left and the sheild left. Everything is tell by color and I already have the code for managing all of that. But for showing this, I think that I can put all of my different image in a egg texture card. But when its done, how do I choose from the texture card wich one I want to show? Is it something with Geom?

I already done a button with a egg texture card and it work perfectly so any piece of code for showing a specific texture from a texture card on demand would be greatly appreciated!

If you have question, don’t hesitate to ask!

Thanks!

Jaff

Ok,

I find a way to do it.

First, I found a model with only on face so it’s like a paper and I can put the texture of my choice on it.

After that, I’ve done this:

        self.energyModel = loader.loadModel('models/logo.x')
        self.sheildModel = loader.loadModel('models/logo.x')
        
        self.energy = aspect2d.attachNewNode('hud-energy')
        self.energy.setScale(0.02)
        self.energy.setPos(0.8,0,0.85)
        self.energyModel.reparentTo(self.energy)
        
        self.sheild = aspect2d.attachNewNode('hud-sheild')
        self.sheild.setScale(0.025)
        self.sheild.setPos(0.8,0,0.85)
        self.sheildModel.reparentTo(self.sheild)

I load the texture like this (Could have done a egg texture card but I don’t see the point for now. If you could give me a good reason to do it, I will)


def loadTexture(self):
        #Loading the different textures
        self.energyGreen_tex = loader.loadTexture("models/hud/energy/energy-VERT.png")
        self.energyYellow_tex = loader.loadTexture("models/hud/energy/energy-JAUNE.png")
        self.energyRed_tex = loader.loadTexture("models/hud/energy/energy-ROUGE.png")
        
        self.sheildGreen_tex = loader.loadTexture("models/hud/sheild/armureVERT.png")
        self.sheildYellow_tex = loader.loadTexture("models/hud/sheild/armureJAUNE.png")
        self.sheildRed_tex = loader.loadTexture("models/hud/sheild/armureROUGE.png")

Finally, I put the texture of my choice using this call:

def loadTextureOnModel(self, model,texture): 
        model.setTexture(texture, 1)

If you want to comment on my solution, let’s go :slight_smile:

Thanks

Jaff

you could post a sample in the code snipplets with the necessary graphics so we could see how it works, or post a video on youtube or something