Using tags to place items in scene?

Hello, I have a 3d level mesh in 3ds max where I’d like to place objects in certain areas.

To do this, I was thinking of placing small spheres in areas where I’d like to place some particular object, like a spawn point or some mesh like a weapons rack.

For each of these spheres, I would set a user definition in the objects properties to something like:
weaponsrack = 1


spawnpoint = 1

I would export this to the egg using the 3ds max exporter, and in the code I would do something like this:

levelmodel = loader.loadModel(‘level.egg’)
racknode = levelmodel.find(’**/=weaponsrack’)
rackmodel = loader.loadModel(‘weaponsrack.egg’)

Or something along those lines. The idea is to use spheres as a placeholder for some other object which will be put in later. I would get the sphere’s position, detach the sphere from the scenegraph, set the weapon rack’s position, attach the weapon rack model to the scenegraph.

I don’t want the spheres to be rendered at all in the game. Would this be the ideal way of doing it? Or is there a better way?

I’m not sure how 3ds Max’s tags work, but in Blender I did something similar by setting Prop { propname } in the egg file. I have a custom exporter, so I can control exactly what gets written. All props are children of an object called Props, so I can just enumerate through its children in Panda3d, pull out the prop’s name with getTag(), and load the corresponding model at that position.

Your way of tagging things “weaponsrack” and then checking explicitly for something with that tag is problematic. You need to know the names of all props beforehand in the panda3d code, and your code will fail if you try to load a prop that doesn’t exist in the .egg file because you didn’t check it exists before calling getPos() on it.

Instead of setting weaponsrack = 1, I would try setting Prop = weaponsrack (assuming you can set strings like this).

Then you could call levelmodel.findAllMatches(’**/=Prop’), which will return a list of all objects with a tag called prop. You can then access the tag’s value by calling object.getTag(“Prop”), which would be in this case “weaponsrack”. You can use this to load the correct model without having to know its string beforehand.

As for the objects showing up: because of the custom exporter, I could just tell it to not write any geometry to the egg file for children of Props. I’m not sure how you’d do that. Your detachnode() call should delete it anyway (or perhaps remove() would be better?).

Like that sir that’s a good idea for your characters, i impress about that idea if you make that you use a weapons to your characters i thing that’s perfect combinations.

Yeah, this is a viable approach. We’ve used it in the Naith project, search around for the source code - it uses xml files to describe how the tags should be interpreted. Instead of a sphere you can use an object with one vertex, or something like that if you don’t want it to show up. Some modelling programs, like Blender, even have this concept of an empty node, so you can use that instead.