Changing a .b3d texture on-the-fly

Blitz3D Forums/Blitz3D Programming/Changing a .b3d texture on-the-fly

puki(Posted 2006) [#1]
It may seem an odd enquiry - but I know little about modelling.

Let's suppose I have a character called 'Man.b3d'.

Let's suppose the texture file-name is hard-coded into the .B3D file - ie 'Man.jpg'.

If I then load that .b3d model into Blitz, and then load another skin (Man2.jpg) and then 'EntityTexture' the new skin to the mesh, what happens to the original texture?

Do both textures exist inside Blitz3D as being applied to the model? Or is Blitz3D cunning enough to kill the first one. Do both textures remain in memory? Does the first texture go into 'limbo'. Can you 'Freetexture' the first texture if it is not killed by the second texture?

I hope I have made sense there. Anyway, hopefully someone can shed a bit of light here.


Tom(Posted 2006) [#2]
I'm guessing limbo until you ClearWorld ents=true,brushes=true,textures=true


puki(Posted 2006) [#3]
Ah, thanks "Tom". I was supsicious it went into 'limbo' as even when you 'FreeTexture' a texture from memory it remains on any objects in memory - yet the second texture would have taken its place.


puki(Posted 2006) [#4]
However, this raises a new question:

What is the best way to remove a hard-coded texture file-name from a .b3d file?


big10p(Posted 2006) [#5]
What about loading the models into an editor/modeller and removing the textures. Then, load the models and textures separately in Blitz3D, and apply textures as required.


puki(Posted 2006) [#6]
Ah, what editor do you suggest? Smartie-shaped editor, Squirrel paw-shaped editor, perhaps Amphibious landing craft-shaped editor'?


big10p(Posted 2006) [#7]
Knob-shaped editor, natch.


puki(Posted 2006) [#8]
Mmm. I used Ultimate Unwrap - not knowing what I was doing, I just looked at the right-hand side of the screen and noted 'Groups/Materials/Bones'. 'Materials' looked interesting - it seemed to contain the texture - so I simply deleted it entirely (the whole thing).

However, the new model has increased in size - it was 949KB, now it is 967KB.

The end result worked - the model has no texture at all and the file structure of the .b3d file reflects it has no default texture - yet, I am not sure how the file size has increased.


EDIT:
I just got the file size to drop by not selecting to re-export vertex normals or vertex colours. File size is now 936KB - which would be about right to remove the texture file-name from the structure.


Tom(Posted 2006) [#9]
Freaking out over 18kb? :P


Naughty Alien(Posted 2006) [#10]
..maybe its better to explain what you trying to achieve buddy...big10p is right if you trying to change texture becouse of 'new better look' in your game or whatever...if you trying to do something else, approach should be different..so..give it a try and give us more details about task you trying to achieve..


Ross C(Posted 2006) [#11]
Change the texture. How about, loading the new texture and copying rect-ing over the old one?


puki(Posted 2006) [#12]
Not my stuff - I have paid for these:

http://www.cubixstudio.com/MaleNPCInfo.html

There is one .b3d mesh - but 2 skins. The .b3d had the file-name of one of the skins hard-coded - so it auto loads onto the mesh when you load the .b3d. So, I was purely wondering what would happen if I applied the second skin when I had loaded it. I couldn't see the point of hard-coding the texture file-name to a .b3d whereby it comes with 2 skins.


jfk EO-11110(Posted 2006) [#13]
All you have to do is to check the hierarchy of the b3d recursively and EntityTexture those children that are meshes. See the "how to make entityalpha work with animated meshes" (or alike) in the archives for an example on recursively parsing the entity hierarchy.

For multitextured stuff you may track down the used textures as seen in the "SaveB3D" source and then use PaintSurface to replace certain textures.

AFAIK Blitz will do an automatic Garbage collection. When a Texture is freed, its space is available. Although physicly still there and even the entity handle still working, but you could compare this to the file system that only releases the space occupation referenced in the FAT, the data is still there.

Blitz has no known memory leak and manages memory nicely. When you try to load something twice, it will reuse the loaded data and only create an instance. When you AddMesh a few meshes together and some of them use the same textures, it will minimize the surface count automaticly.


Ruz(Posted 2006) [#14]
I reckon the texture goes on holiday for a while then comes back when its feeling better