Could someone please inform me if it is possible to change the Showbase’s model-path on the fly, i.e. when loading .obj files in a loop, each with a different sub directory and if so how?
I can load the actual .obj files in a loop from their specific directories but the loader doesn’t process the .mtl files etc. as it does when they are in the model-path directory.
I loaded the PrcFileData into my script (as per grateful advice) which allows me to open a .obj file and have it read the associated .mtl file and all jpgs, pngs etc…from the designated path
loadPrcFileData(‘’, “model-path $MAIN_DIR/models”)
provided that all the file .mtl etc are in the models sub directory as specified in the loadPrcFileData
However I need to read in (load) multiple .obj files and they reside in different directories due to conflicts with material files (jpgs etc) and the fact that the zip files from the ‘modeling program’ (SweetHome3D) exports the models in a zip file containing ‘sub models’ in different directories’
I have spent a delightful number of hours attempting to get the system to accept the ammended directory
mps = (‘’, “model-path $MAIN_DIR/models”) as original in file to i.e. mps = (‘’, “model-path $MAIN_DIR/models/somesubdir”)
i…e x = “‘’, ‘model-path $MAIN_DIR/models’”
y = ‘/somesubdir’
z = x+y
loadPRCFileData(z)
TypeError: unsupported operand type(s) for +: ‘panda3d.core.ConfigPage’ and ‘str’
loadPrcFileData(mps) → TypeError: a bytes-like object is required, not ‘tuple’
tried this
sd = ‘/subdir’
mps = mps + sd
loadPrcFileData(mps)
i.e.
mps = (“‘’, ‘model-path $MAIN_DIR/models/subdir’”)
mpsb = str.encode(mps)
Print(mpsb) → b"‘’, ‘model-path $MAIN_DIR/models’" (looks ok to me BUT)
loadPrcFileData(mpsb)
→ TypeError: load_prc_file_data() missing required argument ‘data’ (pos 2)
[the comma is there but assume as its part of the single variable …
modelPath =loadPrcFileData(‘’, “model-path $MAIN_DIR/models”)
to modelPath =loadPrcFileData(‘’, “model-path $MAIN_DIR/models/G”)
TypeError: unsupported operand type(s) for +: ‘panda3d.core.ConfigPage’ and ‘str’
next try a = bytes(‘//G’,“UTF-8”)
modelPath =modelPath + a
TypeError: unsupported operand type(s) for +: ‘panda3d.core.ConfigPage’ and ‘bytes’
tried
mpsb = str.encode(mps)
TypeError: load_prc_file_data() missing required argument ‘data’ (pos 2)
I have given up on this (beyond my paygrade) - desperately need help (expertise Please)
there is something in the Panda3D Manual ;
To manipulate this variable procedurally, use code not unlike the following, which creates an object of class ConfigVariableString and then manipulates it using the methods setValue() and getValue().
from panda3d.core import ConfigVariableString
myGameServer = ConfigVariableString(‘my-game-server’, ‘127.0.0.1’)
print('Server specified in config file: ', myGameServer.getValue())
Allow the user to change servers on the command-line.
if (sys.argv[1] == ‘–server’):
myGameServer.setValue(sys.argv[2])
print('Server that we will use: ', myGameServer.getValue())
then it mentions ConfigVariableSearchPath so
**modelPath = ConfigVariableSearchPath.setValue(mp)**
response:
AttributeError: type object ‘panda3d.core.ConfigVariableSearchPath’ has no attribute ‘setValue’
I have poked around Loader.py thinking I might be able to force it to process the .mtl file et al but again beyond my paygrade(could find no mention of if obj or anything…
Alcoholism, suicide or reverting back to day time TV threatens!
if none of this makes any sense please ask for clarification, will try to clarify if insanity hasn’t overcome me.
thanks in advance … Richard