If BSP shaders really are, what is missing here, then this doesn't need game specific code, but a generic implementation of BSP shader loading in JAGaToo.
I don't think they are "BSP shaders". They're rather "Quake3 shaders". BSP format itself seems to have no particular dependency on those. Right now I have no facts of their use in games other than of Q3 engine family.
If you really need a game specific AppearanceFactory, we might need to trick the ModelLoader to take an instance of it to do loading with it.
Well, I did some experiments again with those classes. Here's where I am now. Passing my own AppearanceFactory to the BSP loader is not a problem. I just copied some code from ModelLoader. Don't be scared, this is Scala

object LocationLoader extends ModelLoaderWrapper {
def loadLocation (locationURL: URL): Model = {
val location = new Model()
BSPPrototypeLoader.load(locationURL.openStream(),
LoaderUtils.extractFilenameWithoutExt(locationURL),
null,
new XithGeometryFactory( Geometry.Optimization.USE_DISPLAY_LISTS ),
true, 0.03f,
new GameAppearanceFactory,
new XithNodeFactory,
location, GroupType.BSP_TREE,
getSI(location))
return location;
}
}
BTW, loading a BSP through ModelLoader is not very useful anyway since BSP models are not as generic as all others and need some special treatment in 90% cases, since they contain much more data than just a model.
So, I had to wrap ModelLoader with another Java subclass to get access to SpecialItemsHandlerImpl, because its
protected static and thus inaccessible to Scala object model:
public class ModelLoaderWrapper extends ModelLoader {
protected SpecialItemsHandler getSI(Model model) {
return new SpecialItemsHandlerImpl(model);
};
}
What's really bad is that I can't subclass neither XithAppearanceFactory nor XithNodeFactory and override their methods because they are all
final. The idea is to write my own XithAppearanceFactory.loadOrGetTexture which won't return fallback texture for a missing file if there's a shader description instead. Then in XithNodeFactory.createShape it will be possible to catch those textures and apply appearance properties described by a shader - effectively making a BSP brush invisible or whatever else. It can't be done earlier, because BSPConverter may alter Appearance many times before creating a final shape.
That's the plan. Now I have copy-pasted XithAppearanceFactory (can't override) to make my GameAppearanceFactory and going to make the same with XithNodeFactory. This looks ugly, but I have no better idea

. But no modifications to Xith or Jagatoo are totally necessary right now.