Counting Brush Textures?

Blitz3D Forums/Blitz3D Programming/Counting Brush Textures?

Ross C(Posted 2006) [#1]
Hey guys/gals. I don't suppose there is anyway to count the brush textures? Upon writing this i just realise that that would be kind of pointless. I guess you just loop through each brush texture slot and see if it holds a texture?


jfk EO-11110(Posted 2006) [#2]
That's what I would try too. I guess it will return zero if there's no texture. Note GetSurfaceBrush and GetBrushTexture will create a clone Brush/Texture that needs to be deleted after eg. counting the textures.


Ross C(Posted 2006) [#3]
So, say if i wanted to get the texture that was on a 3d model, i would be creating a clone? So, how do i access the texture on the model?


jfk EO-11110(Posted 2006) [#4]
Sorry, was AFK for a while.

No, you don't need to create a clone.

If you're working on the mesh level (not animesh) than you have to track down the textures this way:

Get the surfaces one by one.
Get each surfaces brush
Get each brushes testureS
If you want get each textures file path.


The SaveB3D example in the archives /mesh stuff shows clearly how to determine the used textures.

In your case you will also do a "repeat until texture handle returns zero" check to determine potential multiple textures of a brush.

The commands GetBrushTexture and GetSurfaceBrush will create a clone brush and texture for some reason, so you need to free them after usage. No Mesh clone.


Ross C(Posted 2006) [#5]
Sorry to bring this up again, but... if it creates a clone texture and clone brush, how can i access the texture, change it (draw on it) and keep the results. Surely if i create a clone, edit that, then free it, it will be lost?


jfk EO-11110(Posted 2006) [#6]
Simply PaintSurface the surface in question with the new brush, and don't delete it. I guess the old one, that is not in use anymore, will be freed automaticly with the next garbage collection, or at least as soon as directX needs to optimize the resources for some reason.


Ross C(Posted 2006) [#7]
Fair point :o) Will do. I am finding out alot about what seems to go on behind the scenes with blitz. For instance, as i have posted in my other post, EntityTexture seems to add a texture to the EntityBrush, rather than a surface texture brush. I guess this was for ease of use for beginners, who simply wanted to slap on a texture, without creating a brush first. Makes saving a dam pain though :o)


John Blackledge(Posted 2006) [#8]
This is probably not what you want but may be useful anyway:
Model's Texture names:
http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=1626


Ross C(Posted 2006) [#9]
Thanks John. I have read over Ricky Smith's archive code, and i'm going to get the brush textures by reading through the actual .b3d file. Keep you'z posted and hopefully have a save routine that easy to use and very portable.