Findind B3d File Textures

Blitz3D Forums/Blitz3D Programming/Findind B3d File Textures

KuRiX(Posted 2006) [#1]
I have a b3d file with their textures, all in the same dir. No problem with it.

What i want is the ability to have the b3d in other dir (let's say for example c:\temp), and that i tell him where the textures are (c:\mygame\mytextures for example).

Of course, both directories would be dynamic.

So, what i want is to copy the b3d file to c:\temp but having the textures in the installation dir.

Thanks all!


Jams(Posted 2006) [#2]
If the model is expecting the textures to be in the same directory, they *have* to be there - no compromise on that one i'm afraid.


KuRiX(Posted 2006) [#3]
Oh... I expected something like changing actualdir or something so would work... :(

Impossible then?


Damien Sturdy(Posted 2006) [#4]
I'm sure i managed to work around this. Kurix, I will get home in about 6 hours and take a look.

I'm sure when I did it, changing the current dir to the folder containing the textures, then running a "loadmesh" from there using 'Loadmesh("../meshes/level.b3d")' worked.

Seems that when loading a b3d, blitz also searches the current dir for the textures. not 100% sure though:)


GfK(Posted 2006) [#5]
If the model is expecting the textures to be in the same directory, they *have* to be there - no compromise on that one i'm afraid.

1. Load the B3D model from its location *
2. Load the texture from another location
3. Apply the texture to the model with EntityTexture

* UVs remain in tact and the model will load even if the required texture is not immediately present.


Ricky Smith(Posted 2006) [#6]
This might help.
This function will search for and copy a loaded model's texture into a designated folder. It first checks the absolute path and filename - if found it copied it to a directory appath$\mytextures. If the file is not found using the absolute path then it looks in the same folder as the model.
You need to supply the mesh handle and the mesh path.
You will also need a file utility function for the extractfilename function.



Dim c_surf(c_surfs)
Dim c_brush(c_surfs)
Dim c_tex(c_surfs)
Dim c_tex_name$(c_surfs)

Function CopyTextures(Xmesh,modelpath$)
c_surfs=CountSurfaces(Xmesh)


For i=1 To c_surfs
 c_surf(i)= GetSurface(Xmesh,i)
 c_brush(i)=GetSurfaceBrush( c_surf(i) )
 c_tex(i)=GetBrushTexture( c_brush(i) )
 c_tex_name$(i)=Lower$(TextureName$( c_tex(i))) 

	If(FileType(c_tex_name$(i)))
    
    		CopyFile (c_tex_name$(i),appPath$+"\mytextures\"+extractfilename$(c_tex_name$(i))
)
			DebugLog "Copying "+c_tex_name$(i)+" to "+appPath$+"\mytextures\"+extractfilename$(c_tex_name$(i))
	Else 


 	c_filename$=extractfilename$(c_tex_name$(i))
	DebugLog modelpath$+c_filename$ 

		If(FileType(modelpath$+c_filename$))
    
    			CopyFile (modelpath$+c_filename$,appPath$+"\mytextures\"+c_filename$)
				DebugLog "Copying "+modelpath$+c_filename$+" to "+appPath$+"\mytextures\"+c_filename$
		End If
	End If

 
 Next


For i=1 To c_surfs
 FreeBrush c_brush(i); release memory
 FreeTexture c_tex(i)
Next

End Function



KuRiX(Posted 2006) [#7]
Thanks for your help, but i need something like Cygnus solution. But it doesn't work for me :(

My model needs to load 1041 bmp's textures. So copying them or loading them manully is not an option, it is a full level map.


Cheers.

EditeD: Perhaps some manual b3d loader so i can change directories when loading... but hoping not to be slow...


Jams(Posted 2006) [#8]
"I'm sure when I did it, changing the current dir to the folder containing the textures, then running a "loadmesh" from there using 'Loadmesh("../meshes/level.b3d")' worked."

Actually that might work!


GfK(Posted 2006) [#9]
My model needs to load 1041 bmp's textures.
What the hell??? How much graphics memory is that taking up, can I ask?


KuRiX(Posted 2006) [#10]
In the low resolution version, just 50MB. They are 16bpp. The game runs on AMD 1800, 256MBRam, 128MB Geforce5200, at 75FPS


Damien Sturdy(Posted 2006) [#11]
Update:

Yes, i used the currentdir method in very early builds of the racer. It worked fnie and nobody here had any texture problems (At least, none reported...) so give it a go Kurix :)


KuRiX(Posted 2006) [#12]
I have tried! it doesn't work for me !!!

what i do:

- Copy the b3d file to c:\temp\
- ChangeDir to the dir with the textures ( i debuglog this Dir and it is perfect)
- Load c:\temp\file.b3d

I see no textures...
It should be really great to have it working! could you give me more information cygnus? Thanks!


KuRiX(Posted 2006) [#13]
Cygnus... any working example? thanks


Damien Sturdy(Posted 2006) [#14]
If i get 5 mins free i'll see if i can get a demo working, but it sounds like it just doesn't work.

A similar project I did had a lot of missing texture reports that i never figured out, this may have been why.


b32(Posted 2006) [#15]
Cygnus is right, the following code loads the model with the textures.



KuRiX(Posted 2006) [#16]
bram32, perhaps it's just working because you have absolute path references in darp.b3d, so it looks directly on the correct texture path, and no need for changedir.

Check it, please.


Mikele(Posted 2006) [#17]
Wow! It's working for me too. Textures pathes are different.
ChangeDir gamedir$ + "textures\blablablabla\mario"
mesh = LoadMesh(gamedir$ + "objects\mario2.b3d")

Hmm... It doesn't work if pathes in .b3d are absolute.


KuRiX(Posted 2006) [#18]
I use b3d pipeline, and it doesn't work for me :(

EDITED: Oh MY! If i uncheck Relative Paths it works!

Thanks Everyone!

Great!


Damien Sturdy(Posted 2006) [#19]
Heh, another Quirk i found eh? :-)


KuRiX(Posted 2006) [#20]
When are you going to set a paypal donation site for quirks!!!

Thanks ;)


b32(Posted 2006) [#21]
In the code archive is a code by jfk EO-11110 that saves B3D files. It shows the B3D file structure clearly.
http://www.blitzbasic.com/codearcs/codearcs.php?code=866

I checked if the paths of the textures were relative using this program:



Damien Sturdy(Posted 2006) [#22]

When are you going to set a paypal donation site for quirks!!!



I got one, but I'm not the one who made it possible ;)