How I get objects/meshes in an egg file ?

Hi,

I need a little help to understand better the way of panda works…
Since 2008 I develop a game (personal project) using C# and Blitz3D, but I want to test the Panda for know the good and worse points to verify if is possible the conversion from Blitz to Panda.

When I load the egg model (exported from Blender) I saw some errors and warnings, like this:

Ok, is normal, because the blender use relative paths, now I want to read all objects/meshes in egg file and get the name of mesh/object to load manually the texture (like I do in Blitz3D).

For example, this images are the same file / scene loaded directly in Blitz3D:

In Blitz I used a little loop from main object to childrens.

How I do in Panda ?

You can do model.findAllMatches("**") which returns a NodePathCollection which should return all the object in your model. However I’m sure theres a better way to load the textures relative to the model just using the egg tools or editing the egg file. I’m not a blender user though so I can’t give you a solid answer. I’m sure someone else can point you to a better way of loading your model though.

As an aside, that level looks really fantastic.

ZeroByte

First, thanks for reply and thanks for the comments about my screens :laughing:
I believe is possible improve the render result in Panda, the result in Blitz not is better than Panda.

So…I read more about the creation of class in Python (take easy, is my second day using the language) and I extract the methods for load the scene into a simple class.

print "Iniciando carregamento de " + arquivo
		self.__model = loader.loadModel(Filename.fromOsSpecific(arquivo))
		objetos = self.__model.findAllMatches("**")
		for objeto in objetos:
			objeto_node = objeto.node()
			print "Depurando " + objeto_node.getName() + " do tipo " + str(objeto_node.getType())
			#print objeto_node.getTexture().getFilename()			
		print "Finalizando carregamento de " + arquivo
		self.__model.reparentTo(render)
		self.__model.setScale(0.025,0.025,0.025)

The problem is the attribute texture of objects…
How I do ?
The returned object is a GeomNode and I found only in PandaNode methods to access the texture of an isolated object. For example, my scene have triggers to change camera position, start cinematics, etc… so I need to use a loop for “build” the scene in runtime.

Here a simple output, I see the objects in collection, but I dont have idea how I get the texture for GeomNode

Hmm… I really think this would be handled better if the egg file had the texture paths set relative to the file. Could you open the egg file with a text editor and pastebin it? There should be file paths there that point to your textures.

When troubleshooting missing textures from blender to egg:

  • Make sure it has a proper UV map, and that the texture is mapped to UV, not to Orco.
  • Make sure the paths to the texture are correct. In your case, one of them isn’t… Edit the egg file by hand and make sure it contains the relative path to the texture.

Oh my god !!!
Now that I discovery and work in blender to fix the relative paths of textures, my plugin in NetBeans dont work !!!

To fix the problem:

But, in NetBeans…

java.lang.NullPointerException
	at org.netbeans.modules.python.project.ui.actions.RunCommand.invokeAction(RunCommand.java:52)
	at org.netbeans.modules.python.project.PythonActionProvider$1.run(PythonActionProvider.java:70)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)

After one hour…finally I configure the PyDev in eclipse correctly to continue the work…

Many texture are correct now, but I need hide my triggers (saw the White Walls ?!?!) .


By mcunha98 at 2009-07-09

It’s looking nice mcunha, to edit the path to the textures I do that: In the .egg file, I edit directly the path to the textures instead to go in blender and editing it, I think to use Blender to do that would be more tedious.

Look in the chicken manual for something about object-types. You can set those trigger walls into collision polygons that panda can directly load and which won’t show up in panda unless you .show() them.

Or if you don’t want them to be exported at all, add a “ForceEmpty” property in blender and set it to False.

cute town you have there. waiting to see it in the showcase forum :slight_smile:

Guys…sorry ask again but is very hard…
I get all GeomNode object in my scene, but I need for example if my objects is named “worldspawn” I neet to set the position of my model in worldspawn GeomNode reference and in sequece delete the WorldSpawn GeomNode object

panda3d.org/apiref.php?page=GeomNode

See a piece of code:

		arquivo = "level/" + self.__model_filename + "/@map.egg"
		print "Iniciando carregamento de " + arquivo
		self.__model = loader.loadModel(arquivo)
		objetos = self.__model.findAllMatches("**")
		for objeto in objetos:
			objeto_node = objeto.node()
			print "Depurando " + objeto_node.getName() + " do tipo " + str(objeto_node.getType()) + " e classe " +  str(objeto_node.getClassType())
			
			if objeto_node.getName() == "worldspawn":
				worldspawn = objeto_node
				print "Worldspawn encontrado !"
			
			if objeto_node.getName() == "cam-pos-001":
				base.camera.setPos(objeto_node.getPos())
		
		print "Finalizando carregamento de " + arquivo

A little example of the problem is it:

			if objeto_node.getName() == "cam-pos-001":
				base.camera.setPos(objeto_node.getPos())

:laughing:
Thanks and wait when I put the light points :wink:

Another try…and nothing :frowning:

		worldspawn = self.model.findAllMatches("**/worldspawn") 
		if worldspawn != None and self.billy != None:
			print "Worldspawn encontrado e Billy posicionado !"
			self.billy.getModel().setPos(worldspawn.getPos())

It’s not clear what you’re trying to do. A GeomNode, plucked out of the middle of an egg file, doesn’t usually have any position other than (0, 0, 0). Even if it contains polygons that are nowhere near (0, 0, 0); the position of the polygons has little to do with the node’s position.

If you want to put a marker in the model, to hold a position for you to set your camera to, you should probably tag it with in the egg file. The “DCS” tag tells Panda that the local coordinate system of this node is relevant, and it should not be optimized away. That way, it will keep whatever translation it had in your modeling package, and your getPos() value will be meaningful.

David

In https://discourse.panda3d.org/viewtopic.php?t=6629 you see the same code I’m trying…

self.Level.find("**/start_point").getPos()
        self.player.setPos(playerStartPos-0.5)


By mcunha98

I want to put my player model in a initial position in my scene…only this.
I dont understand the process about the DCS tag

It comes down to what’s in the egg file. That code will only work if “start_point” is a particular kind of node in the egg file, either a Locator or a node tagged with DCS. An ordinary geom node won’t do it.

David

With the help vinicius_mar at hotmail dot com I fix the problem, but actually not is easy.

		self.worldspawn = self.model.findAllMatches("**/worldspawn") 
		if self.worldspawn != None and self.worldspawn.isEmpty() == False:
			self.worldspawn = self.worldspawn.getPath(0)
			print "Worldspawn encontrado e Billy posicionado !"

Implementation:

if cenarioatual != None and cenarioatual.getWorldspawn != None :
    billy.getModel().setPos(cenarioatual.getWorldspawn().getPos())
    camera.setPos(cenarioatual.getWorldspawn().getPos())

I believe that in blender, if you use an “Empty” for the models, chicken will add such a tag automatically, because empties are kinda meant for that purpose.

This is good and not !
For example, in worldspawn object (now, an empty) ok !
But, for example I have triggers (complete cube to active/deactive camera), see the black “wall” in image above.

When the player collides with the trigger, I need to active/deactive a camera position.