Loading same texture more than once?

Blitz3D Forums/Blitz3D Programming/Loading same texture more than once?

PowerPC603(Posted 2004) [#1]
I'm trying to create a 3D space-sim, like Freelancer.

In Freelancer there are space-stations who have a station-base, with a couple of silos attached to them.

I wanted to use the same approach (create a stationbase called "Station01.b3d") and attach 4 textured silos (they're all the same, as they use the same b3d file = "Silo01.b3d").

So the game would load the stationbase only once and the silo 4 times.

The silo would use a texture (Silo01.bmp).

Is this texture only loaded once (because Blitz would "see" if the texture-filename is already loaded) or does Blitz load the same texture 4 times?

I know, it could be this question has been asked before, but I couldn't find it anymore.


_PJ_(Posted 2004) [#2]
You can load it once...

MyText=LoadTexture("Silo.bmp")

Texture each Silo...

EntityTexture SiloA,MyText
EntityTexture SiloB,MyText
EntityTexture SiloC,MyText
EntityTexture SiloD,MyText

then free the memory as the texture is now set to the material info of the mesh...

FreeTexture MyText

However without 'Free-ing' the Texture, you can manipulate/animate it where required, but as you are using the same texture, updating it once will update all instances.

___________________________________________

Just re-read you r post.

Are the silo meshes all the same? If so, loaad one, texture it, free the texture, and copyentity for the other 3 and just re-copy each time you need a new station.


PowerPC603(Posted 2004) [#3]
The 4 meshes are the same indeed (I would just use the command LoadMesh on it 4 times).
The 4 silos use the same b3d-file (which holds the geometry for 1 silo).

But I create those meshes in 3DS Max (where I can export them to b3d).
And the texture-filename is already present in the b3d-file, so I don't need to texture them in code anymore.

Or do I have to create just simple white meshes in Max, export them and texture them manually using code?

Actually, what you've said, could be a benefit.
Then I could create just the geometry for the silos (without a texture),
and in different sectors (= different locations) use exactly the same station, but with different textures, so it will look different, as if there are more stations of the same type.

I'm asking this now, I haven't created the meshes yet.
It would be silly to design a complete station now (with the silos included in the stationbase file), and redo everything, because I could use that new approach.


Pongo(Posted 2004) [#4]
I'm curious about this as well, although I don't have time to test it at the moment.

Perhaps try a simple scene with and without texture, using the built in texture, or assigning it in blitz. Then duplicate the object and check the available memory.

That should tell you what's going on I would think.


_PJ_(Posted 2004) [#5]
I dont make my own meshes, (Im crap at 3D modelling) and always texture them within the code, so I'm not sure what's good or bad or what really.


John Blackledge(Posted 2004) [#6]
I've been through this one and I believe I know the answer.
If, for different models, the texture filname remains the same (including folder) then Blitz spots this and reuses what it has already loaded.
If the filename remains the same, but e.g. the folder changes, then Blitz will load another copy of the texture.


PowerPC603(Posted 2004) [#7]
That shouldn't be any problem then, because I intend to put ALL my 3D-objects and their textures in the same directory.

@Malice: I have to, because I don't know anyone who could help me with that (and my game will be sold eventually, if I can get it to work like I want it to work) and I'm crappy myself in 3D-modelling.
The hardest part for me will be to create my own textures and sounds, I think that's harder to do than modelling.

First I will try to use textured meshes.
Later on, I think I will switch to non-textured meshes and texture them in code.

Thanks for all the help, mates.