Return default loaded texture (OpenB3D)
BlitzMax Forums/MiniB3D Module/Return default loaded texture (OpenB3D)
| ||
Does anyone know if there's a way to return the default texture used by a loaded mesh? Let's say I've made a mesh of a dumpster and that the texture it uses is "dumpster_texture.png". When I've loaded my dumpster into OpenB3D I want to somehow get that "dumpster_texture.png" filename. I've tried stuff like Mesh.GetSurface(1).brush.name[0] and Mesh.GetSurface(1).brush.tex[0].file But only get blank results. |
| ||
Haven't tried, is it supposed to be a similar command like in B3D? |
| ||
I haven't tried with B3D, so I have no idea. |
| ||
Not sure if this is exactly what you're looking for but probably this one: http://www.blitzbasic.com/b3ddocs/command.php?name=GetBrushTexture To find out the name of the texture, use TextureName$ http://www.blitzbasic.com/b3ddocs/command.php?name=TextureName OpenB3D Equivalent: GetBrushTexture https://github.com/markcwm/openb3d.mod/blob/master/openb3d.mod/inc/TBrush.bmx#L87 TextureName https://github.com/markcwm/openb3d.mod/blob/master/openb3d.mod/inc/TTexture.bmx#L267 |
| ||
How do you know it's on surface 1? How do you know that that surface has a valid brush, instead of the default blank brush? You have to dig through all the surfaces (and their respective brushes) of the mesh. If you still can't find it then you're querying the wrong mesh. |
| ||
@Kryzon Because I made the mesh myself and I know it's only got one surface, and since GetSurface(0) is always blank it means 1 will be the first surface in the mesh. Oh and accessing 0 or 2 spits out "Attempt to access field or method of Null object" anyways. So for this test mesh I'm sure it's surface 1 I want. :) @RustyKristi Nice find! TextureName() does work with textures I've loaded myself. But I can't get it to work with a texture loaded by a mesh. For example TextureName(GetBrushTexture(GetSurfaceBrush(GetSurface(Mesh, 1))))doesn't seem to work... Nor does the more direct way TextureName(Mesh.GetSurface(1).brush.tex[0])They always just return a blank string. Oh and just to be sure. I also tested this For Local i:Int = 1 To CountSurfaces(mesh) Print TextureName(GetBrushTexture(GetSurfaceBrush(GetSurface(Mesh, i)))) NextBut only blank strings are returned. |
| ||
Good start! Maybe you can check with minib3d or B3D if what you're looking for is indeed supported. |
| ||
For now I'm just going to assume that all meshes use one texture and that the filename is the same as the mesh's filename but as a PNG. It's a bad way of doing it, but I need to move forward. If anyone finds a way of doing it, please give me a heads up. And thanks for all the help. |
| ||
Send the model to my e-mail and I'll try here. |
| ||
It's literally just a quad with a smiley face on. Here you go anyways: https://dl.dropboxusercontent.com/u/2842751/plane.zip |
| ||
Hi. I haven't downloaded it yet, but please try this first.myTexture:TTexture = GetBrushTexture( GetSurfaceBrush( GetSurface( Mesh, 1 ) ) ) ) file:String = String.FromCString( TextureString_( TTexture.GetInstance( myTexture ), TEXTURE_file ) ) file_abs:String = String.FromCString( TextureString_( TTexture.GetInstance( myTexture ), TEXTURE_file_abs ) ) Print file Print file_abs |
| ||
It prints two empty strings. Infact it works just like the tests above. It works with an actual Texture I load myself, but not with textures from a mesh. I'm guessing OpenB3D forgets to set those fields when loading a mesh. |