Brushes limit for a mesh?
Blitz3D Forums/Blitz3D Programming/Brushes limit for a mesh?
| ||
I don't know where i picked it up, but i thought there was an 8 brushes limit to a mesh? If there's not, does anyone know what the limit is? I am trying to scan a mesh to see how many brushes it has applied to it. |
| ||
Ok, so i've counted that there are 9 surfaces on my mesh. Is there no limit to that? This kind of throws alot of what i thought i knew in the air. |
| ||
Ok, so limme see if this is right: A mesh can have as many brushes/surfaces as it wishes. A brush is a surface. A brush may have up to 8 textures. The only thing that doesn't really make sense, is the entitybrush thing. Whats the point in it? Does it get added over the top of the surface brushes? Or does it override them? |
| ||
I don't know where i picked it up, but i thought there was an 8 brushes limit to a mesh? Nope. Perhaps you're thinking of texture layers? A mesh can have as many brushes/surfaces as it wishes. I've never hit a limit and I've gone way over eight. There might be some arbitrary limit, but I would think it would high. 255 at least. A brush is a surface. Not exactly, but basically. A brush is a Blitz invention, doesn't really have any corresponding lower-level structure. It's a set of material properties, for want of a better description. But it's applied on a per-surface basis, yes. You can, of course, apply the same brush to lots of different surfaces. And probably should. Brushes are just a convenient way of applying the same properties to multiple entities without duplicating all the commands over and over. No more, no less. A brush may have up to 8 textures. Yep, just as if you were applying them directly with EntityTexture. The only thing that doesn't really make sense, is the entitybrush thing. Whats the point in it? Does it get added over the top of the surface brushes? Or does it override them? What EntityBrush thing is this? I've never used that command and it seems to be undocumented. I also don't have B3D installed right now so I can't see what it does. Is it the opposite of PaintEntity? As in, it returns the brush you painted an entity with if indeed you have painted an entity with a brush? |
| ||
I'm not sure, but you have two commands. GetEntityBrush and GetSurfaceBrush. Back to the other point, i assume that when use entitytexture, a brush is created and applied to the mesh, also creating a brush texture? |
| ||
Well you do have PaintEntity and PaintSurface, the former applying the same brush to all surfaces. So I guess that would make sense. I haven't tested, but I don't think a brush is automatically created when you use EntityTexture. I think brushes are created when you use the GetBrush commands, and the properties are populated at that point. |
| ||
Hmmm, that would make more sense. I posted another topic on this about creating clone brushes. So basically, when a mesh is loaded, no brushes are created or textures. But using GetBrush commands, that actually creates them? Just didn't see the point in freeing them afterwards, as this would surely free the texture i just modified... Thanks for your help on this btw. Most appreciated! |
| ||
I'm pretty sure - though this is all from memory - that the GetBrush() stuff was added much later after frequent requests from people. I'm also pretty sure that there were discussions that using it caused memory to be allocated, indicating that the brush was being created or copied from the original. That you were, in fact, not getting the original brush back. Test it to be sure, but I'm pretty sure freeing a brush won't free anything attached to it. Again, don't take this as gospel, but I'm pretty sure you can think of brushes as something like this : Type Brush Field Tex1:Int Field Tex2:Int Field Tex3:Int Field Tex4:Int End Type PaintEntity(Entity,Brush) Function PaintEntity(E,Brush) EntityTexture E,Brush\Tex1,0 EntityTexture E,Brush\Tex2,1 EntityTexture E,Brush\Tex3,2 EntityTexture E,Brush\Tex4,3 End Function Apologies if my syntax is a bit off there, it's been ages since I did any B3D. Anyway, what that's supposed to illustrate is that it's really no more than a wrapper for your Entity commands. I'd be VERY surprised if it freed a texture when the brush was freed. I think it's just a bunch of fields storing anything you send to it and then when you paint with it, it triggers all the entity commands you would have used. You'd need Mark or Simon, or perhaps just someone a bit smarter than me to confirm this, but I think this is how it works. Ironically, I never used brushes when I was coding with B3D and now that I'm coding with BlitzMax and TV3D, I've invented my own brush class encompassing everything the B3D brushes encompass and several other things like lights and shaders which B3D doesn't actually have, but might be well be in brushes if it did. |
| ||
Hehehe :o) Well, that makes most thing clearer, thanks. Still makes me wonder though. I'm creating an editor, with the ability to save to .b3d. After getting a little frustrated the code archives ones didn't work, i set out to code my own. If i'm creating copies of brushes and textures every time i load a mesh, i guess that's the way it'll have to be. Thanks again for your time with this. Most helpful and much appreciated. Cheers! |
| ||
Ok, well, i've made a discovery. It seems everything created in blitz, has a brush. If you do:s = CreateSphere() Then this is given an Entity Brush. Seems to be different from a surface brush. I checked through all the surfaces and didn't find any textures on them. So, it seems the EntityBrush comes from the EntityTexture command. I assume any loaded in meshes, that have been textured from a modeller, will have surface brushes. |
| ||
I assume any loaded in meshes, that have been textured from a modeller, will have surface brushes. brush = material and there is one material/brush per surface (a material/brush has color, alpha, shininess, fx, blendmode, and can have one or several textures) |
| ||
Gabriel is correct in that GetEntityBush and GetSurfaceBrush actuaally generate an identical copy of the information, so you may need to track the return handle from using these commands and free it afterwards in order to prevent memory leaks. |