Saving a .b3d with a brush?
Blitz3D Forums/Blitz3D Programming/Saving a .b3d with a brush?
| ||
I downloaded the .B3D format files from the Specs and utils. It has a demo that uses a red sphere and saves and loades it. Works great. Anyone know how to make it save the texture brush? |
| ||
you need to add the [TEXS] chunk before the [BRUS] chunk |
| ||
This isn't working but it doesn't look too bad I think. All I need to do is save the floor2.jpg as a brush and then assign it I guess... Function WriteBB3D( f_name$,mesh ) file=WriteFile( f_name$ ) b3dSetFile( file ) b3dBeginChunk( "BB3D" ) b3dWriteInt( 1 ) ;version b3dBeginChunk( "TEXS" ) b3dWriteString "floor2.jpg" ;name b3dWriteInt ( 9 ) ;flags b3dWriteInt ( 2 ) ;blend b3dWritefloat ( 0 ) ;xpos b3dWritefloat ( 0 ) ;ypos b3dWritefloat ( 1 ) ;xscale b3dWritefloat ( 1 ) ;yscale b3dWritefloat ( 0 ) ;rot b3dEndChunk() ;end of TEXS chunk b3dBeginChunk( "BRUS" ) b3dWriteInt( 1 ) ;0 textures per brush b3dWriteString( "floor2.jpg" ) ;name b3dWriteFloat( 1 ) ;red b3dWriteFloat( 1 ) ;green b3dWriteFloat( 1 ) ;blue b3dWriteFloat( 1 ) ;alpha b3dWriteFloat( 0 ) ;shininess b3dWriteInt( 1 ) ;blend b3dWriteInt( 0 ) ;FX b3dEndChunk() ;end of BRUS chunk b3dBeginChunk( "NODE" ) b3dWriteString( "entity_name_here!" ) b3dWriteFloat( 0 ) ;x_pos b3dWriteFloat( 0 ) ;y_pos b3dWriteFloat( 0 ) ;y_pos b3dWriteFloat( 1 ) ;x_scale b3dWriteFloat( 1 ) ;y_scale b3dWriteFloat( 1 ) ;z_scale b3dWriteFloat( 1 ) ;rot_w b3dWriteFloat( 0 ) ;rot_x b3dWriteFloat( 0 ) ;rot_y b3dWriteFloat( 0 ) ;rot_z WriteMESH( mesh ) b3dEndChunk() ;end of NODE chunk b3dEndChunk() ;end of BB3D chunk CloseFile file End Function |
| ||
Here is a sample code to include the [TEXS] chunk: In your [BRUS] chunk you forgot to include the ID of the texture being used. |
| ||
Thanks Kevin. Here's what I'm actually trying to do. My editor creates rooms. Each room is a separate mesh. I am texturing each triangle on each surface. So what I really need is a .b3d saver that saves multiples meshes into one file while storing the brushes for each triangle of every surface(mesh). For example the floors and ceiling of a room have different brushes than the walls. |
| ||
Here's an example. The level will have mulitiple rooms and corridors. Each needs to be saved in one .b3d but with all the brushes(textures) in tact. |
| ||
Just set up a different [BRUS] and [TEXS] chunk for each texture used and set up each [TRIS] and [MESH] chunk with the proper brush ID. The brush and texture chunks can be stacked onto each other, I believe. Example: if you are using 5 textures you can have 5 [TEXS] chunks and the same with the brushes. |